Skip to content
Open
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
52 changes: 38 additions & 14 deletions docs/api/modal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ import CardExample from '@site/static/usage/v9/modal/card/basic/index.mdx';

:::info

[Content](./content) should be used inside of the sheet modal if you want your modal content to be scrollable.
[Content](./content.mdx) should be used inside of the sheet modal if you want your modal content to be scrollable.

:::

Expand Down Expand Up @@ -175,34 +175,58 @@ import SheetScrollingContentExample from '@site/static/usage/v9/modal/sheet/expa

<SheetScrollingContentExample />

## Styling
## Theming

@brandyscarney brandyscarney Sep 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reorganizing the sections into Theming -> Styling to match other components, see: https://ionicframework.com/docs/api/action-sheet#theming

I considered updating the playground directory structure but moving any would break the JP docs.


Modals are presented at the root of your application so they overlay your entire app. This behavior applies to both inline modals and modals presented from a controller. As a result, custom modal styles can not be scoped to a particular component as they will not apply to the modal. Instead, styles must be applied globally. For most developers, placing the custom styles in `global.css` is sufficient.
[Controller modals](#controller-modals) are appended to the root of your application, outside of the component that presented them. Component-scoped styles will not reach these modals, so their styles must be applied globally, from a stylesheet that is not scoped to a component.

:::note
[Inline modals](#inline-modals-recommended) stay where they are declared in your template, so component-scoped styles do apply to them.
Comment on lines +180 to +182

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can revert this if desired - but I don't know why inline modals were specified here as needing to be overridden globally. We can target ion-modal directly from the example component.


If you are building an Ionic Angular app, the styles need to be added to a global stylesheet file. Read [Style Placement](#style-placement) in the Angular section below for more information.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Style Placement section has been removed since v6 so I deleted this entire note: 997fe9e

### Styling

:::
Modals expose [CSS Custom Properties](#css-custom-properties) and [CSS Shadow Parts](#css-shadow-parts) for customizing their appearance.

:::note
import ThemeExample from '@site/static/usage/v9/modal/styling/theming/index.mdx';

`ion-modal` works under the assumption that stacked modals are the same size. As a result, each subsequent modal will have no box shadow and a backdrop opacity of `0`. This is to avoid the effect of shadows and backdrops getting darker with each added modal. This can be changed by setting the `--box-shadow` and `--backdrop-opacity` CSS variables:
<ThemeExample />

:::
### Stacked Modals

```
`ion-modal` works under the assumption that stacked modals are the same size. As a result, each subsequent modal will have no box shadow and a backdrop opacity of `0`. This is to avoid the effect of shadows and backdrops getting darker with each added modal. This can be changed by setting the `--box-shadow` and `--backdrop-opacity` CSS variables:

```css
ion-modal.stack-modal {
--box-shadow: 0 28px 48px rgba(0, 0, 0, 0.4);
--backdrop-opacity: var(--ion-backdrop-opacity, 0.32);
}
```

import ThemeExample from '@site/static/usage/v9/modal/styling/theming/index.mdx';
### Sizing to Content

<ThemeExample />
A modal fills the height of its container by default. Setting the `--height` CSS variable to `auto`, `fit-content`, `min-content`, or `max-content` sizes the modal to the height of what it renders instead.

:::warning

The height must be set on the modal through the `--height` CSS variable. Setting `height` on the `content` [CSS Shadow Part](#css-shadow-parts) will still resize the modal, but any [Content](./content.mdx) inside of it will collapse to a height of `0`, leaving only the header visible.

```css
/* DO NOT DO THIS */
ion-modal::part(content) {
height: fit-content;
}

/* Do this instead */
ion-modal {
--height: fit-content;
}
```

:::

import SizingToContentExample from '@site/static/usage/v9/modal/styling/sizing-to-content/index.mdx';

<SizingToContentExample />

### Animations
## Animations

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I promoted Animations out of Theming because it doesn't actually change any styles.


The enter and leave animations can be customized by using our animation builder and assigning animations to `enterAnimation` and `leaveAnimation`.

Expand All @@ -220,7 +244,7 @@ import CustomDialogs from '@site/static/usage/v9/modal/custom-dialogs/index.mdx'

A few things to keep in mind when creating custom dialogs:

- `ion-content` is intended to be used in full-page modals, cards, and sheets. If your custom dialog has a dynamic or unknown size, `ion-content` should not be used.
- `ion-content` can be used in a custom dialog, including one that is sized to its contents. The dialog's height must come from the `--height` CSS variable rather than from the dialog's children. See [Sizing to Content](#sizing-to-content).
- Creating custom dialogs provides a way of ejecting from the default modal experience. As a result, custom dialogs should not be used with card or sheet modals.

## Event Handling
Expand Down
14 changes: 7 additions & 7 deletions static/code/stackblitz/v9/angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/code/stackblitz/v9/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"@angular/platform-browser": "^22.0.0",
"@angular/platform-browser-dynamic": "^22.0.0",
"@angular/router": "^22.0.0",
"@ionic/angular": "9.0.1",
"@ionic/core": "9.0.1",
"@ionic/angular": "9.0.1-dev.11788212611.154b1596",
"@ionic/core": "9.0.1-dev.11788212611.154b1596",
"ionicons": "8.1.0",
"rxjs": "^7.8.1",
"tslib": "^2.5.0"
Expand Down
6 changes: 3 additions & 3 deletions static/code/stackblitz/v9/html/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/code/stackblitz/v9/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "vite preview"
},
"dependencies": {
"@ionic/core": "9.0.1",
"@ionic/core": "9.0.1-dev.11788212611.154b1596",
"ionicons": "8.1.0"
},
"devDependencies": {
Expand Down
20 changes: 10 additions & 10 deletions static/code/stackblitz/v9/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/code/stackblitz/v9/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@ionic/react": "9.0.1",
"@ionic/react-router": "9.0.1",
"@ionic/react": "9.0.1-dev.11788212611.154b1596",
"@ionic/react-router": "9.0.1-dev.11788212611.154b1596",
"@types/node": "^24.0.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
Expand Down
20 changes: 10 additions & 10 deletions static/code/stackblitz/v9/vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/code/stackblitz/v9/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"preview": "vite preview"
},
"dependencies": {
"@ionic/vue": "9.0.1",
"@ionic/vue-router": "9.0.1",
"@ionic/vue": "9.0.1-dev.11788212611.154b1596",
"@ionic/vue-router": "9.0.1-dev.11788212611.154b1596",
"vue": "^3.2.25",
"vue-router": "5.3.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```css
ion-modal {
--height: fit-content;
--width: 90%;
--border-radius: 8px;
--box-shadow: 0 28px 48px rgba(0, 0, 0, 0.4);
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
```html
<ion-header>
<ion-toolbar>
<ion-title>App</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<ion-button id="open-modal" expand="block">Open Modal</ion-button>

<ion-modal #modal trigger="open-modal">
<ng-template>
<ion-header>
<ion-toolbar>
<ion-title>Modal</ion-title>
<ion-buttons slot="end">
<ion-button (click)="modal.dismiss()">Close</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list lines="full">
@for (item of ['Item 1', 'Item 2', 'Item 3']; track item) {
<ion-item>
<ion-label>{{ item }}</ion-label>
</ion-item>
}
</ion-list>
</ion-content>
</ng-template>
</ion-modal>
</ion-content>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```ts
import { Component } from '@angular/core';
import {
IonButton,
IonButtons,
IonContent,
IonHeader,
IonItem,
IonLabel,
IonList,
IonModal,
IonTitle,
IonToolbar,
} from '@ionic/angular';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonButton, IonButtons, IonContent, IonHeader, IonItem, IonLabel, IonList, IonModal, IonTitle, IonToolbar],
})
export class ExampleComponent {}
```
Loading