Skip to content

Instantly share code, notes, and snippets.

@Saadnajmi
Created May 19, 2022 18:24
Show Gist options
  • Save Saadnajmi/7f920a8cafb1460d411f1073cff8ef15 to your computer and use it in GitHub Desktop.
Save Saadnajmi/7f920a8cafb1460d411f1073cff8ef15 to your computer and use it in GitHub Desktop.
const ListAccessibilityExamples: React.FunctionComponent = () => {
const [showImage, setShowImage] = React.useState(true);
const [showPresence, setShowPresence] = React.useState(false);
const [showRing, setShowRing] = React.useState(false);
const redSquareStyle: ViewStyle = { width: 20, height: 20, margin: 10, backgroundColor: 'red' };
const cardStyle: ViewStyle = { width: 40, height: 40, margin: 10, backgroundColor: 'white', borderWidth: 1 };
return (
<View>
<Text>Simple List</Text>
{/* Outer View has accessibilityRole "list", and at least one inner view has an AccessibilityLabel */}
<View accessibilityRole={'list'} accessible>
<View accessible accessibilityLabel={'A red box'} style={redSquareStyle} />
<View accessible style={redSquareStyle} />
<View accessible style={redSquareStyle} />
</View>
<Text>List with cards (not accessible), and inner views (acessible)</Text>
{/* Outer View has accessibilityRole "list", and at least one inner view has an AccessibilityLabel */}
<View accessibilityRole={'list'} accessible>
<View style={cardStyle}>
<View accessible accessibilityLabel={'A red box'} style={redSquareStyle} />
</View>
<View style={cardStyle}>
<View accessible accessibilityLabel={'A red box'} style={redSquareStyle} />
</View>
<View style={cardStyle}>
<View accessible accessibilityLabel={'A red box'} style={redSquareStyle} />
</View>
</View>
</View>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment