Skip to content

Commit 15004ba

Browse files
spliffonekfenner
authored andcommitted
docs(display): document display utils
1 parent 0a9fa18 commit 15004ba

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Display
2+
3+
Responsive display utilities for controlling element visibility and layout behavior across breakpoints. Built on CSS [display](https://developer.mozilla.org/en-US/docs/Web/CSS/display) property with mobile-first responsive design and optimized for modern development workflows.
4+
5+
## How it works
6+
7+
Change the value of the display property with our responsive display utility classes. We purposely support only a subset of all possible values for display. Classes can be combined for various effects as you need.
8+
9+
## Notation
10+
11+
Display utility classes that apply to all breakpoints, from `xs` to `xxl`, have no breakpoint abbreviation in them. This is because those classes are applied from `min-width: 0;` and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation.
12+
13+
As such, the classes are named using the format:
14+
15+
- `.d-{value}` for `xs`
16+
- `.d-{breakpoint}-{value}` for `sm`, `md`, `lg`, `xl`, and `xxl`.
17+
18+
Supported display values:
19+
20+
| Class Suffix | CSS Property | Use Case |
21+
|--------------|--------------|-----------|
22+
| `none` | `display: none` | Hide elements completely |
23+
| `block` | `display: block` | Block-level elements |
24+
| `inline` | `display: inline` | Inline elements |
25+
| `inline-block` | `display: inline-block` | Inline with block properties |
26+
| `flex` | `display: flex` | Flexbox containers |
27+
| `inline-flex` | `display: inline-flex` | Inline flexbox containers |
28+
| `grid` | `display: grid` | CSS Grid containers |
29+
| `inline-grid` | `display: inline-grid` | Inline grid containers |
30+
| `table` | `display: table` | Table layout |
31+
| `table-row` | `display: table-row` | Table row elements |
32+
| `table-cell` | `display: table-cell` | Table cell elements |
33+
34+
The media queries affect screen widths with the given breakpoint or larger. For example, `.d-lg-none` sets `display: none;` on `lg`, `xl`, and `xxl` screens.
35+
36+
## Hiding elements
37+
38+
For faster mobile-friendly development, use responsive display classes for showing and hiding elements by device. Avoid creating entirely different versions of the same site, instead hide elements responsively for each screen size.
39+
40+
To hide elements simply use the `.d-none` class or one of the `.d-{sm,md,lg,xl,xxl}-none` classes for any responsive screen variation.
41+
42+
To show an element only on a given interval of screen sizes you can combine one `.d-*-none` class with a `.d-*-*` class, for example `.d-none` `.d-md-block` `.d-xl-none` will hide the element for all screen sizes except on medium and large devices.
43+
44+
| Screen size | Class |
45+
| ----------- | ----- |
46+
| Hidden on all | `.d-none` |
47+
| Hidden only on xs | `.d-none` `.d-sm-block` |
48+
| Hidden only on sm | `.d-sm-none` `.d-md-block` |
49+
| Hidden only on md | `.d-md-none` `.d-lg-block` |
50+
| Hidden only on lg | `.d-lg-none` `.d-xl-block` |
51+
| Hidden only on xl | `.d-xl-none` `.d-xxl-block` |
52+
| Hidden only on xxl | `.d-xxl-none` |
53+
| Visible on all | `.d-block` |
54+
| Visible only on xs | `.d-block` `.d-sm-none` |
55+
| Visible only on sm | `.d-none` `.d-sm-block` `.d-md-none` |
56+
| Visible only on md | `.d-none` `.d-md-block` `.d-lg-none` |
57+
| Visible only on lg | `.d-none` `.d-lg-block` `.d-xl-none` |
58+
| Visible only on xl | `.d-none` `.d-xl-block` `.d-xxl-none` |
59+
| Visible only on xxl | `.d-none` `.d-xxl-block` |
60+
61+
```html
62+
<div class="d-lg-none">hide on lg and wider screens</div>
63+
<div class="d-none d-lg-block">hide on screens smaller than lg</div>
64+
```
65+
66+
## Display in print
67+
68+
Optimize layouts for print media using dedicated print utilities:
69+
70+
- `.d-print-none`
71+
- `.d-print-inline`
72+
- `.d-print-inline-block`
73+
- `.d-print-block`
74+
- `.d-print-grid`
75+
- `.d-print-table`
76+
- `.d-print-table-row`
77+
- `.d-print-table-cell`
78+
- `.d-print-flex`
79+
- `.d-print-inline-flex`
80+
81+
The print and display classes can be combined.
82+
83+
## Examples
84+
85+
<si-docs-component example="display/display" height="300"></si-docs-component>

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ nav:
3535
- Icons: 'fundamentals/icons.md'
3636
- Localization: 'fundamentals/localization.md'
3737
- Styles:
38+
- Display: 'fundamentals/styles/display.md'
3839
- Flex: 'fundamentals/styles/flex.md'
3940
- UX Writing:
4041
- Overview: 'fundamentals/ux-text-style-guide/index.md'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div class="m-5">
2+
<h3>Display inline</h3>
3+
<div class="d-inline p-2 bg-primary">d-inline</div>
4+
<div class="d-inline p-2">d-inline</div>
5+
</div>
6+
<div class="m-5">
7+
<h3>Display block</h3>
8+
<span class="d-block p-2 bg-primary">d-block</span>
9+
<span class="d-block p-2">d-block</span>
10+
</div>
11+
<div class="m-5">
12+
<h3>Display none</h3>
13+
<div class="d-lg-none">hide on lg and wider screens</div>
14+
<div class="d-none d-lg-block">hide on screens smaller than lg</div>
15+
</div>
16+
<div class="m-5">
17+
<h3>Display print</h3>
18+
<div class="d-print-none">Screen Only (Hide on print only)</div>
19+
<div class="d-none d-print-block">Print Only (Hide on screen only)</div>
20+
<div class="d-none d-lg-block d-print-block">
21+
Hide up to large on screen, but always show on print
22+
</div>
23+
</div>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright (c) Siemens 2016 - 2025
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
import { Component } from '@angular/core';
6+
7+
@Component({
8+
selector: 'app-sample',
9+
templateUrl: './display.html'
10+
})
11+
export class SampleComponent {}

0 commit comments

Comments
 (0)