Skip to content

Commit 71e57ed

Browse files
docs(theming): add section about safe area padding (#3065)
1 parent 13b92d8 commit 71e57ed

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

docs/theming/advanced.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,29 @@ However, because CSS variables can be set at runtime and are more dynamic, it is
180180
This is normally not a problem, but when an application needs to have dynamic theming it presents issues. In Ionic, this is the reason that there are [variations to each color](colors.md#layered-colors), and it is also why [stepped colors](themes.md#stepped-colors) are necessary for theming.
181181

182182
There are drafts and issues discussing [color modification proposals](https://github.com/w3c/csswg-drafts/issues/3187) that would make this possible.
183+
184+
## Safe Area Padding
185+
186+
The safe area of a display is the section that is not covered by the device's notch, status bar, or other elements that are part of the device's UI and not the app's. The dimensions of the safe area are different across devices and orientations (portrait or landscape).
187+
188+
For example, below are screenshots of an iPhone 14 Pro Max. The red section is the safe area, and the white sections are places where the app's content would be covered up.
189+
190+
| Portrait | Landscape |
191+
| ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
192+
| <img src={require('@site/static/img/theming/ios-portrait-top.png').default} /> | <img src={require('@site/static/img/theming/ios-landscape-left.png').default} /> |
193+
194+
To accommodate this, Ionic automatically adds padding to certain components. For example, the first `ion-toolbar` component placed in an `ion-modal` will receive padding according to the top edge of the device's safe area. This avoids the device's notch covering up the header text.
195+
196+
<img src={require('@site/static/img/theming/modal-header-padding.png').default} />
197+
198+
This padding can be manually adjusted through CSS using the `--ion-safe-area-(dir)` variables described in [Application Variables](#application-variables). Values can be set for the whole application, or on a per component basis. For example:
199+
200+
```css
201+
html {
202+
--ion-safe-area-left: 25px;
203+
}
204+
205+
ion-modal {
206+
--ion-safe-area-top: 0;
207+
}
208+
```
22.4 KB
Loading
25.8 KB
Loading
13.8 KB
Loading

0 commit comments

Comments
 (0)