Skip to content

TimePicker Time Picker ​

Rules ​

Basic Example ​

js
const rule = {
    type: "TimePicker",
    field: "section_time",
    title: "Activity Time",
    value: [],
    props: {
        isRange: true
    },
}

Props Configuration Examples ​

Single Time Selection ​

js
const rule = {
    type: "TimePicker",
    field: "startTime",
    title: "Start Time",
    value: "09:00:00",
    props: {
        placeholder: "Select time",
        format: "HH:mm:ss",
        valueFormat: "HH:mm:ss",
        clearable: true,
    },
}

Time Range Selection ​

js
const rule = {
    type: "TimePicker",
    field: "timeRange",
    title: "Business Hours",
    value: ["09:00:00", "18:00:00"],
    props: {
        isRange: true,
        rangeSeparator: "to",
        startPlaceholder: "Start Time",
        endPlaceholder: "End Time",
        format: "HH:mm:ss",
        valueFormat: "HH:mm:ss",
    },
}

Arrow Control ​

js
const rule = {
    type: "TimePicker",
    field: "appointment",
    title: "Appointment Time",
    value: "14:30:00",
    props: {
        arrowControl: true,
        format: "HH:mm",
        valueFormat: "HH:mm",
    },
}

Disable Part of Time ​

js
const rule = {
    type: "TimePicker",
    field: "workTime",
    title: "Work Time",
    value: "09:00:00",
    props: {
        format: "HH:mm:ss",
        disabledHours: () => {
            // Disable 0-8 and 18-23 hours
            return [...Array(9).keys(), ...Array.from({length: 6}, (_, i) => i + 18)];
        },
        disabledMinutes: (hour) => {
            // Disable certain minutes in specific hours
            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: {
        placeholder: "Select time",
        format: "HH:mm:ss",
        clearable: true,
    },
    on: {
        change: (value) => {
            console.log('Time changed:', value);
        },
        blur: (event) => {
            console.log('Lost focus:', event);
        },
        focus: (event) => {
            console.log('Gained focus:', event);
        },
        clear: () => {
            console.log('Cleared time');
        },
        'visible-change': (visible) => {
            console.log('Dropdown visibility:', visible);
        },
    },
}

Full configuration: Element_TimePicker

value :Number | String

Props ​

Attribute NameDescriptionTypeDefault
readonlyCompletely readonlybooleanfalse
disabledDisablebooleanfalse
editableWhether the text box can be editedbooleantrue
clearableWhether to show clear buttonbooleantrue
sizeInput box sizeenum—
placeholderPlaceholder content for non-range selectionstring''
startPlaceholderPlaceholder content for start date in range selectionstring—
endPlaceholderPlaceholder content for end date in range selectionstring—
isRangeWhether it is time range selectionbooleanfalse
arrowControlWhether to use arrows for time selectionbooleanfalse
popperClassClass name for TimePicker dropdownstring''
rangeSeparatorSeparator when selecting rangestring'-'
formatFormat displayed in input boxstring see date formats—
defaultValueOptional, default time displayed when picker opensDate / object—
valueFormatOptional, format of bound value. If not specified, bound value is Date objectstring Refer to date formats—
idEquivalent to native input id attributestring / object—
nameEquivalent to native input name attributestring''
ariaLabelEquivalent to native input aria-label attributestring—
prefixIconCustom prefix iconstring / ComponentClock
clearIconCustom clear iconstring / ComponentCircleClose
disabledHoursDisable selection of partial hour optionsFunction—
disabledMinutesDisable selection of partial minute optionsFunction—
disabledSecondsDisable selection of partial second optionsFunction—
teleportedWhether to mirror popover dropdown list to body elementbooleantrue
tabindexTabindex of input boxstring / number0
emptyValuesEmpty value configuration for component Refer to config-providerarray—
valueOnClearValue when clearing options Refer to config-providerstring / number / boolean / Function—
labelEquivalent to native input aria-label attributestring—

Events ​

Event NameDescriptionType
changeTriggered when user confirms selected valueFunction
blurTriggered when component Input loses focusFunction
focusTriggered when component Input gains focusFunction
clearTriggered when user clicks clear button in clearable modeFunction
visible-changeTriggered when TimePicker dropdown list appears/disappearsFunction

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