[英]When to use accessibilityRole='link' in ReactNative?
I have an application with drawer navigation that uses buttons to navigate to different screens.我有一个带有抽屉导航的应用程序,它使用按钮导航到不同的屏幕。 In terms of accessibility, should I use
accessibilityRole='button'
or accessibilityRole='link'
for the buttons.?在可访问性方面,我应该为按钮使用
accessibilityRole='button'
还是accessibilityRole='link'
?
React Native AccessibilityRole docs sayReact Native AccessibilityRole文档说
link Used when the element should be treated as a link.
link 当元素应被视为链接时使用。
For external links accessibilityRole='link'
is clearly the best option.对于外部链接
accessibilityRole='link'
显然是最佳选择。 But should I use it for internal navigation, too?但是我也应该将它用于内部导航吗?
Note: I do not use deep links in my application.注意:我没有在我的应用程序中使用深层链接。
Thank you for your help.谢谢您的帮助。
renders a component that can navigate to a screen on press.
呈现一个可以在按下时导航到屏幕的组件。
The Button component is a component that performs a certain action if the user presses it. Button 组件是在用户按下时执行特定操作的组件。 A
Button
could be considered a Link
if its onPress
function navigates to a screen, by definition of the Link
component.根据
Link
组件的定义,如果Button
的onPress
function 导航到屏幕,则可以将其视为Link
。 The Link
could be styled to look exactly like a Button
and vice versa. Link
的样式可以看起来与Button
完全一样,反之亦然。 There would be no difference.没有区别。
If we refer to general URL linking which includes deep linking
, then we notice that the link functionality needs a UI component as well in order to function. This could be Markdown, the Link component or again the Button.如果我们参考一般的 URL 链接,其中包括
deep linking
,那么我们注意到链接功能也需要一个 UI 组件才能到 function。这可能是 Markdown,链接组件或按钮。
I personally would use accessibilityRole='button'
for every UI component that is the actual Button
component or functions (and 'looks') like a button in my application ( TouchableOpacity
, Pressable
, ...), since this is what a user whose disability prevents him from noticing needs to know or wants to visualize.我个人会为每个 UI 组件使用
accessibilityRole='button'
作为实际Button
组件或功能(和'外观')就像我的应用程序中的按钮( TouchableOpacity
, Pressable
,......),因为这是用户的残疾使他无法注意到需要知道或想要形象化。 This includes the Drawer buttons
.这包括
Drawer buttons
。
I would use accessibilityRole='link'
for text which is styled too look like a link (text with some highlighting) and navigates somewhere (this could be a website as well).我会将
accessibilityRole='link'
用于样式太像链接(带有一些突出显示的文本)并在某处导航(这也可能是网站)的文本。
In general, I would keep in mind that the user wants to visualize the component.一般来说,我会记住用户想要可视化组件。 While a button, that navigates to a screen, is technically a link by definition of its functionality, it is not a 'typical link' when speaking of visual appereance (but again, we could style our button exactly like that...).
虽然导航到屏幕的按钮根据其功能的定义在技术上是一个链接,但在谈到视觉外观时它不是“典型链接”(但同样,我们可以像那样设计我们的按钮......)。
What is generally more important is the accessibilityHint which通常更重要的是accessibilityHint哪个
helps users understand what will happen when they perform an action on the accessibility element when that result is not clear from the accessibility label.
帮助用户了解当他们对可访问性元素执行操作时会发生什么,而结果从可访问性 label 中看不清楚。
The 'what will happen if I click' is certainly more important than 'what the component looks like'. “如果我点击会发生什么”肯定比“组件看起来像什么”更重要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.