Skip to main content

Date picker

Examples

Check out the Usage section for details about how to design a DatePicker properly, and the different configuration options we provide.

Basic example

You can add an input that allows a user to enter a date either manually or through a calendar modal.

<DatePicker
label="Choose date"
onChange={(event, value) =>
console.log('The date chosen is', value.day, value.month, value.year)
}
/>

Error example

You can use the stateMessages property to display an error on the DatePicker.

<DatePicker
label="Choose date"
stateMessages={{ error: ['This is an error message'] }}
/>

Min/Max example

You can limit the range of dates a user can select.

note

This does not include validation, it only limits the options in a dropdown. A user can manually enter any date.

<DatePicker
label="Choose date"
minDate={{ day: 1, month: 1, year: 2022 }}
maxDate={{ day: 31, month: 12, year: 2023 }}
/>