Skip to content

docs(focus indicators): Add documentation for focus indicators. #18724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions guides/theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,34 @@ function changeTheme(themeName) {
### Theming your own components
For more details about theming your own components,
see [theming-your-components.md](./theming-your-components.md).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention the mat-focus-indicator class somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a sentence & example towards the end, let me know if you had something else in mind.

### Showing strong focus indicators
Angular Material has built-in support for showing **strong focus indicators** on all components.
These focus indicators render as highly visible outlines around elements.

<!-- example(focus-indicators-overview) -->

Strong focus indicators are off by default. To turn them on, include these mixins:

```scss
@import '@angular/material/core/focus-indicator/focus-indicator';

// Including this mixin will enable strong focus indicators for your app.
// This mixin should only be included once in your app.
@include mat-strong-focus-indicators();

// Choose a color for the focus indicators.
$color: mat-color(mat-palette($mat-deep-purple));

// Including this mixin will theme the focus indicators.
// This mixin can be included multiple times throughout your app
// to change the focus indicator's color.
@include mat-strong-focus-indicators-theme($color);
```

You can also use the class `.mat-focus-indicator` to add focus indicators to your own components.

```html
<!-- Adding a focus indicator to a custom, non-Material button. -->
<div role="button" tabindex="0" class="mat-focus-indicator">My custom button</div>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<button mat-button>Click me</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '../material/core/focus-indicator/focus-indicator';

// Including this mixin will enable strong focus indicators for your app.
// This mixin should only be included once in your app.
@include mat-strong-focus-indicators();

// Choose a color for the focus indicators.
$color: mat-color(mat-palette($mat-deep-purple));

// Including this mixin will theme the focus indicators.
// This mixin can be included multiple times throughout your app
// to change the focus indicator's color.
@include mat-strong-focus-indicators-theme($color);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Component} from '@angular/core';

/**
* @title Focus indicators overview.
*/
@Component({
selector: 'focus-indicators-overview-example',
styleUrls: ['focus-indicators-overview-example.css'],
templateUrl: 'focus-indicators-overview-example.html',
})
export class FocusIndicatorsOverviewExample {
}
3 changes: 3 additions & 0 deletions src/components-examples/material/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatRippleModule} from '@angular/material/core';
import {MatInputModule} from '@angular/material/input';
import {ElevationOverviewExample} from './elevation-overview/elevation-overview-example';
import {FocusIndicatorsOverviewExample} from './focus-indicators-overview/focus-indicators-overview-example';
import {RippleOverviewExample} from './ripple-overview/ripple-overview-example';

export {
ElevationOverviewExample,
FocusIndicatorsOverviewExample,
RippleOverviewExample,
};

const EXAMPLES = [
ElevationOverviewExample,
FocusIndicatorsOverviewExample,
RippleOverviewExample,
];

Expand Down