Skip to content

Commit

Permalink
Merge pull request #3053 from Akshat55/toggle-aria
Browse files Browse the repository at this point in the history
fix: allow users to pass in aria-label for toggle button
  • Loading branch information
zvonimirfras authored Nov 12, 2024
2 parents 0e072f0 + b36671c commit a119742
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/toggle/toggle.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { I18n } from "carbon-components-angular/i18n";
import { Observable } from "rxjs";

/**
* @deprecated since v5 - Use boolean
* Defines the set of states for a toggle component.
*/
export enum ToggleState {
Expand Down Expand Up @@ -50,7 +51,8 @@ export enum ToggleState {
role="switch"
type="button"
[attr.aria-checked]="checked"
(click)="onClick($event)">
(click)="onClick($event)"
[attr.aria-label]="ariaLabel">
</button>
<label
class="cds--toggle__label"
Expand Down Expand Up @@ -143,6 +145,11 @@ export class Toggle extends Checkbox {
*/
@Input() hideLabel = false;

/**
* Set `aria-label` property for the button when label is empty
*/
@Input() ariaLabel: string;

@HostBinding("class.cds--toggle--skeleton") @Input() skeleton = false;

@HostBinding("class.cds--toggle") toggleClass = true;
Expand Down

0 comments on commit a119742

Please sign in to comment.