@@ -174,17 +174,59 @@ By setting the `required` prop, DayPicker ensures that the selected range cannot
174
174
<Examples.RangeRequired />
175
175
</BrowserWindow >
176
176
177
- ## Disabling Dates
177
+ ## Disabling Dates { # disabled }
178
178
179
- To disable specific days, use the ` disabled ` prop. Disabled dates cannot be selected.
179
+ To disable specific days, use the ` disabled ` prop. Disabled days cannot be selected.
180
+
181
+ ### Matchers Types
180
182
181
183
The prop accepts a [ ` Matcher ` ] ( ../api/type-aliases/Matcher.md ) or an array of matchers to specify which days should be disabled.
182
184
183
- ### Disabling Specific Dates
185
+ | Matcher Type | Description |
186
+ | ----------------------------------------------------- | ------------------------------------------------------------------------- |
187
+ | ` boolean ` | Disable all the dates |
188
+ | ` Date ` | Matches a specific date. |
189
+ | ` Date[] ` | Matches any date in the array of dates. |
190
+ | [ ` DateRange ` ] ( ../api/type-aliases/DateRange.md ) | Matches a range of dates, including the start and end dates. |
191
+ | [ ` DateBefore ` ] ( ../api/type-aliases/DateBefore.md ) | Matches all dates before a specific date (exclusive). |
192
+ | [ ` DateAfter ` ] ( ../api/type-aliases/DateAfter.md ) | Matches all dates after a specific date (exclusive). |
193
+ | [ ` DateInterval ` ] ( ../api/type-aliases/DateInterval.md ) | Matches dates between two dates (exclusive of the start and end dates). |
194
+ | [ ` DayOfWeek ` ] ( ../api/type-aliases/DayOfWeek.md ) | Matches specific days of the week (e.g., Sunday is ` 0 ` , Saturday is ` 6 ` ). |
195
+ | ` (date: Date) => boolean ` | A function that returns ` true ` if the given date matches the condition. |
196
+ | [ ` Matcher[] ` ] ( ../api/type-aliases/Matcher.md ) | An array of the matchers listed above. |
197
+
198
+ ``` tsx
199
+ // Disable all days
200
+ <DayPicker disabled />
201
+
202
+ // Disable a day
203
+ <DayPicker disabled = { new Date (2023 , 9 , 1 )} />
204
+
205
+ // Disable an array of days
206
+ <DayPicker disabled = { [new Date (2023 , 9 , 1 ), new Date (2023 , 9 , 2 )]} />
207
+
208
+ // Disable a range of days
209
+ <DayPicker disabled = { { from: new Date (2023 , 9 , 1 ), to: new Date (2023 , 9 , 5 ) }} />
210
+
211
+ // Disable a specific day of the week
212
+ <DayPicker disabled = { { dayOfWeek: [0 , 6 ] }} /> // disable weekends
213
+
214
+ // Disable days before a specific date
215
+ <DayPicker disabled = { { before: new Date (2023 , 9 , 1 ) }} />
216
+
217
+ // Disable days after a specific date
218
+ <DayPicker disabled = { { after: new Date (2023 , 9 , 5 ) }} />
219
+
220
+ // Disable days between two dates
221
+ <DayPicker disabled = { { before: [new Date (2023 , 9 , 1 ), after : new Date (2023 , 9 , 5 )] }} />
222
+ ```
223
+
224
+ ### Disabling Weekends
225
+
226
+ To disable weekends, use the ` dayOfWeek ` matcher, where ` 0 ` is Sunday and ` 6 ` is Saturday.
184
227
185
228
``` tsx
186
- // disable weekends
187
- <DayPicker mode = " range" disabled = { { dayOfWeek: [0 , 6 ] }} />
229
+ <DayPicker disabled = { { dayOfWeek: [0 , 6 ] }} />
188
230
```
189
231
190
232
<BrowserWindow >
@@ -193,6 +235,8 @@ The prop accepts a [`Matcher`](../api/type-aliases/Matcher.md) or an array of ma
193
235
194
236
### Disabling Dates in the Past
195
237
238
+ Use the ` before ` matcher to disable all dates before today.
239
+
196
240
``` tsx
197
241
<DayPicker mode = " single" disabled = { { before: new Date () }} />
198
242
```
0 commit comments