Chakra ui typescript 强制图标按钮的 aria-label - 如何关闭

问题描述 投票:0回答:1

所以我有一个 Chakra UI 图标按钮

<IconButton
   aria-label="Left Arrow"

我想删除 aria 标签 - 为什么我要这样做?因为 IconButton 位于树的

aria-hidden
部分内,因此标签是多余的。

但是如果我删除它,我会收到以下打字稿投诉

 ../../node_modules/@chakra-ui/button/dist/icon-button.d.ts:23:5
web:tsc:     23     "aria-label": string;
web:tsc:            ~~~~~~~~~~~~
web:tsc:     '"aria-label"' is declared here.

如何制作脉轮图标按钮而不给它不必要的咏叹调标签。

typescript wai-aria chakra-ui
1个回答
0
投票

出于可访问性目的,

aria-label
是开发人员应该使用的重要属性。根据 ChakraUI 官方文档,
aria-label
是强制性道具,您必须通过它。

文档:https://v2.chakra-ui.com/docs/components/icon-button#usage

© www.soinside.com 2019 - 2024. All rights reserved.