Mobilens English

控件 · 输入

日期选择器

所有状态

何时出现
行为规则

    用法

    import { useState } from 'react';
    import { DatePicker } from '@/components/mobilens/DatePicker';
    
    export function DeliveryDate({ firstDay, lastDay }: { firstDay: string; lastDay: string }) {
      const [date, setDate] = useState<string | null>(null);
      return <DatePicker label="Delivery date" locale="en-US" value={date} onChange={setDate}
        min={firstDay} max={lastDay} clearable />;
    }
    

    API

    参数类型默认值说明
    label string – Label above the date field.
    value string | null – Selected calendar date as YYYY-MM-DD, or null.
    onChange (date: string | null) => void – Receives the selected date, or null when cleared.
    min? string – Earliest selectable YYYY-MM-DD, inclusive.
    max? string – Latest selectable YYYY-MM-DD, inclusive.
    locale? 'en-US' | 'zh-CN' 'en-US' Calendar and button language (en-US or zh-CN).
    defaultOpen? boolean false Open the calendar when the field first mounts.
    initialMonth? string – First month to show for an empty field, given as a YYYY-MM-DD date.
    error? string – Optional form validation message.
    disabled? boolean false Prevent the field from opening or changing.
    clearable? boolean true Show a clear action for an existing selection.