Skip to content
Oruga
Bulma
Bootstrap

Timepicker

The Timepicker input component allow users to select a time, and type the date directly into the input. The input opens a simple popover/modal for selecting a time, and uses the native timepicker for mobile.

The overlay is implemented using the native Popover API.

Use it with the Field component to access all the functionalities.

Examples

Base

html
<section>
    <o-field grouped>
        <o-field>
            <o-switch v-model="enableSeconds" label="Enable seconds" />
        </o-field>
        <o-field label="Locale">
            <o-select v-model="locale">
                <option :value="undefined"></option>
                <option value="de-DE">de-DE</option>
                <option value="en-CA">en-CA</option>
                <option value="en-GB">en-GB</option>
                <option value="en-US">en-US</option>
                <option value="es-ES">es-ES</option>
                <option value="es-MX">es-MX</option>
                <option value="fr-CA">fr-CA</option>
                <option value="fr-FR">fr-FR</option>
                <option value="it-IT">it-IT</option>
                <option value="ja-JP">ja-JP</option>
                <option value="pt-BR">pt-BR</option>
                <option value="ru-RU">ru-RU</option>
                <option value="zn-CN">zn-CN</option>
            </o-select>
        </o-field>
        <o-field label="Hour format">
            <o-select v-model="hourFormat">
                <option :value="undefined"></option>
                <option value="12">12</option>
                <option value="24">24</option>
            </o-select>
        </o-field>
    </o-field>

    <o-field label="Select time">
        <o-timepicker
            v-model="selected"
            placeholder="Click to select..."
            icon="clock"
            :enable-seconds="enableSeconds"
            :hour-format="hourFormat"
            :locale="locale" />
    </o-field>
    <p><b>Selected:</b> {{ selected }}</p>
</section>
javascript
import { ref } from "vue";

const selected = ref(new Date());
const hourFormat = ref(); // Browser locale
const enableSeconds = ref(false);
const locale = ref(); // Browser locale

Inline

To render the component inline instead of a dropdown/modal use the inline prop.

html
<section>
    <o-timepicker inline />
</section>

Min/Max date

Use the min-time and max-time props to define a limited time range for the user to choose from.

html
<section>
    <o-field label="Select time">
        <o-timepicker
            placeholder="Click to select..."
            rounded
            :min-time="minTime"
            :max-time="maxTime" />
    </o-field>
</section>
javascript
import { ref } from "vue";

const min = new Date();
min.setHours(9);
min.setMinutes(0);
const max = new Date();
max.setHours(18);
max.setMinutes(0);

const minTime = ref(min);
const maxTime = ref(max);

Templates

The component has an additional footer template slot for customization.

html
<section>
    <o-field label="Select time">
        <o-timepicker v-model="time" placeholder="Click to select...">
            <template #footer>
                <o-button
                    label="Now"
                    variant="primary"
                    icon-left="clock"
                    @click="time = new Date()" />

                <o-button
                    label="Clear"
                    variant="danger"
                    icon-left="times"
                    outlined
                    @click="time = undefined" />
            </template>
        </o-timepicker>
    </o-field>
</section>
javascript
import { ref } from "vue";

const time = ref<Date | undefined>(new Date());
scss
button {
    margin-left: 0.5rem;
}

Granularity

To define the granularity of the hours, minutes and seconds to select from use the increment-hours, increment-minutes and increment-seconds props.

html
<section>
    <o-field label="Select timepicker">
        <o-timepicker
            placeholder="Click to select"
            icon="clock"
            enable-seconds
            :increment-minutes="5"
            :increment-hours="2"
            :increment-seconds="15" />
    </o-field>
</section>

Timepicker Component

An input with a simple dropdown/modal for selecting a time, uses native timepicker for mobile.

html
<o-timepicker></o-timepicker>

Props

