You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/datetime.md
+16-5
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ import HighlightedDatesCallback from '@site/static/usage/v7/datetime/highlighted
37
37
import MultipleDateSelection from '@site/static/usage/v7/datetime/multiple/index.md';
38
38
39
39
import GlobalTheming from '@site/static/usage/v7/datetime/styling/global-theming/index.md';
40
+
import CalendarDaysStyling from '@site/static/usage/v7/datetime/styling/calendar-days/index.md';
40
41
import WheelStyling from '@site/static/usage/v7/datetime/styling/wheel-styling/index.md';
41
42
42
43
<head>
@@ -50,7 +51,7 @@ import EncapsulationPill from '@components/page/api/EncapsulationPill';
50
51
51
52
Datetimes present a calendar interface and time wheel, making it easy for users to select dates and times. Datetimes are similar to the native `input` elements of `datetime-local`, however, Ionic Framework's Datetime component makes it easy to display the date and time in the preferred format, and manage the datetime values.
52
53
53
-
## Overview
54
+
## Overview
54
55
55
56
Historically, handling datetime values within JavaScript, or even within HTML
56
57
inputs, has always been a challenge. Specifically, JavaScript's `Date` object is
@@ -100,15 +101,15 @@ If you need to present a datetime in an overlay such as a modal or a popover, we
100
101
101
102
## Setting Values Asynchronously
102
103
103
-
If its `value` is updated programmatically after a datetime has already been created, the datetime will automatically jump to the new date. However, it is recommended to avoid updating the `value` in this way when users are able to interact with the datetime, as this could be disorienting for those currently trying to select a date. For example, if a datetime's `value` is loaded by an asyncronous process, it is recommended to hide the datetime with CSS until the value has finished updating.
104
+
If its `value` is updated programmatically after a datetime has already been created, the datetime will automatically jump to the new date. However, it is recommended to avoid updating the `value` in this way when users are able to interact with the datetime, as this could be disorienting for those currently trying to select a date. For example, if a datetime's `value` is loaded by an asynchronous process, it is recommended to hide the datetime with CSS until the value has finished updating.
104
105
105
106
## Date Constraints
106
107
107
108
### Max and Min Dates
108
109
109
110
To customize the minimum and maximum datetime values, the `min` and `max` component properties can be provided which may make more sense for the app's use-case. Following the same IS0 8601 format listed in the table above, each component can restrict which dates can be selected by the user.
110
111
111
-
The following example restricts date selection to March 2022 through May 2022 only.
112
+
The following example restricts date selection to March 2022 through May 2022 only.
112
113
113
114
<MaxMin />
114
115
@@ -122,7 +123,7 @@ The following example allows minutes to be selected in increments of 15. It also
122
123
123
124
### Advanced Date Constraints
124
125
125
-
With the `isDateEnabled` property, developers can customize the `ion-datetime` to disable a specific day, range of dates, weekends or any custom rule using an ISO 8601 date string.
126
+
With the `isDateEnabled` property, developers can customize the `ion-datetime` to disable a specific day, range of dates, weekends or any custom rule using an ISO 8601 date string.
126
127
The `isDateEnabled` property accepts a function returning a boolean, indicating if a date is enabled. The function is called for each rendered calendar day, for the previous, current and next month. Custom implementations should be optimized for performance to avoid jank.
127
128
128
129
The following example shows how to disable all weekend dates. For more advanced date manipulation, we recommend using a date utility such as `date-fns`.
@@ -325,6 +326,16 @@ The benefit of this approach is that every component, not just `ion-datetime`, c
325
326
326
327
<GlobalTheming />
327
328
329
+
### Calendar Days
330
+
331
+
The calendar days in a grid-style `ion-datetime` can be styled using CSS shadow parts.
332
+
333
+
:::note
334
+
The example below selects the day 2 days ago, unless that day is in the previous month, then it selects a day 2 days in the future. This is done for demo purposes in order to show how to apply custom styling to all days, the current day, and the selected day.
335
+
:::
336
+
337
+
<CalendarDaysStyling />
338
+
328
339
### Wheel Pickers
329
340
330
341
The wheels used in `ion-datetime` can be styled through a combination of shadow parts and CSS variables. This applies to both the columns in wheel-style datetimes, and the month/year picker in grid-style datetimes.
@@ -367,7 +378,7 @@ import { format, parseISO } from 'date-fns';
0 commit comments