React Native / Core
Button
Pressable with a text label: primary for the main action on a screen, secondary, ghost, or danger for destructive ones. Always at least 44×44pt to touch, and the label wraps at large text sizes.
import { Button } from "@stylhero/native";
Example
import { useState } from "react";
import { Button, Stack } from "@stylhero/native";
const noop = () => {};
function ButtonExample() {
const [saving, setSaving] = useState(false);
return (
<Stack gap={3}>
<Button loading={saving} onPress={() => setSaving(true)}>Save build</Button>
<Button variant="secondary" onPress={noop}>Compare</Button>
<Button variant="danger" size="sm" onPress={noop}>Delete build</Button>
</Stack>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children required |
string |
- | |
fullWidth |
boolean |
- | |
icon |
ReactNode |
- | Icon shown before the label (e.g. a lucide-react-native icon). |
loading |
boolean |
false |
Shows a spinner, keeps the width, and blocks presses. Announced as busy. |
numberOfLines |
number |
- | Caps the label's lines. Unset by default so long labels wrap instead of being cut off when the user picks a large text size. |
ref |
Ref<ComponentRef<typeof View>> |
- | |
size |
ButtonSize |
"md" |
|
style |
StyleProp<ViewStyle> |
- | |
variant |
ButtonVariant |
"primary" |
Also takes React Native's Pressable props (testID, accessibilityHint, onLayout…), passed to that Pressable.
Types
type ButtonSize = "sm" | "md" | "lg";
type ButtonVariant = "primary" | "secondary" | "ghost" | "danger";
Screen reader gestures
| Gesture (VoiceOver / TalkBack) | Does |
|---|---|
| Double-tap | Presses it |
Accessibility
- A
button;disabledandloadingare announced (loading as busy). - At least 44×44pt to touch, even at
size="sm"(the extra area comes fromhitSlop). - Uses
minHeight, and the label wraps at large text sizes instead of being cut off.numberOfLinescaps it.
Generated from src/components/Button.tsx. Something wrong or missing? Open an issue.