Prop nameDescriptionTypeValuesDefault
activeThe active state of the dropdownboolean-false
ariaSelectHoursLabelAccessibility hours select aria labelstring-
From config:
timepicker: {
  ariaSelectHourLabel: "Select Hour"
}
ariaSelectMinutesLabelAccessibility minutes select aria labelstring-
From config:
timepicker: {
  ariaSelectMinuteLabel: "Select Minute"
}
ariaSelectSecondsLabelAccessibility seconds select aria labelstring-
From config:
timepicker: {
  ariaSelectSecondLabel: "Select Second"
}
creatortime creator function, default is new Date()(() => Date)-
From config:
timepicker: {
  creator: undefined
}
customValidityCustom HTML 5 validation error to set on the form controlstring | ((currentValue: Date | null , state: ValidityState) => string) | undefined-""
defaultMinutesnumber-
defaultSecondsnumber-
desktopModalPicker content is shown into a modal on desktopboolean-
From config:
timepicker: {
  desktopModal: false
}
disabledSame as native disabledboolean-false
enableSecondsboolean-false
expandedMakes input full width when inside a grouped or addon fieldboolean-
From config:
timepicker: {
  expanded: false
}
formatterCustom function to format a date into a string((date: Date ) => string) | undefined-
From config:
timepicker: {
  formatter: undefined
}
hourFormat"12" | "24" | 12 | 24-
iconIcon to be shownstring-
From config:
timepicker: {
  icon: undefined
}
iconPackIcon pack to usestringmdi, fa, fas and any other custom icon pack
From config:
timepicker: {
  iconPack: undefined
}
iconRightIcon to be added on the right sidestring-
From config:
timepicker: {
  iconRight: undefined
}
iconRightClickableMake the icon right clickableboolean-false
incrementHoursnumber-1
incrementMinutesnumber-1
incrementSecondsnumber-1
inlineDisplay datepicker inlineboolean-false
localeDate format localestring-
From config:
{
  locale: undefined
}
maxTimeMax time to selectDate-
minTimeMin time to selectDate-
mobileBreakpointMobile breakpoint as max-width valuestring-
From config:
timepicker: {
  mobileBreakpoint: undefined
}
mobileModalPicker content is shown into a modal on mobileboolean-
From config:
timepicker: {
  mobileModal: true
}
mobileNativeEnable mobile native input if mobile agentboolean-
From config:
timepicker: {
  mobileNative: true
}
v-modelThe input value state, use v-model to make it two-way bindingDate-
openOnFocusOpen picker on focusboolean-
From config:
timepicker: {
  openOnFocus: true
}
overrideOverride existing theme classes completelyboolean-
parserCustom function to parse a string into a date((date: string) => Date ) | undefined-
From config:
timepicker: {
  parser: undefined
}
placeholderInput placeholderstring-
positionPosition of the popover relative to the input"bottom" | "center" | "left" | "right" | "top"auto, top, bottom, left, right, center
From config:
timepicker: {
  position: "bottom"
}
readonlySame as native input readonlyboolean-false
resetOnMeridianChangeReset the time inputs when meridian changesboolean-false
roundedMakes the input roundedboolean-false
sizeSize of the buttonstringsmall, medium, large
From config:
timepicker: {
  size: undefined
}
stayOpenThe picker stays open after date got pickedboolean-
teleportAppend the component to another part of the DOM.
Set true to append the component to the body.
In addition, any CSS selector string or an actual DOM node can be used.
boolean | object | string-
From config:
timepicker: {
  teleport: false
}
unselectableTimesDefine a list of times which can not be selectedDate[] | ((date: Date) => boolean)-
useHtml5ValidationEnable HTML 5 native validationboolean-
From config:
{
  useHtml5Validation: true
}

Events

Event namePropertiesDescription
focusevent Event - native eventon input focus event
blurevent Event - native eventon input blur event
invalidevent Event - native eventon input invalid event
icon-clickevent Event - native eventon icon click event
icon-right-clickevent Event - native eventon icon right click event
update:model-valuevalue Date - updated modelValue propmodelValue prop two-way binding
update:activevalue boolean - updated active propactive prop two-way binding

Slots

NameDescriptionBindings
triggerOverride the trigger input element
headerDefine an additional content before the body
bodyOverride the content body
footerDefine an additional content after the body

Class Inspector

Classes applied to the element:
Want to know how does the Class Inspector work?
Class propDescriptionPropsSuffixes
rootClass
Class of the root element.
mobileClass
Class of the root element when on mobile.
👉 Switch to mobile view to see it in action!
teleportClass
Class of the root element when teleported.
teleport
disabledClass
Class of the root element when disabled.
disabled
sizeClass
Class of the root element with size.
sizesmall
medium
large
expandedClass
Class of the root element when expanded.
expanded
inlineClass
Class of the root element when inlined.
inline
activeClass
Class of the root element when active.
active
triggerClass
Class of the trigger element.
contentClass
Class of the box container element where you choose the date.
contentModalClass
Class of the content element when shown as modal.
mobileModal
desktopModal
contentBackdropClass
Class of the content when should has a backdrop.
mobileModal
desktopModal
contentActiveClass
Class of the content element when active.
active
headerClass
Class of the content header element.
bodyClass
Class of the content body element.
separatorClass
Class of the select separator element.
footerClass
Class of the content footer element.
inputClass
Class to apply on the input element.
More details here.
inputAttrs
Input properties to apply on the internal input component.
More details here.
selectClass
Class to apply on the select element.
More details here.
selectAttrs
Select properties to apply on the internal select component.
More details here.

Sass Variables

Current theme ➜ Oruga

SASS VariableDefault
$timepicker-font-sizeh.useVar("font-size")
$timepicker-colorh.useVar("font-color")
$timepicker-line-heighth.useVar("line-height")
$timepicker-font-weight600
$timepicker-box-padding0 calc(2 * h.useVar("control-spacer"))
$timepicker-footer-padding0 0.5rem
$timepicker-select-paddingh.useVar("control-padding-vertical") h.useVar("control-padding-horizontal")
$timepicker-select-placeholder-opacityh.useVar("disabled-opacity")

See ➜ 📄 SCSS file

Current theme ➜ Bulma

The theme does not have any custom variables for this component.

Current theme ➜ Bootstrap

SASS VariableDefault
$timepicker-select-width4em

See ➜ 📄 SCSS file

Released under the MIT License.