To create a basic Bootstrap Time Picker, use:
<div class="row">
<div class="col-sm-6 col-lg-5 mb-3 mb-sm-0">
<div class="time-picker" data-coreui-locale="en-US" data-coreui-toggle="time-picker" id="timePicker1"></div>
</div>
<div class="col-sm-6 col-lg-5">
<div class="time-picker" data-coreui-locale="en-US" data-coreui-time="02:17:35 PM" data-coreui-toggle="time-picker" id="timePicker2"></div>
</div>
</div>
Sizing
Set heights using data-coreui-size
attribute like data-coreui-size="lg"
and data-coreui-size="sm"
.
<div class="row">
<div class="col-lg-5 mb-3">
<div class="time-picker" data-coreui-locale="en-US" data-coreui-size="lg" data-coreui-toggle="time-picker"></div>
</div>
</div>
<div class="row">
<div class="col-lg-4">
<div class="time-picker" data-coreui-locale="en-US" data-coreui-size="sm" data-coreui-toggle="time-picker"></div>
</div>
</div>
Disabled
Add the data-coreui-disabled="true"
attribute on an input to give it a grayed out appearance and remove pointer events.
<div class="row">
<div class="col-lg-4">
<div class="time-picker" data-coreui-disabled="true" data-coreui-locale="en-US" data-coreui-toggle="time-picker"></div>
</div>
</div>
Readonly
Add the data-coreui-input-read-only="true"
boolean attribute to prevent modification of the input’s value.
<div class="row">
<div class="col-lg-4">
<div class="time-picker" data-coreui-input-read-only="true" data-coreui-locale="en-US" data-coreui-toggle="time-picker"></div>
</div>
</div>
Custom formats Disable minutes and seconds
Customize Bootstrap Time Picker to display only hours, or hours and minutes by disabling minutes/seconds.
<div class="row">
<div class="col-sm-6 col-lg-5 mb-3 mb-sm-0">
<label class="form-label">Only hours and minutes</label>
<div class="time-picker" data-coreui-locale="en-US" data-coreui-seconds="false" data-coreui-toggle="time-picker"></div>
</div>
<div class="col-sm-6 col-lg-5">
<label class="form-label">Only hours</label>
<div class="time-picker" data-coreui-locale="en-US" data-coreui-minutes="false" data-coreui-seconds="false" data-coreui-toggle="time-picker"></div>
</div>
</div>
Custom hours, minutes and seconds
Tailor the Bootstrap Time Picker to your needs by specifying custom values for hours, minutes, and seconds. Use arrays to define selectable options or functions for dynamic filtering. The example below demonstrates setting specific hour options, minute intervals, and a condition for seconds only to include values less than 20.
<div class="row">
<div class="col-lg-4">
<div id="myTimePickerCustom"></div>
</div>
</div>
const myTimePickerCustom = document.getElementById('myTimePickerCustom')
if (myTimePickerCustom) {
const options = {
locale: 'en-US',
hours: [1, 3, 5, 7],
minutes: [0, 15, 30, 45],
seconds: s => s < 20
}
new coreui.TimePicker(document.getElementById('myTimePickerCustom'), options)
}
In this configuration, the Bootstrap TimePicker restricts hours to a predefined set, minutes to quarter intervals, and seconds to values under 20, offering a high degree of customization for precise time selection scenarios.
Non-english localeCoreUI Time Picker allows you to display times in a non-English locale, ideal for international users or multilingual applications.
AutoBy default, the Time Picker uses the browser’s locale. To set a different locale, use the data-coreui-locale
attribute.
<div class="row">
<div class="col-lg-4">
<div data-coreui-toggle="time-picker"></div>
</div>
</div>
Chinese
To configure the Time Picker for Chinese users, set the locale to zh-CN
and provide a placeholder text:
<div class="row">
<div class="col-lg-4">
<div class="time-picker" data-coreui-locale="zh-CN" data-coreui-placeholder="入住日期" data-coreui-toggle="time-picker"></div>
</div>
</div>
Japanese
To localize the Time Picker for Japanese, set the locale to ja
and use an appropriate placeholder:
<div class="row">
<div class="col-lg-4">
<div class="time-picker" data-coreui-locale="ja" data-coreui-placeholder="日付を選択" data-coreui-toggle="time-picker"></div>
</div>
</div>
Korean
For Korean localization, set the locale to ko
and include placeholder text:
<div class="row">
<div class="col-lg-4">
<div class="time-picker" data-coreui-locale="ko" data-coreui-placeholder="날짜 선택" data-coreui-toggle="time-picker"></div>
</div>
</div>
Right to left support
RTL support is built-in and can be explicitly controlled through the $enable-rtl
variables in scss.
<div class="row">
<div class="col-lg-4">
<div class="time-picker" data-coreui-locale="he-IL" data-coreui-placeholder="בחר תאריך" data-coreui-toggle="time-picker" dir="rtl"></div>
</div>
</div>
Persian
<div class="row">
<div class="col-lg-4">
<div class="time-picker" data-coreui-locale="fa-IR" data-coreui-placeholder="تاریخ شروع" data-coreui-toggle="time-picker" dir="rtl"></div>
</div>
</div>
Usage
Heads up! In our documentation, all examples show standard CoreUI implementation. If you are using a Bootstrap-compatible version of CoreUI, remember to use the following changes:
new bootstrap.Alert(...)
instead of new coreui.Alert(...)
close.bs.alert
instead of close.coreui.alert
data-bs-toggle="..."
instead of data-coreui-toggle="..."
Add data-coreui-toggle="time-picker"
to a div
element.
<div data-coreui-toggle="time-picker"></div>
Via JavaScript
Call the time picker via JavaScript:
<div class="time-picker"></div>
const timePickerElementList = Array.prototype.slice.call(document.querySelectorAll('.time-picker'))
const timePickerList = timePickerElementList.map(timePickerEl => {
return new coreui.TimePicker(timePickerEl)
})
Options
Options can be passed using data attributes or JavaScript. To do this, append an option name to data-coreui-
, such as data-coreui-animation="{value}"
. Remember to convert the case of the option name from “camelCase” to “kebab-case” when using data attributes. For instance, you should write data-coreui-custom-class="beautifier"
rather than data-coreui-customClass="beautifier"
.
Starting with CoreUI 4.2.0, all components support an experimental reserved data attribute named data-coreui-config
, which can contain simple component configurations as a JSON string. If an element has attributes data-coreui-config='{"delay":50, "title":689}'
and data-coreui-title="Custom Title"
, then the final value for title
will be Custom Title
, as the standard data attributes will take precedence over values specified in data-coreui-config
. Moreover, existing data attributes can also hold JSON values like data-coreui-delay='{"show":50, "hide":250}'
.
cancelButton
boolean, string 'Cancel'
Cancel button inner HTML cancelButtonClasses
array, string ['btn', 'btn-sm', 'btn-ghost-primary']
CSS class names that will be added to the cancel button cleaner
boolean true
Enables selection cleaner element. confirmButton
boolean, string 'OK'
Confirm button inner HTML confirmButtonClasses
array, string ['btn', 'btn-sm', 'btn-primary']
CSS class names that will be added to the confirm button container
string, element, false false
Appends the dropdown to a specific element. Example: container: 'body'
. disabled
boolean false
Toggle the disabled state for the component. footer
boolean true
Toggle visibility of footer element. hours
array, function, null null
Specify a list of available hours using an array, or customize the filtering of hours through a function. indicator
boolean true
Toggle visibility or set the content of the input indicator. inputReadOnly
boolean false
Toggle the readonly state for the component. invalid
boolean false
Toggle the invalid state for the component. locale
string 'default'
Sets the default locale for components. If not set, it is inherited from the navigator.language. minutes
array, boolean, function true
Toggle the display of minutes, specify a list of available minutes using an array, or customize the filtering of minutes through a function. name
string null
Set the name attribute for the input element. placeholder
string 'Select time'
Specifies a short hint that is visible in the input. seconds
array, boolean, function true
Toggle the display of seconds, specify a list of available seconds using an array, or customize the filtering of seconds through a function. size
'sm'
, 'lg'
null
Size the component small or large. time
date, string, null null
Default value of the component valid
boolean false
Toggle the valid state for the component. variant
'roll'
, 'select'
'roll'
Set the time picker variant to a roll or select. Methods Method Description clear
Clear selection of the time picker. reset
Reset selection of the time picker to the initial value. update
Updates the configuration of the time picker. dispose
Destroys a component. (Removes stored data on the DOM element) getInstance
Static method which allows you to get the time picker instance associated to a DOM element, you can use it like this: coreui.TimePicker.getInstance(element)
getOrCreateInstance
Static method which returns a time picker instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: coreui.TimePicker.getOrCreateInstance(element)
Events Method Description timeChange.coreui.time-picker
Callback fired when the value changed. show.coreui.time-picker
Fires immediately when the show instance method is called. shown.coreui.time-picker
Fired when the dropdown has been made visible to the user and CSS transitions have completed. hide.coreui.time-picker
Fires immediately when the hide instance method has been called. hidden.coreui.time-picker
Fired when the dropdown has finished being hidden from the user and CSS transitions have completed.
const myTimePicker = document.getElementById('myTimePicker')
myTimePicker.addEventListener('timeChange.coreui.time-picker', ({ timeString, localeTimeString, date }) => {
// do something...
})
Customizing CSS variables
TimePickers use local CSS variables on .time-picker
for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
--cui-time-picker-zindex: #{$time-picker-zindex};
--cui-time-picker-font-family: #{$time-picker-font-family};
--cui-time-picker-font-size: #{$time-picker-font-size};
--cui-time-picker-font-weight: #{$time-picker-font-weight};
--cui-time-picker-line-height: #{$time-picker-line-height};
--cui-time-picker-color: #{$time-picker-color};
--cui-time-picker-bg: #{$time-picker-bg};
--cui-time-picker-box-shadow: #{$time-picker-box-shadow};
--cui-time-picker-border-width: #{$time-picker-border-width};
--cui-time-picker-border-color: #{$time-picker-border-color};
--cui-time-picker-border-radius: #{$time-picker-border-radius};
--cui-time-picker-disabled-color: #{$time-picker-disabled-color};
--cui-time-picker-disabled-bg: #{$time-picker-disabled-bg};
--cui-time-picker-disabled-border-color: #{$time-picker-disabled-border-color};
--cui-time-picker-focus-color: #{$time-picker-focus-color};
--cui-time-picker-focus-bg: #{$time-picker-focus-bg};
--cui-time-picker-focus-border-color: #{$time-picker-focus-border-color};
--cui-time-picker-focus-box-shadow: #{$time-picker-focus-box-shadow};
--cui-time-picker-placeholder-color: #{$time-picker-placeholder-color};
--cui-time-picker-padding-y: #{$time-picker-padding-y};
--cui-time-picker-padding-x: #{$time-picker-padding-x};
--cui-time-picker-gap: #{$time-picker-gap};
--cui-time-picker-indicator-width: #{$time-picker-indicator-width};
--cui-time-picker-indicator-icon: #{escape-svg($time-picker-indicator-icon)};
--cui-time-picker-indicator-icon-color: #{$time-picker-indicator-icon-color};
--cui-time-picker-indicator-icon-size: #{$time-picker-indicator-icon-size};
--cui-time-picker-cleaner-width: #{$time-picker-cleaner-width};
--cui-time-picker-cleaner-icon: #{escape-svg($time-picker-cleaner-icon)};
--cui-time-picker-cleaner-icon-color: #{$time-picker-cleaner-icon-color};
--cui-time-picker-cleaner-icon-hover-color: #{$time-picker-cleaner-icon-hover-color};
--cui-time-picker-cleaner-icon-size: #{$time-picker-cleaner-icon-size};
--cui-time-picker-body-padding: #{$time-picker-body-padding};
--cui-time-picker-footer-border-width: #{$time-picker-footer-border-width};
--cui-time-picker-footer-border-color: #{$time-picker-footer-border-color};
--cui-time-picker-footer-padding: #{$time-picker-footer-padding};
--cui-time-picker-dropdown-bg: #{$time-picker-dropdown-bg};
--cui-time-picker-dropdown-border-width: #{$time-picker-dropdown-border-width};
--cui-time-picker-dropdown-border-color: #{$time-picker-dropdown-border-color};
--cui-time-picker-dropdown-border-radius: #{$time-picker-dropdown-border-radius};
--cui-time-picker-dropdown-box-shadow: #{$time-picker-dropdown-box-shadow};
--cui-time-picker-roll-col-border-width: #{$time-picker-roll-col-border-width};
--cui-time-picker-roll-col-border-color: #{$time-picker-roll-col-border-color};
--cui-time-picker-roll-cell-selected-color: #{$time-picker-roll-cell-selected-color};
--cui-time-picker-roll-cell-selected-bg: #{$time-picker-roll-cell-selected-bg};
--cui-time-picker-inline-select-font-size: #{$time-picker-inline-select-font-size};
--cui-time-picker-inline-select-color: #{$time-picker-inline-select-color};
--cui-time-picker-inline-select-padding-y: #{$time-picker-inline-select-padding-y};
--cui-time-picker-inline-select-padding-x: #{$time-picker-inline-select-padding-x};
--cui-time-picker-inline-select-disabled-color: #{$time-picker-inline-select-disabled-color};
SASS variables
$time-picker-zindex: 1000;
$time-picker-font-family: $input-font-family;
$time-picker-font-size: $input-font-size;
$time-picker-font-size-sm: $input-font-size-sm;
$time-picker-font-size-lg: $input-font-size-lg;
$time-picker-font-weight: $input-font-weight;
$time-picker-line-height: $input-line-height;
$time-picker-color: $input-color;
$time-picker-bg: $input-bg;
$time-picker-box-shadow: $box-shadow-inset;
$time-picker-border-width: $input-border-width;
$time-picker-border-color: $input-border-color;
$time-picker-border-radius: $input-border-radius;
$time-picker-border-radius-sm: $input-border-radius-sm;
$time-picker-border-radius-lg: $input-border-radius-lg;
$time-picker-invalid-border-color: $form-invalid-border-color;
$time-picker-valid-border-color: $form-valid-border-color;
$time-picker-disabled-color: $input-disabled-color;
$time-picker-disabled-bg: $input-disabled-bg;
$time-picker-disabled-border-color: $input-disabled-border-color;
$time-picker-focus-color: $input-focus-color;
$time-picker-focus-bg: $input-focus-bg;
$time-picker-focus-border-color: $input-focus-border-color;
$time-picker-focus-box-shadow: $input-btn-focus-box-shadow;
$time-picker-placeholder-color: var(--#{$prefix}secondary-color);
$time-picker-padding-y: $input-padding-y;
$time-picker-padding-x: $input-padding-x;
$time-picker-gap: $input-padding-x;
$time-picker-padding-y-sm: $input-padding-y-sm;
$time-picker-padding-x-sm: $input-padding-x-sm;
$time-picker-gap-sm: $input-padding-x-sm;
$time-picker-padding-y-lg: $input-padding-y-lg;
$time-picker-padding-x-lg: $input-padding-x-lg;
$time-picker-gap-lg: $input-padding-x-lg;
$time-picker-cleaner-width: 1.25rem;
$time-picker-cleaner-icon-color: var(--#{$prefix}tertiary-color);
$time-picker-cleaner-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' role='img'><polygon fill='#000' points='348.071 141.302 260.308 229.065 172.545 141.302 149.917 163.929 237.681 251.692 149.917 339.456 172.545 362.083 260.308 274.32 348.071 362.083 370.699 339.456 282.935 251.692 370.699 163.929 348.071 141.302'></polygon><path fill='#000' d='M425.706,86.294A240,240,0,0,0,86.294,425.706,240,240,0,0,0,425.706,86.294ZM256,464C141.309,464,48,370.691,48,256S141.309,48,256,48s208,93.309,208,208S370.691,464,256,464Z'></path></svg>");
$time-picker-cleaner-icon-hover-color: var(--#{$prefix}body-color);
$time-picker-cleaner-icon-size: 1rem;
$time-picker-cleaner-icon-size-sm: .875rem;
$time-picker-cleaner-icon-size-lg: 1.25rem;
$time-picker-cleaner-width-sm: 1rem;
$time-picker-cleaner-width-lg: 1.5rem;
$time-picker-cleaner-icon-size-sm: .875rem;
$time-picker-cleaner-icon-size-lg: 1.25rem;
$time-picker-indicator-width: 1.25rem;
$time-picker-indicator-icon-color: var(--#{$prefix}tertiary-color);
$time-picker-indicator-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' role='img'><polygon fill='#000' points='271.514 95.5 239.514 95.5 239.514 273.611 355.127 328.559 368.864 299.657 271.514 253.389 271.514 95.5'></polygon><path fill='#000' d='M256,16C123.452,16,16,123.452,16,256S123.452,496,256,496,496,388.548,496,256,388.548,16,256,16Zm0,448C141.125,464,48,370.875,48,256S141.125,48,256,48s208,93.125,208,208S370.875,464,256,464Z'></path></svg>");
$time-picker-indicator-invalid-icon-color: var(--#{$prefix}form-invalid-color);
$time-picker-indicator-invalid-icon: $time-picker-indicator-icon;
$time-picker-indicator-valid-icon-color: var(--#{$prefix}form-valid-color);
$time-picker-indicator-valid-icon: $time-picker-indicator-icon;
$time-picker-indicator-icon-size: 1rem;
$time-picker-indicator-width-sm: 1rem;
$time-picker-indicator-width-lg: 1.5rem;
$time-picker-indicator-icon-size-sm: .875rem;
$time-picker-indicator-icon-size-lg: 1.25rem;
$time-picker-dropdown-bg: var(--#{$prefix}body-bg);
$time-picker-dropdown-border-color: var(--#{$prefix}border-color);
$time-picker-dropdown-border-width: var(--#{$prefix}border-width);
$time-picker-dropdown-border-radius: var(--#{$prefix}border-radius);
$time-picker-dropdown-box-shadow: var(--#{$prefix}box-shadow);
$time-picker-body-padding: $spacer * .5;
$time-picker-footer-padding: .5rem;
$time-picker-footer-border-width: 1px;
$time-picker-footer-border-color: var(--#{$prefix}border-color);
$time-picker-roll-col-border-width: var(--#{$prefix}border-width);
$time-picker-roll-col-border-color: var(--#{$prefix}border-color);
$time-picker-roll-cell-selected-color: var(--#{$prefix}white);
$time-picker-roll-cell-selected-bg: var(--#{$prefix}primary);
$time-picker-inline-select-font-size: $form-select-font-size-sm;
$time-picker-inline-select-color: $input-color;
$time-picker-inline-select-padding-y: $input-padding-y-sm;
$time-picker-inline-select-padding-x: $input-padding-x-sm;
$time-picker-inline-select-disabled-color: $input-disabled-color;
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4