react-day-picker 9.4.0 → 9.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,61 +8,29 @@ DayPicker follows the [ARIA Authoring Practices Guide](https://www.w3.org/WAI/AR
8
8
 
9
9
  Depending on your design, you might need to add more accessibility features. For example, when using [Input Fields](../guides/input-fields), there may be some limitations based on your accessibility goals. Keep up with best practices by following the [ARIA Patterns](https://www.w3.org/WAI/ARIA/apg/patterns/).
10
10
 
11
- ## Accessibility Tips
11
+ :::tip Accessibility Tips
12
12
 
13
13
  - Test your date picker regularly with a screen reader to ensure accessibility.
14
- - Use an `aria-live` region to announce when a date is selected, utilizing the `footer` prop.
14
+ - Use an `aria-live` region to announce when a date is selected, like using the `footer` prop.
15
15
  - Customize ARIA labels with the [`labels`](../api/interfaces/PropsBase.md#labels) prop for better user feedback.
16
- - Ensure the date picker is fully navigable with just the keyboard.
17
- - Provide clear focus indicators for keyboard users.
18
16
  - Maintain sufficient color contrast between text and background.
19
17
  - Offer instructions for first-time users or those unfamiliar with the date picker.
20
18
 
21
- ## Announcing the Selected Date {#footer}
22
-
23
- Here is an example of an accessible date picker with a live region that announces the selected date using the `footer` prop.
24
-
25
- ```tsx title="./AccessibleDatePicker.tsx"
26
- import { format } from "date-fns";
27
- import { DayPicker } from "react-day-picker";
28
-
29
- export function AccessibleDatePicker() {
30
- const [meetingDate, setMeetingDate] = React.useState<Date | undefined>(
31
- undefined
32
- );
33
-
34
- const footer = meetingDate
35
- ? `Meeting date is set to ${format(meetingDate, "PPPP")}`
36
- : "Please pick a date for the meeting.";
37
-
38
- const labels = {
39
- labelCaption: () => "Select a date for the meeting",
40
- labelDay: (date, modifiers) => {
41
- return modifiers.selected
42
- ? `Selected Meeting Date: ${format(date, "PPP")}`
43
- : "";
44
- }
45
- };
46
-
47
- return (
48
- <DayPicker
49
- mode="single"
50
- onSelect={setMeetingDate}
51
- selected={meetingDate}
52
- labels={labels}
53
- footer={footer}
54
- />
55
- );
56
- }
57
- ```
19
+ :::
20
+
21
+ ## Accessibility Props
58
22
 
59
- <BrowserWindow>
60
- <Examples.AccessibleDatePicker />
61
- </BrowserWindow>
23
+ | Prop Name | Type | Description |
24
+ | ------------ | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
+ | `labels` | [`Labels`](../api/type-aliases/Labels.md) | Map of the ARIA labels used within DayPicker for better accessibility. |
26
+ | `footer` | `ReactNode` \| `string` | Add a footer to the calendar, which can act as a [live region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) to announce updates. |
27
+ | `role` | `application` \| `dialog` | Set the ARIA role for the container. Use `application` for a more interactive widget or `dialog` for a modal-like date picker. |
28
+ | `aria-label` | `string` | The label to use for the container when a `role` is set, providing a descriptive text for screen readers. |
29
+ | `autoFocus` | `boolean` | Autofocus the calendar when it opens, improving keyboard navigation. |
62
30
 
63
- ## Autofocusing the Calendar {#autofocus}
31
+ ### Autofocusing the Calendar {#autofocus}
64
32
 
65
- DayPicker manages focus automatically when users interact with the calendar. For better accessibility, you might want to autofocus the calendar when it opens. Use the `autoFocus` prop to achieve this:
33
+ DayPicker automatically manages focus when users interact with the calendar. To enhance accessibility, you can autofocus the calendar when it opens by using the `autoFocus` prop:
66
34
 
67
35
  ```tsx
68
36
  <DayPicker mode="single" autoFocus />