feat(components): [switch] add label attribute for accessibility (#14319)

* feat(components): [switch] add label attribute for accessibility

* refactor(components): [switch] set default switch label to undefined

* docs: version change
This commit is contained in:
Karolis_Stoncius_Sneakybox 2023-10-16 15:08:09 +03:00 committed by GitHub
parent 40b64dfb57
commit 26e9727299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -115,6 +115,7 @@ switch/custom-action-icon
| before-change | before-change hook before the switch state changes. If `false` is returned or a `Promise` is returned and then is rejected, will stop switching | ^[boolean] / ^[Function]`() => Promise<boolean>` | — |
| id | id for input | ^[string] | — |
| tabindex | tabindex for input | ^[string] / ^[number] | — |
| label ^(2.4.1) ^(a11y) | same as `aria-label` in native input | ^[string] | — |
### Events

View File

@ -169,6 +169,13 @@ export const switchProps = buildProps({
type: [Boolean, String, Number],
default: false,
},
/**
* @description native input aria-label
*/
label: {
type: String,
default: undefined,
},
} as const)
export type SwitchProps = ExtractPropTypes<typeof switchProps>

View File

@ -8,6 +8,7 @@
role="switch"
:aria-checked="checked"
:aria-disabled="switchDisabled"
:aria-label="label"
:name="name"
:true-value="activeValue"
:false-value="inactiveValue"