Skip to content

Commit 54b8d40

Browse files
committed
main - 6ce27af docs: add strong focus indicator instructions to m3 guide (#32177)
1 parent b1db1b5 commit 54b8d40

2 files changed

Lines changed: 71 additions & 8 deletions

File tree

docs-content/guides/theming.md.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,69 @@ <h3 id="direct-style-overrides" class="docs-header-link">
411411
change at any time. CSS variables used by the Angular Material components should
412412
be defined through the <code>overrides</code> API instead of defined explicitly.</p>
413413

414+
<h2 id="strong-focus-indicators" class="docs-header-link">
415+
<span header-link="strong-focus-indicators"></span>
416+
Strong focus indicators
417+
</h2>
418+
<p>By default, most components indicate browser focus by changing their background color as described
419+
by the Material Design specification. This behavior, however, can fall short of accessibility
420+
requirements, such as [WCAG 4.5:1][], which require a stronger indication of browser focus.</p>
421+
<p>Angular Material supports rendering highly visible outlines on focused elements. Applications can
422+
enable these strong focus indicators via two Sass mixins:
423+
<code>strong-focus-indicators</code> and <code>strong-focus-indicators-theme</code>.</p>
424+
<p>The <code>strong-focus-indicators</code> mixin emits structural indicator styles for all components. This mixin
425+
should be included exactly once in an application, similar to the <code>core</code> mixin described above.</p>
426+
<p>The <code>strong-focus-indicators-theme</code> mixin emits only the indicator&#39;s color styles. This mixin should
427+
be included once per theme, similar to the theme mixins described above. Additionally, you can use
428+
this mixin to change the color of the focus indicators in situations in which the default color
429+
would not contrast sufficiently with the background color.</p>
430+
<p>The following example includes strong focus indicator styles in an application alongside the rest of
431+
the custom theme API.</p>
432+
<pre><code class="language-scss"><span class="hljs-keyword">@use</span> <span class="hljs-string">&#x27;@angular/material&#x27;</span> as mat;
433+
434+
<span class="hljs-variable">$my-theme</span>: (
435+
color: mat.<span class="hljs-variable">$violet-palette</span>,
436+
typography: Roboto,
437+
density: <span class="hljs-number">0</span>
438+
);
439+
440+
<span class="hljs-keyword">@include</span> mat.strong-focus-indicators();
441+
442+
<span class="hljs-selector-tag">html</span> {
443+
<span class="hljs-attribute">color-scheme</span>: light dark;
444+
<span class="hljs-keyword">@include</span> mat.theme(<span class="hljs-variable">$my-theme</span>);
445+
<span class="hljs-keyword">@include</span> mat.strong-focus-indicators-theme(<span class="hljs-variable">$my-theme</span>);
446+
}</code></pre>
447+
<h3 id="customizing-strong-focus-indicators" class="docs-header-link">
448+
<span header-link="customizing-strong-focus-indicators"></span>
449+
Customizing strong focus indicators
450+
</h3>
451+
<p>You can pass a configuration map to <code>strong-focus-indicators</code> to customize the appearance of the
452+
indicators. This configuration includes <code>border-style</code>, <code>border-width</code>, and <code>border-radius</code>.</p>
453+
<p>You also can customize the color of indicators with <code>strong-focus-indicators-theme</code>. This mixin
454+
accepts either a theme, as described earlier in this guide, or a CSS color value. When providing a
455+
theme, the indicators will use the default hue of the primary palette.</p>
456+
<p>The following example includes strong focus indicator styles with custom settings alongside the rest
457+
of the custom theme API.</p>
458+
<pre><code class="language-scss"><span class="hljs-keyword">@use</span> <span class="hljs-string">&#x27;@angular/material&#x27;</span> as mat;
459+
460+
<span class="hljs-keyword">@include</span> mat.strong-focus-indicators((
461+
<span class="hljs-attribute">border-style</span>: dotted,
462+
<span class="hljs-attribute">border-width</span>: <span class="hljs-number">4px</span>,
463+
<span class="hljs-attribute">border-radius</span>: <span class="hljs-number">2px</span>,
464+
));
465+
466+
<span class="hljs-selector-tag">html</span> {
467+
<span class="hljs-attribute">color-scheme</span>: light dark;
468+
469+
<span class="hljs-keyword">@include</span> mat.theme((
470+
<span class="hljs-attribute">color</span>: mat.<span class="hljs-variable">$rose-palette</span>,
471+
<span class="hljs-attribute">typography</span>: Roboto,
472+
<span class="hljs-attribute">density</span>: <span class="hljs-number">0</span>
473+
));
474+
475+
<span class="hljs-keyword">@include</span> mat.strong-focus-indicators-theme(orange);
476+
}</code></pre>
414477
<h2 id="shadow-dom" class="docs-header-link">
415478
<span header-link="shadow-dom"></span>
416479
Shadow DOM

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/components-examples",
3-
"version": "21.1.0-next.0+sha-022dba9",
3+
"version": "21.1.0-next.0+sha-6ce27af",
44
"description": "Angular Components Examples",
55
"private": true,
66
"repository": {
@@ -287,15 +287,15 @@
287287
},
288288
"homepage": "https://github.com/angular/components#readme",
289289
"peerDependencies": {
290-
"@angular/aria": "21.1.0-next.0+sha-022dba9",
291-
"@angular/cdk": "21.1.0-next.0+sha-022dba9",
292-
"@angular/cdk-experimental": "21.1.0-next.0+sha-022dba9",
290+
"@angular/aria": "21.1.0-next.0+sha-6ce27af",
291+
"@angular/cdk": "21.1.0-next.0+sha-6ce27af",
292+
"@angular/cdk-experimental": "21.1.0-next.0+sha-6ce27af",
293293
"@angular/core": "^21.0.0-0 || ^21.1.0-0 || ^21.2.0-0 || ^21.3.0-0 || ^22.0.0-0",
294294
"@angular/common": "^21.0.0-0 || ^21.1.0-0 || ^21.2.0-0 || ^21.3.0-0 || ^22.0.0-0",
295-
"@angular/material": "21.1.0-next.0+sha-022dba9",
296-
"@angular/material-experimental": "21.1.0-next.0+sha-022dba9",
297-
"@angular/material-luxon-adapter": "21.1.0-next.0+sha-022dba9",
298-
"@angular/material-date-fns-adapter": "21.1.0-next.0+sha-022dba9"
295+
"@angular/material": "21.1.0-next.0+sha-6ce27af",
296+
"@angular/material-experimental": "21.1.0-next.0+sha-6ce27af",
297+
"@angular/material-luxon-adapter": "21.1.0-next.0+sha-6ce27af",
298+
"@angular/material-date-fns-adapter": "21.1.0-next.0+sha-6ce27af"
299299
},
300300
"devDependencies": {
301301
"@angular/aria": "workspace:*",

0 commit comments

Comments
 (0)