Button

Primitives

Feature-rich button with 6 variants, icon-only mode, button groups, rounded pill shape, custom colors, haptic feedback, and spring animation.

GitHub

Installation

bash
1
npx native-mate add button

Examples

#FAFAFA
Radius100%

Usage

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { Button, ButtonGroup } from '~/components/ui/button'

// Variants
<Button variant="default">Default</Button>
<Button variant="outline">Outline</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="destructive">Delete</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="link">Learn more</Button>

// Sizes
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>

// Rounded pill
<Button rounded>Rounded</Button>

// Icon only (square or circle)
<Button iconOnly iconLeft={<PlusIcon />} />
<Button iconOnly rounded iconLeft={<HeartIcon />} />

// With icons
<Button iconLeft={<PlusIcon />}>Add Item</Button>
<Button iconRight={<ArrowIcon />} variant="outline">Next</Button>

// Custom color
<Button color="#6366f1">Indigo</Button>
<Button color="#10b981" variant="outline">Emerald</Button>

// Full width
<Button fullWidth>Save Changes</Button>

// Haptic feedback
<Button haptic="light">Light tap</Button>
<Button haptic="heavy">Strong tap</Button>
<Button haptic="none">No haptic</Button>

// Button group (segmented control)
<ButtonGroup fullWidth>
  <Button>Day</Button>
  <Button>Week</Button>
  <Button>Month</Button>
</ButtonGroup>

<ButtonGroup fullWidth>
  <Button variant="outline">Cancel</Button>
  <Button variant="default">Confirm</Button>
</ButtonGroup>

// Loading & disabled
<Button loading>Saving…</Button>
<Button disabled>Disabled</Button>

Props

PropTypeDefaultDescription
variant"default" | "outline" | "ghost" | "destructive" | "secondary" | "link""default"Visual style of the button.
size"sm" | "md" | "lg""md"Controls height and padding.
loadingbooleanfalseShows an ActivityIndicator and disables press.
disabledbooleanfalseReduces opacity and disables press.
fullWidthbooleanfalseStretches button to fill container width.
roundedbooleanfalseApplies fully rounded pill shape (borderRadius: 9999).
iconOnlybooleanfalseSquare/circle button with only an icon, no text.
haptic"light" | "medium" | "heavy" | "none""light"Haptic feedback intensity on press. Requires expo-haptics (optional).
colorstringCustom color override. Sets background for default, border for outline.
iconLeftReact.ReactNodeElement rendered before the label.
iconRightReact.ReactNodeElement rendered after the label.
onPress() => voidPress handler.

Example

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { Button, ButtonGroup } from '~/components/ui/button'
import { View } from 'react-native'

export function ButtonExamples() {
  return (
    <View style={{ gap: 16, padding: 16 }}>
      {/* All variants */}
      <Button variant="default">Default</Button>
      <Button variant="outline">Outline</Button>
      <Button variant="ghost">Ghost</Button>
      <Button variant="destructive">Destructive</Button>
      <Button variant="secondary">Secondary</Button>
      <Button variant="link">Link</Button>

      {/* Rounded pill */}
      <Button rounded>Rounded</Button>
      <Button rounded variant="outline">Pill Outline</Button>

      {/* Icon only */}
      <View style={{ flexDirection: 'row', gap: 12 }}>
        <Button iconOnly iconLeft={<PlusIcon />} />
        <Button iconOnly rounded iconLeft={<HeartIcon />} />
      </View>

      {/* With icons */}
      <Button iconLeft={<PlusIcon />}>Add Item</Button>

      {/* Custom colors */}
      <Button color="#6366f1">Indigo</Button>
      <Button color="#10b981">Emerald</Button>

      {/* Button group */}
      <ButtonGroup fullWidth variant="outline">
        <Button>Day</Button>
        <Button>Week</Button>
        <Button>Month</Button>
        <Button>Year</Button>
      </ButtonGroup>

      <ButtonGroup fullWidth>
        <Button variant="outline">Cancel</Button>
        <Button variant="default">Confirm</Button>
      </ButtonGroup>

      {/* Full width */}
      <Button fullWidth>Full Width</Button>

      {/* States */}
      <Button loading>Loading…</Button>
      <Button disabled>Disabled</Button>
    </View>
  )
}

Accessibility

FeatureDetail
RoleaccessibilityRole="button" is set automatically.
LabelaccessibilityLabel is auto-derived from text children, or pass a custom one.
Disabled stateaccessibilityState={{ disabled }} is set when disabled or loading.
Busy stateaccessibilityState={{ busy: true }} is set when loading.
KeyboardFully pressable via assistive technology. Disabled buttons prevent interaction.