Repository navigation
Docs: Add README for DatePicker and TimePicker Components #70365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ciampo
merged 18 commits into
WordPress:trunk
from
shrivastavanolo:docs/date-time-picker
Apr 14, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0865aba
docs: add readme for DatePicker component
880f337
docs: add readme for TimePicker component
a85eb1f
chore: update manifest.json for docs
96574ed
chore: update changelog
shrivastavanolo e70ffe1
chore: npm run docs:build command
shrivastavanolo 587d085
Update packages/components/src/date-time/time/README.md
shrivastavanolo 9ea4a99
docs: semantic/markup issues
shrivastavanolo 8a02f16
docs: update manifest titles to DatePicker and TimePicker for consist…
shrivastavanolo c0e8cac
chore: run docs build and include generated updates
shrivastavanolo d1e894d
docs: address review feedback for DatePicker and TimePicker README
shrivastavanolo 36cc539
refactor: rename date/time folders to date-picker/time-picker and upd…
shrivastavanolo b381ff2
chore: run docs build and use tabs for indentation in README
shrivastavanolo 33052f9
Update packages/components/src/date-time/time-picker/README.md
shrivastavanolo 77c3654
docs: expand TimePicker.TimeInput docs and align JSDoc with README
shrivastavanolo 26f1711
chore: fix docs build failure
shrivastavanolo e1480a9
Update packages/components/src/date-time/time-picker/README.md
ciampo 986d40b
Update packages/components/src/date-time/time-picker/README.md
ciampo c04de39
Update packages/components/src/date-time/time-picker/README.md
ciampo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # DatePicker | ||
|
|
||
| DatePicker is a React component that renders a calendar for date selection. It can be used independently or as part of the `DateTimePicker` component. | ||
|
|
||
| ## Usage | ||
|
|
||
| Render a DatePicker. | ||
|
|
||
| ```jsx | ||
| import { useState } from 'react'; | ||
| import { DatePicker } from '@wordpress/components'; | ||
|
|
||
| const MyDatePicker = () => { | ||
| const [ date, setDate ] = useState( new Date() ); | ||
|
|
||
| return ( | ||
| <DatePicker | ||
| currentDate={ date } | ||
| onChange={ ( newDate ) => setDate( newDate ) } | ||
| /> | ||
| ); | ||
| }; | ||
| ``` | ||
|
|
||
| ## Props | ||
|
|
||
| The component accepts the following props: | ||
|
|
||
| ### `currentDate`: `Date | string | number | null` | ||
|
|
||
| The current date at initialization. Optionally pass in a `null` value to specify no date is currently selected. | ||
|
|
||
| - Required: No | ||
| - Default: today's date | ||
|
|
||
| ### `onChange`: `( date: string ) => void` | ||
|
|
||
| The function called when a new date has been selected. It is passed the `currentDate` as an argument. | ||
|
|
||
| - Required: No | ||
|
|
||
| ### `events`: `{ date: Date }[]` | ||
|
|
||
| List of events to show in the date picker. Each event will appear as a dot on the day of the event. | ||
|
|
||
| - Required: No | ||
|
|
||
| ### `isInvalidDate`: `( date: Date ) => boolean` | ||
|
|
||
| A callback function which receives a Date object representing a day as an argument, and should return a Boolean to signify if the day is valid or not. | ||
|
|
||
| - Required: No | ||
|
|
||
| ### `onMonthPreviewed`: `( date: string ) => void` | ||
|
|
||
| A callback invoked when selecting the previous/next month in the date picker. The callback receives the new month date in the ISO format as an argument. | ||
|
|
||
| - Required: No | ||
|
|
||
| ### `startOfWeek`: `0 | 1 | 2 | 3 | 4 | 5 | 6` | ||
|
|
||
| The day that the week should start on. 0 for Sunday, 1 for Monday, etc. | ||
|
|
||
| - Required: No | ||
| - Default: 0 | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
packages/components/src/date-time/time-picker/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # TimePicker | ||
|
|
||
| TimePicker is a React component that renders form inputs for time and date selection. It can be used independently or as part of the `DateTimePicker` component. | ||
|
|
||
| **Note:** `TimePicker` also exposes a compound sub-component, `TimePicker.TimeInput`, which can be used independently to render a time input field without the full picker UI. | ||
|
ciampo marked this conversation as resolved.
|
||
|
|
||
| ## Usage | ||
|
|
||
| Render a TimePicker. | ||
|
|
||
| ```jsx | ||
| import { useState } from 'react'; | ||
| import { TimePicker } from '@wordpress/components'; | ||
|
|
||
| const MyTimePicker = () => { | ||
| const [ time, setTime ] = useState( new Date() ); | ||
|
|
||
| return ( | ||
| <TimePicker | ||
| currentTime={ time } | ||
| onChange={ ( newTime ) => setTime( newTime ) } | ||
| is12Hour | ||
| /> | ||
| ); | ||
| }; | ||
| ``` | ||
|
ciampo marked this conversation as resolved.
|
||
|
|
||
| ## Props | ||
|
|
||
| The component accepts the following props: | ||
|
|
||
| ### `currentTime`: `Date | string | number | null` | ||
|
|
||
| The current time at initialization. Optionally pass in a `null` value to specify no time is currently selected. | ||
|
|
||
| - Required: No | ||
| - Default: current time | ||
|
|
||
| ### `onChange`: `( time: string ) => void` | ||
|
|
||
| The function called when a new time has been selected. It is passed the time as an ISO-formatted string. | ||
|
|
||
| - Required: No | ||
|
|
||
| ### `is12Hour`: `boolean` | ||
|
|
||
| Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed. | ||
|
|
||
|
ciampo marked this conversation as resolved.
|
||
| - Required: No | ||
| - Default: false | ||
|
|
||
| ### `dateOrder`: `'dmy' | 'mdy' | 'ymd'` | ||
|
|
||
| The order of day, month, and year. This prop overrides the time format determined by `is12Hour` prop. | ||
|
|
||
| - Required: No | ||
| - Default: `'dmy'` (or `'mdy'` when `is12Hour` is `true`) | ||
|
|
||
| ### `hideLabelFromVision`: `boolean` | ||
|
|
||
| Whether to visually hide field labels while keeping them accessible to screen readers. | ||
|
|
||
| - Required: No | ||
| - Default: false | ||
|
|
||
| ## TimePicker.TimeInput | ||
|
|
||
| A standalone time input component. Values are passed as an object in 24-hour format (`{ hours: number, minutes: number }`). | ||
|
|
||
| ### Usage | ||
|
|
||
| ```jsx | ||
| import { useState } from 'react'; | ||
| import { TimePicker } from '@wordpress/components'; | ||
|
|
||
| const MyTimeInput = () => { | ||
| const [ time, setTime ] = useState( { hours: 13, minutes: 30 } ); | ||
|
|
||
| return ( | ||
| <TimePicker.TimeInput | ||
| value={ time } | ||
| onChange={ setTime } | ||
| label="Time" | ||
| /> | ||
| ); | ||
| }; | ||
|
ciampo marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| ### Props | ||
|
|
||
| #### `value`: `{ hours: number, minutes: number }` | ||
|
|
||
| The time input value in 24-hour format. | ||
|
|
||
| - Required: No | ||
|
|
||
| #### `defaultValue`: `{ hours: number, minutes: number }` | ||
|
|
||
| An optional default value for the control when used in uncontrolled mode. If left `undefined`, the current time will be used. | ||
|
|
||
| - Required: No | ||
|
|
||
| #### `onChange`: `( time: { hours: number, minutes: number } ) => void` | ||
|
|
||
| Called when the time changes. Receives the new value as an object with `hours` and `minutes`. | ||
|
|
||
| - Required: No | ||
|
|
||
| #### `is12Hour`: `boolean` | ||
|
|
||
| Whether to use a 12-hour clock. With a 12-hour clock, an AM/PM widget is displayed. | ||
|
|
||
| - Required: No | ||
|
|
||
| #### `label`: `string` | ||
|
|
||
| The label for the time input. | ||
|
|
||
| - Required: No | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.