Skip to content
Stylhero 0.6.2
React Native

Theme

Core

Feedback

Inputs

Navigation

Overlays

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

PropTypeDefaultDescription
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-tapPresses it

Accessibility

  • accessibilityLabel is required, since there's no visible text.
  • At least 44×44pt to touch, even at size="sm" (the extra area comes from hitSlop).

Generated from src/components/IconButton.tsx. Something wrong or missing? Open an issue.