React Native / Core
IconButton
Square button holding only an icon. Always at least 44pt to touch.
import { IconButton } from "@stylhero/native";
Example
import { IconButton, Text } from "@stylhero/native";
const noop = () => {};
function IconButtonExample() {
return (
<IconButton accessibilityLabel="Close" onPress={noop}>
<Text>✕</Text>
</IconButton>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
accessibilityLabel required |
string |
- | Required: an icon has no visible text, so screen readers need this. |
children required |
ReactNode |
- | |
ref |
Ref<ComponentRef<typeof View>> |
- | |
size |
"sm" | "md" |
"md" |
|
style |
StyleProp<ViewStyle> |
- | |
variant |
"ghost" | "secondary" |
"ghost" |
Also takes React Native's Pressable props (testID, accessibilityHint, onLayout…), passed to that Pressable.
Screen reader gestures
| Gesture (VoiceOver / TalkBack) | Does |
|---|---|
| Double-tap | Presses it |
Accessibility
accessibilityLabelis required, since there's no visible text.- At least 44×44pt to touch, even at
size="sm"(the extra area comes fromhitSlop).
Generated from src/components/IconButton.tsx. Something wrong or missing? Open an issue.