|
1
|
import { ComponentExample } from "@/components/ComponentExample" |
|
2
|
import { ComponentReference } from "@/components/ComponentReference" |
|
3
|
|
|
4
|
export const metadata = { |
|
5
|
title: `Date Picker`, |
|
6
|
} |
|
7
|
|
|
8
|
# {metadata.title} |
|
9
|
|
|
10
|
A component for rendering date picker inputs with range and presets. |
|
11
|
|
|
12
|
In this guide, you'll learn how to use the Date Picker component. |
|
13
|
|
|
14
|
<ComponentExample name="date-picker-demo" /> |
|
15
|
|
|
16
|
## Usage |
|
17
|
|
|
18
|
```tsx |
|
19
|
import { DatePicker } from "@medusajs/ui" |
|
20
|
``` |
|
21
|
|
|
22
|
```tsx |
|
23
|
<DatePicker /> |
|
24
|
``` |
|
25
|
|
|
26
|
--- |
|
27
|
|
|
28
|
## API Reference |
|
29
|
|
|
30
|
<ComponentReference mainComponent="DatePicker" /> |
|
31
|
|
|
32
|
--- |
|
33
|
|
|
34
|
## Examples |
|
35
|
|
|
36
|
### Controlled Date Picker |
|
37
|
|
|
38
|
Manage and store the value of the date picker in a state variable for controlled behavior. This is also useful for form integration. |
|
39
|
|
|
40
|
<ComponentExample name="date-picker-controlled" /> |
|
41
|
|
|
42
|
### Date Picker With Time |
|
43
|
|
|
44
|
Enable time selection with different granularity levels for precise scheduling. |
|
45
|
|
|
46
|
<ComponentExample name="date-picker-with-time" /> |
|
47
|
|
|
48
|
### Date Picker Min/Max Values |
|
49
|
|
|
50
|
Restrict date selection to a specific range by setting minimum and maximum values. |
|
51
|
|
|
52
|
In the example below, you can only select dates within the next 30 days. Dates outside the range are disabled. |
|
53
|
|
|
54
|
<ComponentExample name="date-picker-min-max" /> |
|
55
|
|
|
56
|
### Date Picker Disabled Dates |
|
57
|
|
|
58
|
Disable specific dates like weekends and holidays to prevent selection of unavailable dates. |
|
59
|
|
|
60
|
The example below disables weekends and holidays like Christmas. |
|
61
|
|
|
62
|
<ComponentExample name="date-picker-business-hours" /> |
|
63
|
|
|
64
|
### Date Picker Granularity Options |
|
65
|
|
|
66
|
Different levels of time precision from date-only to second-precision selection. |
|
67
|
|
|
68
|
<ComponentExample name="date-picker-granularity" /> |
|
69
|
|
|
70
|
### Date Picker Form Integration |
|
71
|
|
|
72
|
The following example shows how to use the date picker in a form, with simulated form submission. |
|
73
|
|
|
74
|
<ComponentExample name="date-picker-form" hideFeedback /> |