Timepicker
Angular Bootstrap 5 Timepicker component
Use MDB custom Angular Timepicker component to select time.
Note: Read the API tab to find all available options and advanced customization
Basic example
Inline Timepicker with 12h
MDB Timepicker allows you to use a inline version timepicker. Default version is with 12h.
Inline Timepicker with 24h
MDB Timepicker allows you to use a inline version timepicker. You have to add options
format24
to true.
Custom toggle icon
Icon input
You can set your custom toggle icon with [icon]
input.
Icon template
If you want to use more complex toggle icon syntax you can do it by placing HTML code inside
ng-template
with mdbTimepickerToggleIcon
directive.
Default time
MDB Timepicker allows to initialize a default time in the picker.
- 12:34
- 12:34 PM
- 12:34 AM
Format 24h
Timepicker allows you to use time format with 24 hours.
Just Input
You can set a timepicker to just an input.
Increment
You can set a increment value by 5 to a minutes.
Max time
Max time with PM
Max time with AM
Min time
Min time with PM
Min time with AM
Disable past
Use the minTime
input to disallow past time selection.
Disable future
Use the maxTime
input to disallow future time selection.
Validation
Use mdbValidate
directive to enable validation styles and
mdb-error
and mdb-success
components to display validation messages.
Note:
This example uses MDB Angular Validation. Remember to import MdbValidationModule
and ReactiveFormsModule
to enable reactive forms validation in Angular.
Timepicker - API
Import
Inputs
MdbTimepickerComponent
Name | Type | Default | Description |
---|---|---|---|
autoClose |
boolean | false |
Defines whether component should close automatically after minute selection |
disabled |
boolean | false |
Defines whether component is disabled |
format12 |
boolean | true |
Allows to use format 12h |
format24 |
boolean | false |
Allows to use format 24h |
increment |
boolean | false |
Allows to set increment minutes by 5 |
inline |
boolean | false |
Allows to use a inline version of timepicker |
maxTime |
string | - |
Changes max available time |
minTime |
string | - |
Changes min available time |
options |
any | MdbTimepickerOptions |
Defines timepicker's options |
switchHoursToMinutesOnClick |
boolean | true |
Allows to enable/disable switching to minutes if hours are selected |
MdbTimepickerToggleComponent
Name | Type | Default | Description |
---|---|---|---|
disabled |
boolean | false |
Defines whether component is disabled |
icon |
string | 'far fa-clock' |
Allows to set custom icon |
mdbTimepickerToggle |
MdbTimepickerComponent | - |
Input for attaching timepicker component |
Outputs
Name | Type | Description |
---|---|---|
opened
|
EventEmitter<void> | This event fires immediately when the timepicker is opened. |
closed
|
EventEmitter<void> | This event fires immediately when the timepicker is closed. |
timeChange
|
EventEmitter<MdbTimepickerSelectedTime> | This event fires immediately when the new time is selected. |
Methods
Name | Description | Example |
---|---|---|
open |
Manually opens a timepicker |
timepicker.open()
|
close |
Manually closes a timepicker |
timepicker.close()
|
Advanced types
MdbTimepickerOptions
Name | Type | Default | Description |
---|---|---|---|
amLabel
|
string | 'AM' |
Changes AM text |
cancelLabel
|
string | 'Cancel' |
Changes cancel button text |
clearLabel
|
string | 'Clear' |
Changes clear button text |
okLabel
|
string | 'Ok' |
Changes ok button text |
pmLabel
|
string | 'PM' |
Changes PM text |
MdbTimepickerSelectedTime
CSS variables
As part of MDB’s evolving CSS variables approach, timepicker now use local CSS variables for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Timepicker CSS variables are in different classes which belong to this component. To make it easier to use them, you can find below all of the used CSS variables.