Button
Runs an action, shows that it's working, and stays reachable when disabled.
Variants
Use primary for the one action a view is about, and quieter variants for the rest.
Sizes
icon is square, for a button holding only an icon. Give it an aria-label.
Pending
Return a Promise from onClick and the button stays pending until it settles: it ignores
further presses, keeps focus, and tells screen readers it’s busy after a second. Style the
waiting state with the data-pending attribute, or Tailwind’s in-data-pending: variant
inside the button.
Dependencies
What it's built from and what's built from it in Shell, read from the imports in its source.
| Uses | Textprimitive |
|---|---|
| Used by | Nothing yet. |
| Packages | None. |
Installation
Set the project up for Shell once first, as Getting started shows. Add the components it uses, listed under Dependencies. Then copy the source:
API reference
Generated from Shell's types. Props marked ours are added here; the rest come from
the nsh/base part it wraps. Every part also takes nsh's view props, like class, style and testID.
Button
Runs an action.
- childrenours
A label, set in the variant's color, or your own content.
Type Element
- sizeours
Height, padding and label size.
Type ButtonSize · Default md
- variantours
How much the button stands out.
destructiveis a tint, for actions that can't be undone.Type ButtonVariant · Default primary
- accessibilityHint
What activating the button does, for screen readers, as a view's
accessibilityHint.Type string | null
- accessibilityLabel
What screen readers say, when its content is not enough (an icon).
Type string | null
- busy
Busy: its action is running (a "Saving…" button), and screen readers say so. Presses still count; the app sets
disabledas well to refuse them.Type boolean
- disabled
No presses, no press feedback;
disabled:styles apply and screen readers say it is dimmed. A button in a disabledToolbaris disabled too.Type boolean
- hitSlop
How far outside its bounds presses still count, as a view's
hitSlop: one number for every side, or the sides named (each left out 0). A small target (an icon) takes presses a finger lands near it, with no change to its layout or look.Type number | Partial<Edges>
- onPress
The button was pressed.
Type (() => void)
- onPressDown
A press went down on it (for the app's own press feedback).
Type (() => void)
- onPressUp
The press ended: released, moved away or cancelled.
Type (() => void)
- role
What it is for screen readers (default
"button": a link, a tab, a menu item, ...).Type AccessibilityRole | null
- selected
Selected (a toggled trigger, the current tab): screen readers say so. The app owns the value and styles it.
Type boolean
- selectedStyle
The style while
selected(and not disabled), asselected:classes.Type StyleProp<ViewStyle>