Skip to content

Commit 6b07acb

Browse files
Splaktarwagnermaciel
authored andcommitted
docs(material/slider): apply a11y guidance (#22494)
- update configurable example to - have useful labels and use `aria-labelledby` - have labels that work in horizontal and vertical modes - add `aria-label` to other examples - add `step` to formatting example Fixes #7933 (cherry picked from commit a0a77d7)
1 parent 91f6ebe commit 6b07acb

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

src/components-examples/material/slider/slider-configurable/slider-configurable-example.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,23 @@
2828
.example-result-card h2 {
2929
margin: 0 8px;
3030
}
31+
32+
.example-result-card .example-label-container.example-label-horizontal {
33+
display: flex;
34+
justify-content: space-between;
35+
margin: 0 0 12px 16px;
36+
max-width: 284px;
37+
}
38+
39+
.example-result-card .example-label-container.example-label-vertical {
40+
display: flex;
41+
flex-direction: column;
42+
align-items: center;
43+
justify-content: space-between;
44+
max-width: 68px;
45+
height: 48px;
46+
}
47+
48+
.example-result-card .example-value-label {
49+
font-weight: 600;
50+
}

src/components-examples/material/slider/slider-configurable/slider-configurable-example.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ <h2 class="example-h2">Slider configuration</h2>
5151
<mat-card class="example-result-card">
5252
<mat-card-content>
5353
<h2>Result</h2>
54+
<br>
55+
<br>
5456

57+
<div class="example-label-container" [class]="vertical ? 'example-label-vertical' : 'example-label-horizontal'">
58+
<label id="example-name-label" class="example-name-label">Max Value</label>
59+
<label class="example-value-label">{{value}}</label>
60+
</div>
5561
<mat-slider
5662
class="example-margin"
5763
[disabled]="disabled"
@@ -62,7 +68,8 @@ <h2>Result</h2>
6268
[thumbLabel]="thumbLabel"
6369
[tickInterval]="getSliderTickInterval()"
6470
[(ngModel)]="value"
65-
[vertical]="vertical">
71+
[vertical]="vertical"
72+
aria-labelledby="example-name-label">
6673
</mat-slider>
6774
</mat-card-content>
6875
</mat-card>

src/components-examples/material/slider/slider-formatting/slider-formatting-example.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
thumbLabel
33
[displayWith]="formatLabel"
44
tickInterval="1000"
5-
min="1"
6-
max="100000"></mat-slider>
5+
step="1000"
6+
min="0"
7+
max="100000"
8+
aria-label="units"></mat-slider>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<mat-slider value="50"></mat-slider>
1+
<mat-slider value="50" aria-label="unit(s)"></mat-slider>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<mat-slider></mat-slider>
1+
<mat-slider aria-label="unit(s)"></mat-slider>

0 commit comments

Comments
 (0)