Skip to content

docs(datetime): add showAdjacentDays section #4134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/api/datetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import CustomizingButtonTexts from '@site/static/usage/v8/datetime/buttons/custo
import HighlightedDatesArray from '@site/static/usage/v8/datetime/highlightedDates/array/index.md';
import HighlightedDatesCallback from '@site/static/usage/v8/datetime/highlightedDates/callback/index.md';

import ShowAdjacentDays from '@site/static/usage/v8/datetime/show-adjacent-days/index.md';

import MultipleDateSelection from '@site/static/usage/v8/datetime/multiple/index.md';

import GlobalTheming from '@site/static/usage/v8/datetime/styling/global-theming/index.md';
Expand Down Expand Up @@ -248,6 +250,18 @@ import Wheel from '@site/static/usage/v8/datetime/presentation/wheel/index.md';

<Wheel />

## Show Adjacent Days

If the `showAdjacentDays` property is set to `true`, days from the previous and next month will be displayed in the calendar view to fill any empty spaces at the beginning or end of the month. When a user clicks on an enabled adjacent day, the calendar will smoothly animate to show that month's view.

The calendar view always displays 6 rows when `showAdjacentDays` is enabled, so days from the previous or next month will be shown as needed to fill the grid. For example, even if a month starts on the first day of the week and ends within the fifth row, days from the next month will appear at the end to complete the sixth row.

:::note
This property is only supported when using `presentation="date"` and `preferWheel="false"`.
:::

<ShowAdjacentDays />

## Multiple Date Selection

If the `multiple` property is set to `true`, multiple dates can be selected from the calendar picker. Clicking a selected date will deselect it.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```html
<ion-datetime show-adjacent-days="true"></ion-datetime>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```ts
import { Component } from '@angular/core';
import { IonDatetime } from '@ionic/angular/standalone';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonDatetime],
})
export class ExampleComponent {}
```
27 changes: 27 additions & 0 deletions static/usage/v8/datetime/show-adjacent-days/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Datetime</title>
<link rel="stylesheet" href="../../common.css" />
<script src="../../common.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@8/dist/ionic/ionic.esm.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@8/css/ionic.bundle.css" />
<style>
ion-datetime {
width: 350px;
}
</style>
</head>

<body>
<ion-app>
<ion-content>
<div class="container">
<ion-datetime show-adjacent-days="true"></ion-datetime>
</div>
</ion-content>
</ion-app>
</body>
</html>
25 changes: 25 additions & 0 deletions static/usage/v8/datetime/show-adjacent-days/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Playground from '@site/src/components/global/Playground';

import javascript from './javascript.md';
import react from './react.md';
import vue from './vue.md';

import angular_example_component_html from './angular/example_component_html.md';
import angular_example_component_ts from './angular/example_component_ts.md';

<Playground
version="8"
size="medium"
code={{
javascript,
react,
vue,
angular: {
files: {
'src/app/example.component.html': angular_example_component_html,
'src/app/example.component.ts': angular_example_component_ts,
},
},
}}
src="usage/v8/datetime/show-adjacent-days/demo.html"
/>
3 changes: 3 additions & 0 deletions static/usage/v8/datetime/show-adjacent-days/javascript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```html
<ion-datetime show-adjacent-days="true"></ion-datetime>
```
9 changes: 9 additions & 0 deletions static/usage/v8/datetime/show-adjacent-days/react.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```tsx
import React, { useRef, useEffect } from 'react';
import { IonDatetime } from '@ionic/react';

function Example() {
return <IonDatetime showAdjacentDays={true}></IonDatetime>;
}
export default Example;
```
14 changes: 14 additions & 0 deletions static/usage/v8/datetime/show-adjacent-days/vue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```html
<template>
<ion-datetime show-adjacent-days="true"></ion-datetime>
</template>

<script lang="ts">
import { IonDatetime } from '@ionic/vue';
import { defineComponent } from 'vue';

export default defineComponent({
components: { IonDatetime },
});
</script>
```