Skip to content

docs(material/slide-toggle): Update description and examples for color input description on API page #29334

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

Merged
merged 1 commit into from
Jun 26, 2024
Merged
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
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
Loading