Skip to content

Commit

Permalink
docs(material/slide-toggle): Update description and examples for colo…
Browse files Browse the repository at this point in the history
…r input description on API page (#29334)

(cherry picked from commit caeb3e8)
  • Loading branch information
amysorto committed Jun 26, 2024
1 parent ac9e524 commit 0a4712c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
<mat-card>
<mat-card-content>
<h2 class="example-h2">Slider configuration</h2>

<section class="example-section">
<label class="example-margin">Color:</label>
<mat-radio-group [(ngModel)]="color">
<mat-radio-button class="example-margin" value="primary">
Primary
</mat-radio-button>
<mat-radio-button class="example-margin" value="accent">
Accent
</mat-radio-button>
<mat-radio-button class="example-margin" value="warn">
Warn
</mat-radio-button>
</mat-radio-group>
</section>
<h2 class="example-h2">Slide toggle configuration</h2>

<section class="example-section">
<mat-checkbox class="example-margin" [(ngModel)]="checked">Checked</mat-checkbox>
Expand All @@ -34,7 +19,6 @@ <h2 class="example-h2">Result</h2>
<section class="example-section">
<mat-slide-toggle
class="example-margin"
[color]="color"
[checked]="checked"
[disabled]="disabled">
Slide me!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Component} from '@angular/core';
import {ThemePalette} from '@angular/material/core';
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {FormsModule} from '@angular/forms';
Expand All @@ -17,7 +16,6 @@ import {MatCardModule} from '@angular/material/card';
imports: [MatCardModule, MatRadioModule, FormsModule, MatCheckboxModule, MatSlideToggleModule],
})
export class SlideToggleConfigurableExample {
color: ThemePalette = 'accent';
checked = false;
disabled = false;
}
8 changes: 7 additions & 1 deletion src/material/slide-toggle/slide-toggle-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ export interface MatSlideToggleDefaultOptions {
/** Whether toggle action triggers value changes in slide toggle. */
disableToggleValue?: boolean;

/** Default color for slide toggles. */
/**
* Default theme color of the slide toggle. This API is supported in M2 themes only,
* it has no effect in M3 themes.
*
* For information on applying color variants in M3, see
* https://material.angular.io/guide/theming#using-component-color-variants.
*/
color?: ThemePalette;

/** Whether to hide the icon inside the slide toggle. */
Expand Down
4 changes: 0 additions & 4 deletions src/material/slide-toggle/slide-toggle.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ specify an appropriate label.
`<mat-slide-toggle>` is compatible with `@angular/forms` and supports both `FormsModule`
and `ReactiveFormsModule`.

### Theming
The color of a `<mat-slide-toggle>` can be changed by using the `color` property. By default,
slide-toggles use the theme's accent color. This can be changed to `'primary'` or `'warn'`.

### Accessibility

`MatSlideToggle` uses an internal `<button role="switch">` to provide an accessible experience. This
Expand Down

0 comments on commit 0a4712c

Please sign in to comment.