|
| 1 | +# DatePicker |
| 2 | + |
| 3 | +<p class="description">Learn about the datepicker component and its usage in Toolpad.</p> |
| 4 | + |
| 5 | +## Demo |
| 6 | + |
| 7 | +DatePicker is an input component. It takes user input and provides the value for further usage on the page. |
| 8 | + |
| 9 | +{{"demo": "DatePicker.js", "hideToolbar": true}} |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +Below props makes it usable: |
| 14 | + |
| 15 | +### format |
| 16 | + |
| 17 | +The [format](https://day.js.org/docs/en/display/format) of the date in the UI. The value for the bindings will always be in the YYYY-MM-DD format. Leave empty to let the end-user locale define the format. |
| 18 | + |
| 19 | +{{"demo": "DatePickerFormat.js", "hideToolbar": true}} |
| 20 | + |
| 21 | +### value |
| 22 | + |
| 23 | +The current selected date. It shows the format in which it is being provided to the page: YYYY-MM-DD. |
| 24 | + |
| 25 | +### defaultValue |
| 26 | + |
| 27 | +Allows setting a default value. Example: |
| 28 | + |
| 29 | +<video controls width="100%" height="auto" style="contain" alt="button-onclick-js-expression"> |
| 30 | + <source src="/static/toolpad/docs/components/datepicker/datepicker-defaultValue.mp4" type="video/mp4"> |
| 31 | + Your browser does not support the video tag. |
| 32 | +</video> |
| 33 | + |
| 34 | +### name |
| 35 | + |
| 36 | +A name is needed when a textfield is part of a form component. It is used to show validation errors. |
| 37 | + |
| 38 | +## Appearance |
| 39 | + |
| 40 | +The DatePicker component supports below mentioned appearance related props in Toolpad: |
| 41 | + |
| 42 | +### label |
| 43 | + |
| 44 | +A label that describes the content of the datepicker e.g. Enter date. |
| 45 | + |
| 46 | +### variant |
| 47 | + |
| 48 | +The variant property supports three different options: outlined (default), filled, and standard. Outlined is for low-emphasis while Filled is a high-emphasis input. Standard is used for less-pronounced actions that ensure user remains focused on the main content. |
| 49 | + |
| 50 | +{{"demo": "DatePickerVariant.js", "hideToolbar": true}} |
| 51 | + |
| 52 | +### size |
| 53 | + |
| 54 | +The size property supports two options: small (default) and medium. |
| 55 | + |
| 56 | +{{"demo": "DatePickerSize.js", "hideToolbar": true}} |
| 57 | + |
| 58 | +### fullWidth |
| 59 | + |
| 60 | +This boolean defines if the component should take the full width of the page. |
| 61 | + |
| 62 | +### disabled |
| 63 | + |
| 64 | +Disabled property shows the state of the component so that end user is aware that can't interact with the component. |
| 65 | + |
| 66 | +{{"demo": "DatePickerDisabled.js", "hideToolbar": true}} |
| 67 | + |
| 68 | +## Validation |
| 69 | + |
| 70 | +### isRequired |
| 71 | + |
| 72 | +isRequired is useful when the action can't be perfomed without a user provided date. |
| 73 | + |
| 74 | +<video controls width="100%" height="auto" style="contain" alt="button-onclick-js-expression"> |
| 75 | + <source src="/static/toolpad/docs/components/datepicker/datepicker-validation.mp4" type="video/mp4"> |
| 76 | + Your browser does not support the video tag. |
| 77 | +</video> |
| 78 | + |
| 79 | +## API |
| 80 | + |
| 81 | +See the documentation below for a complete reference to all props available to the datepicker component in Toolpad. |
| 82 | + |
| 83 | +- [`<datepicker />`](/toolpad/reference/components/date-picker/#properties) |
0 commit comments