Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(material/button): add the ability to interact with disabled butt…
…ons (#28242) Native disabled buttons don't allow focus and prevent the button from dispatching events. In some cases this can be problematic, because it prevents the app from showing to the user why the button is disabled. These changes introduce a new opt-in input that will style buttons as disabled and set `aria-disabled="true"`, but not set the native `disabled` attribute, allowing them to be interactive.
- Loading branch information
Showing
22 changed files
with
399 additions
and
70 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...mples/material/button/button-disabled-interactive/button-disabled-interactive-example.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
button { | ||
margin-right: 8px; | ||
} |
10 changes: 10 additions & 0 deletions
10
...ples/material/button/button-disabled-interactive/button-disabled-interactive-example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<button | ||
mat-raised-button | ||
disabled | ||
disabledInteractive | ||
matTooltip="This is a tooltip!">Disabled button allowing interactivity</button> | ||
|
||
<button | ||
mat-raised-button | ||
disabled | ||
matTooltip="This is a tooltip!">Default disabled button</button> |
15 changes: 15 additions & 0 deletions
15
...amples/material/button/button-disabled-interactive/button-disabled-interactive-example.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {Component} from '@angular/core'; | ||
import {MatButton} from '@angular/material/button'; | ||
import {MatTooltip} from '@angular/material/tooltip'; | ||
|
||
/** | ||
* @title Interactive disabled buttons | ||
*/ | ||
@Component({ | ||
selector: 'button-disabled-interactive-example', | ||
templateUrl: 'button-disabled-interactive-example.html', | ||
styleUrls: ['button-disabled-interactive-example.css'], | ||
standalone: true, | ||
imports: [MatButton, MatTooltip], | ||
}) | ||
export class ButtonDisabledInteractiveExample {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export {ButtonOverviewExample} from './button-overview/button-overview-example'; | ||
export {ButtonTypesExample} from './button-types/button-types-example'; | ||
export {ButtonDisabledInteractiveExample} from './button-disabled-interactive/button-disabled-interactive-example'; | ||
export {ButtonHarnessExample} from './button-harness/button-harness-example'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.