Is this correct? I'm afraid it will read the word 'switch' twice to the user.
<Switch
accessible={true}
accessibilityLabel="Switch button"
accessibilityHint="Double tap to toggle setting"
accessibilityRole="switch"
/>
Many thanks in advance.
A couple notes on accessibility here:
accessible=true
)accessible
parameter. It will bundle any child elements into one accessible component and a screen reader will not allow users to select individual components when true. (You may need to override the default behavior because of this.)To answer your question:
You are correct that this setup would read out "switch button" twice, followed by the hint.
I tested the <Switch>
component on an iPad just now with VoiceOver. By default, it is accessible and reads with a role of "button". Giving it a parameter of accessibilityRole='switch'
reads with a role of "switch button" and automatically includes the "Double tap to toggle setting." hint.
The following component will read to the user as, "Airplane mode. switch button ... Double tap to toggle setting."
<Switch
accessibilityLabel="Airplane mode."
accessibilityRole="switch"
/>