Skip to content

Commit 6c9ddf1

Browse files
committed
docs(icon): Add docs for inline icon.
1 parent c205749 commit 6c9ddf1

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/demo-app/icon/icon-demo.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@
3939
<mat-icon fontSet="fontawesome" fontIcon="fa-birthday-cake"></mat-icon>
4040
</p>
4141

42+
<span>Inline styling allows icons to appear as the same size as text around them.</span>
4243
<p>
43-
Inline styling <mat-icon inline="true">favorite</mat-icon> icons appear as
44-
the same <mat-icon inline="true">directions_car</mat-icon>size as text around them.</p>
44+
My <span class="cdk-visually-hidden">dog</span><mat-icon inline="true">pets</mat-icon> is my
45+
<span class="cdk-visually-hidden">favorite</span><mat-icon inline="true">favorite</mat-icon>,
46+
he loves to go on <span class="cdk-visually-hidden">walks</span>
47+
<mat-icon inline="true">directions_walk</mat-icon>
48+
</p>
4549
</div>

src/lib/icon/icon.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ In thinking about accessibility, it is useful to place icon use into one of thre
9090
1. **Decorative**: the icon conveys no real semantic meaning and is purely cosmetic.
9191
2. **Interactive**: a user will click or otherwise interact with the icon to perform some action.
9292
3. **Indicator**: the icon is not interactive, but it conveys some information, such as a status.
93-
93+
4. **Inline**: the icon is not interactive and is inlined into a block of text to convey
94+
information.
9495
### Bidirectionality
9596

9697
By default icons in an RTL layout will look exactly the same as in LTR, however certain icons have
@@ -103,21 +104,20 @@ you want to mirror an icon only in an RTL layout, you can use the `mat-icon-rtl-
103104

104105
#### Decorative icons
105106
When the icon is puely cosmetic and conveys no real semantic meaning, the `<mat-icon>` element
106-
should be marked with `aria-hidden="true"`.
107+
is marked with `aria-hidden="true"`.
107108

108109
#### Interactive icons
109110
Icons alone are not interactive elements for screen-reader users; when the user would interact with
110111
some icon on the page, a more appropriate element should "own" the interaction:
111112
* The `<mat-icon>` element should be a child of a `<button>` or `<a>` element.
112-
* The `<mat-icon>` element should be marked with `aria-hidden="true"`.
113113
* The parent `<button>` or `<a>` should either have a meaningful label provided either through
114114
direct text content, `aria-label`, or `aria-labelledby`.
115115

116-
#### Indicator icons
117-
When the presence of an icon communicates some information to the user, that information must also
118-
be made available to screen-readers. The most straightforward way to do this is to
119-
1. Mark the `<mat-icon>` as `aria-hidden="true"`
120-
2. Add a `<span>` as an adjacent sibling to the `<mat-icon>` element with text that conveys the same
116+
#### Indicator icons/Inline icons
117+
When the presence of an icon communicates some information to the user whether as an indicator or
118+
by being inlined into a block of text, that information must also be made available to
119+
screen-readers. The most straightforward way to do this is to
120+
1. Add a `<span>` as an adjacent sibling to the `<mat-icon>` element with text that conveys the same
121121
information as the icon.
122-
3. Add the `cdk-visually-hidden` class to the `<span>`. This will make the message invisible
122+
2. Add the `cdk-visually-hidden` class to the `<span>`. This will make the message invisible
123123
on-screen but still available to screen-reader users.

0 commit comments

Comments
 (0)