DatePicker
Select a date, month, year, or date range.
Basic Usage
<template>
<bp-date-picker v-model="val" :disabledDate style="width: 200px" placeholder="Please select" />
</template>
<script setup lang="ts">
import dayjs from "dayjs";
import { ref } from "vue";
const val = ref();
const disabledDate = (current) => dayjs(current).isBefore(dayjs("2025-05-22"));
</script>Date Range
Use date-range-picker to select a range. Enable show-time to pick times as well — a date/time summary and confirm footer appear below the calendars. Set default-time for the default start/end clock values (default ['00:00:00', '23:59:59']).
<template>
<div style="display: flex; gap: 40px; flex-wrap: wrap">
<div>
<div class="label">Date range</div>
<bp-date-range-picker v-model="val" style="width: 320px" :placeholder="['Start date', 'End date']" />
<div class="value">Value: {{ val }}</div>
</div>
<div>
<div class="label">Date-time range</div>
<bp-date-range-picker
v-model="valTime"
show-time
:default-time="['00:00:00', '23:59:59']"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 400px"
:placeholder="['Start time', 'End time']"
/>
<div class="value">Value: {{ valTime }}</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
const val = ref<string[]>([]);
const valTime = ref<string[]>([]);
</script>
<style scoped>
.label {
font-size: 13px;
color: #86909c;
margin-bottom: 6px;
}
.value {
font-size: 13px;
color: #4e5969;
margin-top: 8px;
}
</style>Shortcuts
Shortcuts (Last 7 days / Last 30 days / Last year) appear on the left by default. Customize with range-shortcuts, hide with false, or move with shortcuts-position.
<template>
<div style="display: flex; gap: 40px; flex-wrap: wrap">
<div>
<div class="label">Default shortcuts</div>
<bp-date-range-picker v-model="val" style="width: 320px" :placeholder="['Start date', 'End date']" />
<div class="value">Value: {{ val }}</div>
</div>
<div>
<div class="label">Custom shortcuts (right)</div>
<bp-date-range-picker
v-model="valCustom"
style="width: 320px"
shortcuts-position="right"
:range-shortcuts="customShortcuts"
:placeholder="['Start date', 'End date']"
/>
<div class="value">Value: {{ valCustom }}</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import dayjs from "dayjs";
import type { RangeShortcut } from "birdpaper-ui";
const val = ref<string[]>([]);
const valCustom = ref<string[]>([]);
const customShortcuts: RangeShortcut[] = [
{
label: "Next 2 days",
value: () => [dayjs(), dayjs().add(2, "day")],
},
{
label: "Next 7 days",
value: () => [dayjs(), dayjs().add(1, "week")],
},
{
label: "Next 30 days",
value: () => [dayjs(), dayjs().add(1, "month")],
},
{
label: "Next 6 months",
value: () => [dayjs(), dayjs().add(6, "month")],
},
{
label: "Next 12 months",
value: () => [dayjs(), dayjs().add(1, "year")],
},
];
</script>
<style scoped>
.label {
font-size: 13px;
color: #86909c;
margin-bottom: 6px;
}
.value {
font-size: 13px;
color: #4e5969;
margin-top: 8px;
}
</style>With Time
Enable show-time and format with value-format.
<template>
<bp-date-picker
v-model="val"
value-format="YYYY-MM-DD HH:mm:ss"
show-time
style="width: 200px"
placeholder="Please select"
/>
</template>
<script setup lang="ts">
import { ref } from "vue";
const val = ref();
</script>Month and Year
Use month-picker and year-picker.
<template>
<bp-space type="vertical">
<bp-month-picker v-model="val" style="width: 200px" placeholder="Please select" />
<bp-month-picker v-model="val" hide-trigger style="width: 200px" placeholder="Please select" />
</bp-space>
</template>
<script setup lang="ts">
import { ref } from "vue";
const val = ref();
</script>Panel Only
Hide the trigger with hide-trigger.
<template>
<bp-date-picker v-model="val" hide-trigger style="width: 200px" placeholder="Please select" />
</template>
<script setup lang="ts">
import { ref } from "vue";
const val = ref();
</script>Custom Trigger
Use the #trigger slot to replace the default input (e.g. with a button). Scoped props: value (current value) and visible (whether the panel is open). Supported by DatePicker, DateRangePicker, MonthPicker, and YearPicker.
<template>
<div style="display: flex; gap: 40px; flex-wrap: wrap; align-items: flex-start">
<div>
<div class="label">Date</div>
<bp-date-picker v-model="date">
<template #trigger>
<bp-button type="secondary">Pick a date</bp-button>
</template>
</bp-date-picker>
<div class="value">Value: {{ date }}</div>
</div>
<div>
<div class="label">Date range</div>
<bp-date-range-picker v-model="range">
<template #trigger>
<bp-button type="secondary">Pick a date range</bp-button>
</template>
</bp-date-range-picker>
<div class="value">Value: {{ range }}</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
const date = ref("");
const range = ref<string[]>([]);
</script>
<style scoped>
.label {
font-size: 13px;
color: #86909c;
margin-bottom: 6px;
}
.value {
font-size: 13px;
color: #4e5969;
margin-top: 8px;
}
</style>Clearable and Disabled
Combine clearable, disabled, and disabled-date.
<template>
<div style="display: flex; gap: 40px">
<div>
<div class="label">Clearable</div>
<bp-date-picker v-model="val" clearable style="width: 200px" placeholder="Please select" />
</div>
<div>
<div class="label">Disabled</div>
<bp-date-picker v-model="val2" disabled style="width: 200px" />
</div>
<div>
<div class="label">Disabled dates</div>
<bp-date-picker v-model="val3" :disabled-date="disabledDate" style="width: 200px" placeholder="Please select" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import dayjs from "dayjs";
const val = ref("");
const val2 = ref("2024-06-15");
const val3 = ref("");
const disabledDate = (current: string) => dayjs(current).isBefore(dayjs().subtract(1, "day"));
</script>
<style scoped>
.label {
font-size: 13px;
color: #86909c;
margin-bottom: 6px;
}
</style>Localization
Switch locale with langs (zh-cn / en).
<template>
<div style="display: flex; gap: 40px">
<div>
<div class="label">Chinese (default)</div>
<bp-date-picker v-model="val" style="width: 200px" placeholder="Please select" />
</div>
<div>
<div class="label">English</div>
<bp-date-picker v-model="val2" langs="en" style="width: 200px" placeholder="Select" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
const val = ref("");
const val2 = ref("");
</script>
<style scoped>
.label {
font-size: 13px;
color: #86909c;
margin-bottom: 6px;
}
</style>Common Props
| v-model | Bound value | String | - | - |
| name | Picker name | String | - | - |
| size | Input size | InputSize | default | - |
| placeholder | Placeholder | String | - | - |
| disabled | Whether disabled | Boolean | false | - |
| disabled-date | Disabled dates | (value: string) => boolean | - | - |
| clearable | Whether clearable | Boolean | false | - |
| hide-trigger | Whether to show panel only | Boolean | false | - |
| langs | Locale | LangsType | zh-cn | - |
DatePicker Props
| value-format | Value format | String | YYYY-MM-DD | - |
| show-time | Whether to allow time selection | Boolean | - | - |
MonthPicker Props
| value-format | Value format | String | YYYY-MM | - |
YearPicker Props
| value-format | Value format | String | YYYY | - |
RangePicker Props
| v-model | Bound value | String[] | - | - |
| placeholder | Placeholder | String[] | ['', ''] | - |
| size | Input size | InputSize | default | - |
| disabled | Whether disabled | Boolean | false | - |
| disabled-date | Disabled dates | (value: string) => boolean | - | - |
| hide-trigger | Whether to show panel only | Boolean | false | - |
| langs | Locale | LangsType | zh-cn | - |
| value-format | Value format | String | YYYY-MM-DD | - |
| show-time | Whether to show time selection | Boolean | false | - |
| default-time | Default start/end time when show-time is enabled | [string, string] | ['00:00:00', '23:59:59'] | - |
| range-shortcuts | Range shortcuts. true for built-in presets, false to hide, or pass an array to customize | RangeShortcut[]boolean | true | - |
| shortcuts-position | Side of the shortcuts panel | RangeShortcutsPosition | left | - |
Slots
Shared by DatePicker / DateRangePicker / MonthPicker / YearPicker.
| trigger | Custom trigger element; falls back to the default input when omitted | { value, visible } | - |