Skip to content

TimePicker

Rules

Basic Example

js
const rule = {
    type: "TimePicker",
    field: "section_time",
    title: "Activity Time",
    value: ''
}

Props Configuration Examples

Time Range Selection

js
const rule = {
    type: "TimePicker",
    field: "timeRange",
    title: "Business Hours",
    value: [],
    props: {
        format: "HH:mm:ss",
        placeholder: ["Start Time", "End Time"],
    },
}

Disable Partial Time

js
const rule = {
    type: "TimePicker",
    field: "workTime",
    title: "Work Time",
    value: "09:00:00",
    props: {
        format: "HH:mm:ss",
        disabledTime: () => {
            return {
                disabledHours: () => [...Array(9).keys(), ...Array.from({length: 6}, (_, i) => i + 18)],
                disabledMinutes: (hour) => {
                    if (hour === 12) {
                        return [0, 30];
                    }
                    return [];
                },
            };
        },
    },
}

Events Examples

Listen to Time Changes

js
const rule = {
    type: "TimePicker",
    field: "startTime",
    title: "Start Time",
    value: "09:00:00",
    props: {
        format: "HH:mm:ss",
        placeholder: "Select time",
    },
    on: {
        change: (time, timeString) => {
            console.log('Time changed:', time, timeString);
        },
    },
}

Reference: Ant-design-vue_TimePicker

value :Number | String

Props

ParameterDescriptionTypeDefault
allowClearWhether to show clear buttonbooleantrue
autofocusAuto focusbooleanfalse
borderedWhether to have borderbooleantrue
clearIconCustom clear iconv-slot:clearIcon-
clearTextTooltip text for clear buttonstringclear
disabledDisable all operationsbooleanfalse
disabledTimeTime that cannot be selectedDisabledTime-
formatDisplay time formatstringHH:mm:ss
getPopupContainerDefine popup container, default creates new div on bodyfunction(trigger)-
hideDisabledOptionsHide disabled optionsbooleanfalse
hourStepHour option intervalnumber1
inputReadOnlySet input box to read-only (avoid opening virtual keyboard on mobile devices)booleanfalse
minuteStepMinute option intervalnumber1
openWhether panel is openbooleanfalse
placeholderContent displayed when there is no valuestring | [string, string]Select time
placementPosition where selector pops upbottomLeft bottomRight topLeft topRightbottomLeft
popupClassNamePopup class namestring-
popupStylePopup style objectobject-
renderExtraFooterCustom content displayed at bottom of selectorv-slot:renderExtraFooter-
secondStepSecond option intervalnumber1
showNowWhether panel displays "Now" buttonboolean-
statusSet validation status'error' | 'warning'-
suffixIconCustom suffix icon for selectorv-slot:suffixIcon-
use12HoursUse 12-hour format, when true format defaults to h:mm:ss abooleanfalse
valueFormatOptional, format of bound value, affects value, defaultValue. If not specified, bound value is dayjs objectstring, Specific format-

DisabledTime

typescript
type DisabledTime = (now: Dayjs) => {
  disabledHours?: () => number[];
  disabledMinutes?: (selectedHour: number) => number[];
  disabledSeconds?: (selectedHour: number, selectedMinute: number) => number[];
};

Events

Event NameDescriptionCallback Parameters
changeCallback when time changesfunction(time: dayjs | string, timeString: string): void
openChangeCallback when panel opens/closes(open: boolean): void

TimeRangePicker

Properties are the same as DatePicker's RangePicker. Also includes the following properties:

ParameterDescriptionTypeDefault
orderWhether start and end time are automatically sortedbooleantrue
disabledTimeTime that cannot be selectedRangeDisabledTime-

RangeDisabledTime

typescript
type RangeDisabledTime = (
  now: Dayjs,
  type = 'start' | 'end',
) => {
  disabledHours?: () => number[];
  disabledMinutes?: (selectedHour: number) => number[];
  disabledSeconds?: (selectedHour: number, selectedMinute: number) => number[];
};

FormCreate is an open-source project released under the MIT License. Free for personal and commercial use.