Skip to content

Commit a119742

Browse files
authored
Merge pull request #3053 from Akshat55/toggle-aria
fix: allow users to pass in aria-label for toggle button
2 parents 0e072f0 + b36671c commit a119742

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/toggle/toggle.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { I18n } from "carbon-components-angular/i18n";
1212
import { Observable } from "rxjs";
1313

1414
/**
15+
* @deprecated since v5 - Use boolean
1516
* Defines the set of states for a toggle component.
1617
*/
1718
export enum ToggleState {
@@ -50,7 +51,8 @@ export enum ToggleState {
5051
role="switch"
5152
type="button"
5253
[attr.aria-checked]="checked"
53-
(click)="onClick($event)">
54+
(click)="onClick($event)"
55+
[attr.aria-label]="ariaLabel">
5456
</button>
5557
<label
5658
class="cds--toggle__label"
@@ -143,6 +145,11 @@ export class Toggle extends Checkbox {
143145
*/
144146
@Input() hideLabel = false;
145147

148+
/**
149+
* Set `aria-label` property for the button when label is empty
150+
*/
151+
@Input() ariaLabel: string;
152+
146153
@HostBinding("class.cds--toggle--skeleton") @Input() skeleton = false;
147154

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

0 commit comments

Comments
 (0)