DateTimepicker
Bootstrap 5 DateTimepicker
DateTimepicker is a form that adds the function of selecting date and time.
Note: Read the API tab to find all available options and advanced customization
Basic example
Input with a modal for selecting a date and time.
Inline version
You can use inline version with inline
prop.
Disabled
Use disabled
property on DateTimepicker to give it a grayed out appearance and remove pointer events.
Default values
You can set default date and time with options datepickerOptions
and
timepickerOptions
.
Invalid label
Add invalidLabel
with specified value, to change the invalid label
message.
Input toggle
Add inputToggle
prop to the input element to enable toggling on
input click.
Custom date and time options
Use datepickerOptions
or timepickerOptions
props to set custom options from our
Datepicker and Timepicker components.
Datepicker options
Timepicker options
DateTimepicker - API
Import
Properties
MDBDateTimepicker
Name | Type | Default | Description | Example |
---|---|---|---|---|
appendValidationInfo
|
boolean | true |
Adds validation info to the bottom of input. |
<MDBDateTimepicker appendValidationInfo={false} />
|
datepickerOptions
|
{ [key: string]: any } |
|
Sets custom options for our MDBDatepicker component. |
<MDBDateTimepicker datepickerOptions={{ format: 'dd-mm-yyyy' }} />
|
disabled
|
boolean | false |
Set a disabled attribute to input in wrapper. |
<MDBDateTimepicker disabled />
|
inline
|
boolean | false |
Allows to use a inline version of datetimepicker. |
<MDBDateTimepicker inline />
|
inputToggle
|
boolean | false |
Enable toggling MDBDateTimepicker on input click. |
<MDBDateTimepicker inputToggle />
|
invalidLabel
|
string |
|
Allows to set the value of invalid label. |
<MDBDateTimepicker invalidLabel='Correct your inputs!' />
|
value
|
string |
|
Enables controlling datetimepicker's input value |
<MDBDateTimepicker invalidLabel='Correct your inputs!' />
|
label
|
string | 'Select Date and Time' |
Defines a label text for the input |
<MDBDateTimepicker label='Date and time' />
|
labelClass
|
string |
|
Adds custom classes to the label |
<MDBDateTimepicker labelClass='custom-class' />
|
labelRef
|
React.RefObject |
|
Reference to label element |
<MDBDateTimepicker labelRef={myRef} />
|
labelStyle
|
React.CSSProperties |
|
Adds custom styles to the label |
<MDBDateTimepicker labelStyle={{ color: 'red' }} />
|
showFormat
|
boolean | false |
Adds placeholder with current format of MDBDateTimepicker |
<MDBDateTimepicker showFormat />
|
timepickerOptions
|
{ [key: string]: any } |
|
Sets custom options for our MDBTimepicker component. |
<MDBDateTimepicker timepickerOptions={{ format: '24h' }} />
|
Events
Name | Type | Description |
---|---|---|
onChange
|
() => any | Fires when the new input value changes. |
onClose
|
() => void | Fires when the datetimepicker is closed. |
onTimepickerClose
|
() => void | Fires when the Timepicker is closed. |
onDatepickerClose
|
() => void | Fires when the Datepicker is closed. |
onOpen
|
() => void | Fires when the datetimepicker is opened. |
onTimepickerOpen
|
() => void | Fires when the Timepicker is opened. |
onDatepickerOpen
|
() => void | Fires when the Datepicker is opened. |