@@ -367,6 +367,85 @@ $my-palette: mat.define-palette(mat.$indigo-palette);
367
367
}
368
368
```
369
369
370
+ ## Strong focus indicators
371
+
372
+ By default, most components indicate browser focus by changing their background color as described
373
+ by the Material Design specification. This behavior, however, can fall short of accessibility
374
+ requirements, such as [ WCAG] [ ] , which require a stronger indication of browser focus.
375
+
376
+ Angular Material supports rendering highly visible outlines on focused elements. Applications can
377
+ enable these strong focus indicators via two Sass mixins:
378
+ ` strong-focus-indicators ` and ` strong-focus-indicators-theme ` .
379
+
380
+ The ` strong-focus-indicators ` mixin emits structal indicator styles for all components. This mixin
381
+ should be included exactly once in an application, similar to the ` core ` mixin described above.
382
+
383
+ The ` strong-focus-indicators-theme ` mixin emits only the indicator's color styles. This mixin should
384
+ be included once per theme, similar to the theme mixins described above. Additionally, you can use
385
+ this mixin to change the color of the focus indicators in situations in which the default color
386
+ would not contrast sufficiently with the background color.
387
+
388
+ The following example includes strong focus indicator styles in an application alongside the rest of
389
+ the custom theme API.
390
+
391
+ ``` scss
392
+ @use ' ~@angular/material' as mat ;
393
+
394
+ @include mat .core ();
395
+ @include mat .strong-focus-indicators ();
396
+
397
+ $my-primary : mat .define-palette (mat .$indigo-palette , 500 );
398
+ $my-accent : mat .define-palette (mat .$pink-palette , A200 , A100 , A400 );
399
+
400
+ $my-theme : mat .define-light-theme ((
401
+ color : (
402
+ primary: $my-primary ,
403
+ accent: $my-accent ,
404
+ )
405
+ ));
406
+
407
+ @include mat .all-component-themes ($my-theme );
408
+ @include mat .strong-focus-indicators-theme ($my-theme );
409
+ ```
410
+
411
+ ### Customizing strong focus indicators
412
+
413
+ You can pass a configuration map to ` strong-focus-indicators ` to customize the appearance of the
414
+ indicators. This configuration includes ` border-style ` , ` border-width ` , and ` border-radius ` .
415
+
416
+ You also can customize the color of indicators with ` strong-focus-indicators-theme ` . This mixin
417
+ accepts either a theme, as described earlier in this guide, or a CSS color value. When providing a
418
+ theme, the indicators will use the default hue of the primary palette.
419
+
420
+ The following example includes strong focus indicator styles with custom settings alongside the rest
421
+ of the custom theme API.
422
+
423
+ ``` scss
424
+ @use ' ~@angular/material' as mat ;
425
+
426
+ @include mat .core ();
427
+ @include mat .strong-focus-indicators ((
428
+ border-style : dotted ,
429
+ border-width : 4px ,
430
+ border-radius : 2px ,
431
+ ));
432
+
433
+ $my-primary : mat .define-palette (mat .$indigo-palette , 500 );
434
+ $my-accent : mat .define-palette (mat .$pink-palette , A200 , A100 , A400 );
435
+
436
+ $my-theme : mat .define-light-theme ((
437
+ color : (
438
+ primary: $my-primary ,
439
+ accent: $my-accent ,
440
+ )
441
+ ));
442
+
443
+ @include mat .all-component-themes ($my-theme );
444
+ @include mat .strong-focus-indicators-theme (purple );
445
+ ```
446
+
447
+ [ WCAG ] : https://www.w3.org/WAI/standards-guidelines/wcag/glance/
448
+
370
449
## Theming and style encapsulation
371
450
372
451
Angular Material assumes that, by default, all theme styles are loaded as global CSS. If you want
0 commit comments