Date picker
Input plus month-grid panel. Supports day/month/year views, min/max/disabledDate constraints, and clearing.
Basic usage
v-model binds a 'YYYY-MM-DD' string. Clicking the trigger opens the month panel; clicking a day cell selects it and closes the panel. Clicking the month name jumps to the month view; clicking the year jumps to the year view.
2026-05-09<script setup lang="ts">
import { ref } from 'vue';
import { CfDatePicker } from '@chufix-design/vue';
const value = ref<string | null>('2026-05-09');
</script>
<template>
<CfDatePicker v-model="value" clearable />
</template> import { useState } from 'react';
import { CfDatePicker } from '@chufix-design/react';
export default function Demo() {
const [value, setValue] = useState<string | null>('2026-05-09');
return <CfDatePicker value={value} clearable onChange={(v) => setValue(v)} />;
} Bounds and disabledDate
minDate / maxDate constrain the selectable range. disabledDate is a (date: Date) => boolean callback; dates that return true are struck through and cannot be clicked.
<script setup lang="ts">
import { ref } from 'vue';
import { CfDatePicker } from '@chufix-design/vue';
const value = ref<string | null>(null);
const noWeekends = (d: Date) => d.getDay() === 0 || d.getDay() === 6;
</script>
<template>
<CfDatePicker
v-model="value"
min-date="2026-01-01"
max-date="2026-12-31"
:disabled-date="noWeekends"
clearable
/>
</template> import { useState } from 'react';
import { CfDatePicker } from '@chufix-design/react';
const noWeekends = (d: Date) => d.getDay() === 0 || d.getDay() === 6;
export default function Demo() {
const [value, setValue] = useState<string | null>(null);
return (
<CfDatePicker
value={value}
minDate="2026-01-01"
maxDate="2026-12-31"
disabledDate={noWeekends}
clearable
onChange={(v) => setValue(v)}
/>
);
} Display format
format controls how the date is rendered in the trigger (it does not affect the v-model storage format, which is always 'YYYY-MM-DD'). Supported tokens: YYYY YY MM M DD D.
<CfDatePicker v-model="a" format="YYYY-MM-DD" />
<CfDatePicker v-model="b" format="YYYY 年 M 月 D 日" />
<CfDatePicker v-model="c" format="DD/MM/YYYY" /> <CfDatePicker value={a} format="YYYY-MM-DD" onChange={(v) => setA(v)} />
<CfDatePicker value={b} format="YYYY 年 M 月 D 日" onChange={(v) => setB(v)} />
<CfDatePicker value={c} format="DD/MM/YYYY" onChange={(v) => setC(v)} /> API
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue (Vue) / value (React) | Date | string | number | null | null | Current date; accepts ISO / timestamp / Date as input |
format | string | 'YYYY-MM-DD' | Trigger display format |
placeholder | string | 'Select a date' | Placeholder text |
variant | 'outline' | 'filled' | 'ghost' | 'outline' | Trigger visual variant |
size | 'sm' | 'md' | 'lg' | 'md' | Size |
disabled | boolean | false | Disabled |
clearable | boolean | false | Show clear button |
error | boolean | false | Error state |
minDate / maxDate | DateLike | — | Selectable range |
disabledDate | (date: Date) => boolean | — | Custom disable rule |
weekStartsOn | 0 | 1 | 1 | 0 = Sunday-first, 1 = Monday-first |
view | 'day' | 'month' | 'year' | 'day' | Initial open view |
Events: update:modelValue / change (React: onChange(value, date), the second argument is Date \| null).
反馈与讨论
Date picker · Discussion