diff --git a/docs/en-US/component/switch.md b/docs/en-US/component/switch.md index 61606513ad..829c010b45 100644 --- a/docs/en-US/component/switch.md +++ b/docs/en-US/component/switch.md @@ -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` | — | | 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 diff --git a/packages/components/switch/src/switch.ts b/packages/components/switch/src/switch.ts index 4832f3ae86..a68c3a5593 100644 --- a/packages/components/switch/src/switch.ts +++ b/packages/components/switch/src/switch.ts @@ -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 diff --git a/packages/components/switch/src/switch.vue b/packages/components/switch/src/switch.vue index 82597a5e31..efa3d59021 100644 --- a/packages/components/switch/src/switch.vue +++ b/packages/components/switch/src/switch.vue @@ -8,6 +8,7 @@ role="switch" :aria-checked="checked" :aria-disabled="switchDisabled" + :aria-label="label" :name="name" :true-value="activeValue" :false-value="inactiveValue"