Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 0abb71b

Browse files
committed
add example for restricted dates
1 parent 9989400 commit 0abb71b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/components/DateRangePicker/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,34 @@ function customDayContent(day) {
189189
}}
190190
/>;
191191
```
192+
193+
194+
#### Example: Restrict Date Selection
195+
196+
```jsx inside Markdown
197+
import { addDays } from 'date-fns';
198+
import { useState } from 'react';
199+
200+
const [state, setState] = useState({
201+
selection: {
202+
startDate: new Date(),
203+
endDate: null,
204+
key: 'selection'
205+
},
206+
compare: {
207+
startDate: new Date(),
208+
endDate: addDays(new Date(), 3),
209+
key: 'compare'
210+
}
211+
});
212+
213+
<DateRangePicker
214+
onChange={item => setState({ ...state, ...item })}
215+
months={1}
216+
minDate={addDays(new Date(), -30)}
217+
maxDate={addDays(new Date(), 30)}
218+
direction="vertical"
219+
scroll={{ enabled: true }}
220+
ranges={[state.selection, state.compare]}
221+
/>;
222+
```

0 commit comments

Comments
 (0)