1e41f4b71Sopenharmony_ci# Calendar Picker Dialog Box (CalendarPickerDialog)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciA calendar picker dialog box is a dialog box that allows users to select a date from a calendar picker.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> This component is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> The functionality of this module depends on UI context. This means that the APIs of this module cannot be used where the UI context is unclear. For details, see [UIContext](../js-apis-arkui-UIContext.md#uicontext).
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## CalendarPickerDialog.show
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_cistatic show(options?: CalendarDialogOptions)
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ciShows a calendar picker dialog box.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**Parameters**
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| Name | Type                                                   | Mandatory| Description                      |
24e41f4b71Sopenharmony_ci| ------- | ------------------------------------------------------- | ---- | -------------------------- |
25e41f4b71Sopenharmony_ci| options | [CalendarDialogOptions](#calendardialogoptions) | No  | Parameters of the calendar picker dialog box.|
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci## CalendarDialogOptions
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ciInherited from [CalendarOptions](ts-basic-components-calendarpicker.md#calendaroptions).
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci| Name      | Type                                           | Mandatory| Description                                                       |
34e41f4b71Sopenharmony_ci| ---------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
35e41f4b71Sopenharmony_ci| onAccept   | (value: Date) => void                           | No  | Triggered when the OK button in the dialog box is clicked.<br>**value**: selected date value<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
36e41f4b71Sopenharmony_ci| onCancel   | () => void                                      | No  | Triggered when the Cancel button in the dialog box is clicked.<br>**Atomic service API**: This API can be used in atomic services since API version 11.                        |
37e41f4b71Sopenharmony_ci| onChange   | (value: Date) => void                           | No  | Triggered when the selection in the picker changes the selected date.<br>**value**: selected date value<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
38e41f4b71Sopenharmony_ci| backgroundColor<sup>11+</sup> | [ResourceColor](ts-types.md#resourcecolor)  | No| Backplane color of the dialog box.<br>Default value: **Color.Transparent**<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
39e41f4b71Sopenharmony_ci| backgroundBlurStyle<sup>11+</sup> | [BlurStyle](ts-universal-attributes-background.md#blurstyle9) | No| Background blur style of the dialog box.<br>Default value: **BlurStyle.COMPONENT_ULTRA_THICK**<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
40e41f4b71Sopenharmony_ci| acceptButtonStyle<sup>12+</sup> | [PickerDialogButtonStyle](ts-methods-datepicker-dialog.md#pickerdialogbuttonstyle12) | No| Style of the accept button.<br>**NOTE**<br>In the **acceptButtonStyle** and **cancelButtonStyle** configurations, only one **primary** field can be set to **true** at most. If both the **primary** fields are set to **true**, neither will take effect.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
41e41f4b71Sopenharmony_ci| cancelButtonStyle<sup>12+</sup> | [PickerDialogButtonStyle](ts-methods-datepicker-dialog.md#pickerdialogbuttonstyle12) | No| Style of the cancel button.<br>**NOTE**<br>In the **acceptButtonStyle** and **cancelButtonStyle** configurations, only one **primary** field can be set to **true** at most. If both the **primary** fields are set to **true**, neither will take effect.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
42e41f4b71Sopenharmony_ci| onDidAppear<sup>12+</sup> | () => void | No| Event callback when the dialog box appears.<br>**NOTE**<br>1. The normal timing sequence is as follows: onWillAppear > onDidAppear > (onAccept/onCancel/onChange) > onWillDisappear > onDidDisappear.<br>2. You can set the callback event for changing the dialog box display effect in **onDidAppear**. The settings take effect next time the dialog box appears.<br>3. If the user dismisses the dialog box immediately after it appears, **onWillDisappear** is invoked before **onDidAppear**.<br>4. If the dialog box is dismissed before its entrance animation is finished, this callback is not invoked.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
43e41f4b71Sopenharmony_ci| onDidDisappear<sup>12+</sup> | () => void | No| Event callback when the dialog box disappears.<br>**NOTE**<br>1. The normal timing sequence is as follows: onWillAppear > onDidAppear > (onAccept/onCancel/onChange) > onWillDisappear > onDidDisappear.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
44e41f4b71Sopenharmony_ci| onWillAppear<sup>12+</sup> | () => void | No| Event callback when the dialog box is about to appear.<br>**NOTE**<br>1. The normal timing sequence is as follows: onWillAppear > onDidAppear > (onAccept/onCancel/onChange) > onWillDisappear > onDidDisappear.<br>2. You can set the callback event for changing the dialog box display effect in **onWillAppear**. The settings take effect next time the dialog box appears.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
45e41f4b71Sopenharmony_ci| onWillDisappear<sup>12+</sup> | () => void | No| Event callback when the dialog box is about to disappear.<br>**NOTE**<br>1. The normal timing sequence is as follows: onWillAppear > onDidAppear > (onAccept/onCancel/onChange) > onWillDisappear > onDidDisappear.<br>2. If the user closes the dialog box immediately after it appears, **onWillDisappear** is invoked before **onDidAppear**.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
46e41f4b71Sopenharmony_ci| shadow<sup>12+</sup>              | [ShadowOptions](ts-universal-attributes-image-effect.md#shadowoptions) \| [ShadowStyle](ts-universal-attributes-image-effect.md#shadowstyle10) | No  | Shadow of the dialog box.<br> Default value on 2-in-1 devices: **ShadowStyle.OUTER_FLOATING_MD** when the dialog box is focused and **ShadowStyle.OUTER_FLOATING_SM** otherwise<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci## Example
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci### Example 1
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ciThis example shows the basic usage of **CalendarPickerDialog**.
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci```ts
55e41f4b71Sopenharmony_ci// xxx.ets
56e41f4b71Sopenharmony_ci@Entry
57e41f4b71Sopenharmony_ci@Component
58e41f4b71Sopenharmony_cistruct CalendarPickerDialogExample {
59e41f4b71Sopenharmony_ci  private selectedDate: Date = new Date('2024-04-23')
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci  build() {
62e41f4b71Sopenharmony_ci    Column() {
63e41f4b71Sopenharmony_ci      Button("Show CalendarPicker Dialog")
64e41f4b71Sopenharmony_ci        .margin(20)
65e41f4b71Sopenharmony_ci        .onClick(() => {
66e41f4b71Sopenharmony_ci          console.info("CalendarDialog.show")
67e41f4b71Sopenharmony_ci          CalendarPickerDialog.show({
68e41f4b71Sopenharmony_ci            selected: this.selectedDate,
69e41f4b71Sopenharmony_ci            onAccept: (value) => {
70e41f4b71Sopenharmony_ci              console.info("calendar onAccept:" + JSON.stringify(value))
71e41f4b71Sopenharmony_ci            },
72e41f4b71Sopenharmony_ci            onCancel: () => {
73e41f4b71Sopenharmony_ci              console.info("calendar onCancel")
74e41f4b71Sopenharmony_ci            },
75e41f4b71Sopenharmony_ci            onChange: (value) => {
76e41f4b71Sopenharmony_ci              console.info("calendar onChange:" + JSON.stringify(value))
77e41f4b71Sopenharmony_ci            },
78e41f4b71Sopenharmony_ci            onDidAppear: () => {
79e41f4b71Sopenharmony_ci              console.info("calendar onDidAppear")
80e41f4b71Sopenharmony_ci            },
81e41f4b71Sopenharmony_ci            onDidDisappear: () => {
82e41f4b71Sopenharmony_ci              console.info("calendar onDidDisappear")
83e41f4b71Sopenharmony_ci            },
84e41f4b71Sopenharmony_ci            onWillAppear: () => {
85e41f4b71Sopenharmony_ci              console.info("calendar onWillAppear")
86e41f4b71Sopenharmony_ci            },
87e41f4b71Sopenharmony_ci            onWillDisappear: () => {
88e41f4b71Sopenharmony_ci              console.info("calendar onWillDisappear")
89e41f4b71Sopenharmony_ci            }
90e41f4b71Sopenharmony_ci          })
91e41f4b71Sopenharmony_ci        })
92e41f4b71Sopenharmony_ci    }.width('100%')
93e41f4b71Sopenharmony_ci  }
94e41f4b71Sopenharmony_ci}
95e41f4b71Sopenharmony_ci```
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci![CalendarPickerDialog](figures/CalendarPickerDialog.gif)
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci### Example 2
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ciThis example shows how to customize the button style.
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci```ts
104e41f4b71Sopenharmony_ci// xxx.ets
105e41f4b71Sopenharmony_ci@Entry
106e41f4b71Sopenharmony_ci@Component
107e41f4b71Sopenharmony_cistruct CalendarPickerDialogExample {
108e41f4b71Sopenharmony_ci  private selectedDate: Date = new Date()
109e41f4b71Sopenharmony_ci  build() {
110e41f4b71Sopenharmony_ci    Column() {
111e41f4b71Sopenharmony_ci      Button("Show CalendarPicker Dialog")
112e41f4b71Sopenharmony_ci        .margin(20)
113e41f4b71Sopenharmony_ci        .onClick(() => {
114e41f4b71Sopenharmony_ci          console.info("CalendarDialog.show")
115e41f4b71Sopenharmony_ci          CalendarPickerDialog.show({
116e41f4b71Sopenharmony_ci            selected: this.selectedDate,
117e41f4b71Sopenharmony_ci            acceptButtonStyle: { type: ButtonType.Normal, style: ButtonStyleMode.NORMAL, role: ButtonRole.NORMAL, fontColor: Color.Red,
118e41f4b71Sopenharmony_ci              fontSize: '26fp', fontWeight: FontWeight.Bolder, fontStyle: FontStyle.Normal, fontFamily: 'sans-serif', backgroundColor:'#80834511',
119e41f4b71Sopenharmony_ci              borderRadius: 20 },
120e41f4b71Sopenharmony_ci            cancelButtonStyle: { type: ButtonType.Normal, style: ButtonStyleMode.NORMAL, role: ButtonRole.NORMAL, fontColor: Color.Blue,
121e41f4b71Sopenharmony_ci              fontSize: '16fp', fontWeight: FontWeight.Normal, fontStyle: FontStyle.Italic, fontFamily: 'sans-serif', backgroundColor:'#50182431',
122e41f4b71Sopenharmony_ci              borderRadius: 10 },
123e41f4b71Sopenharmony_ci            onAccept: (value) => {
124e41f4b71Sopenharmony_ci              console.info("calendar onAccept:" + JSON.stringify(value))
125e41f4b71Sopenharmony_ci            },
126e41f4b71Sopenharmony_ci            onCancel: () => {
127e41f4b71Sopenharmony_ci              console.info("calendar onCancel")
128e41f4b71Sopenharmony_ci            },
129e41f4b71Sopenharmony_ci            onChange: (value) => {
130e41f4b71Sopenharmony_ci              console.info("calendar onChange:" + JSON.stringify(value))
131e41f4b71Sopenharmony_ci            },
132e41f4b71Sopenharmony_ci            onDidAppear: () => {
133e41f4b71Sopenharmony_ci              console.info("calendar onDidAppear")
134e41f4b71Sopenharmony_ci            },
135e41f4b71Sopenharmony_ci            onDidDisappear: () => {
136e41f4b71Sopenharmony_ci              console.info("calendar onDidDisappear")
137e41f4b71Sopenharmony_ci            },
138e41f4b71Sopenharmony_ci            onWillAppear: () => {
139e41f4b71Sopenharmony_ci              console.info("calendar onWillAppear")
140e41f4b71Sopenharmony_ci            },
141e41f4b71Sopenharmony_ci            onWillDisappear: () => {
142e41f4b71Sopenharmony_ci              console.info("calendar onWillDisappear")
143e41f4b71Sopenharmony_ci            }
144e41f4b71Sopenharmony_ci          })
145e41f4b71Sopenharmony_ci        })
146e41f4b71Sopenharmony_ci    }.width('100%')
147e41f4b71Sopenharmony_ci  }
148e41f4b71Sopenharmony_ci}
149e41f4b71Sopenharmony_ci```
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci![CalendarPickerDialog](figures/CalendarPickerDialog_CustomButton.png)
152