Button

A simple button component

Features

  • Size prop that works on all styles.

  • Place an icon before or after.

  • Control icon size explicitly with `iconSize`.

  • Theme groups of buttons with `Button.Apply`.

Usage

import { Button } from 'tamagui'
export default () => <Button>Lorem ipsum</Button>

Sizing

Sizing buttons provides a unique challenge especially for a compiler, because you need to adjust many different properties - not just on the outer frame, but on the text wrapped inside. Tamagui supports adjusting the padding, border radius, font size and icons sizes all in one with the size prop.

import { Button } from 'tamagui'
export default () => <Button size="$6">Lorem ipsum</Button>

Given your theme defines a size 6, the button will adjust all of the properties appropriately. You can also pass a plain number to get an arbitrary size.

Variants

The Button component supports different visual styles through the variant prop. Currently, the primary available variant is "outlined".

import { Button, Stack } from 'tamagui'
export default () => (
<Stack direction="row" space>
<Button>Default</Button>
<Button variant="outlined">Outlined</Button>
</Stack>
)

When variant="outlined" is applied, the button typically has a transparent background with a visible border. The exact appearance (border color, hover/press states) is determined by your theme's definitions for an outlined button.

Icon Theming

You can pass icons as either elements or components. If passing components, Tamagui will automatically theme them (passing size). The icon size is determined by the Button's size prop by default.

You can also explicitly set the icon size using the iconSize prop, which accepts a SizeTokens value (e.g., "$2"). The scaleIcon prop can be used to further adjust the size relative to the determined or explicitly set icon size.

When an icon is present, Tamagui automatically adds spacing between the icon and the button's text. This space is calculated as 40% of the icon's final computed size (after considering size, iconSize, and scaleIcon). This margin is applied to the right of an icon and to the left of an iconAfter.

import { Button, Star } from 'tamagui'
export default () => (
<>
<Button icon={Star} size="$5">
Icon sized by Button
</Button>
<Button icon={Star} iconSize="$2" size="$5">
Icon sized explicitly
</Button>
</>
)

You can use the source of Button itself  to see in more detail what variants you can override, and how we use this pattern internally to create our Button component.

Group Theming

You can use Button.Apply to theme a group of Buttons using a shared context. This is useful for applying consistent sizing or variants to multiple buttons without passing props to each one individually.

import { Button, ButtonDemo, Stack } from 'tamagui'
export default () => (
<Stack space>
<Button.Apply size="$2" variant="outlined">
<Button>Small Outlined 1</Button>
<Button>Small Outlined 2</Button>
<Button icon={ButtonDemo}>With Icon</Button>
</Button.Apply>
<Button.Apply size="$5">
<Button>Large 1</Button>
<Button theme="blue">Large Themed</Button>
</Button.Apply>
</Stack>
)

Creating your own Button

Tamagui now has all the features necessary to make creating a custom Button easy enough that you may want to roll your own button. Learn how to do it with our dedicated guide, How to Build a Button.

Button props

Buttons extend Stack views inheriting all the Tamagui standard props, plus:

Props

  • size

    SizeTokens | number

    Set a size from your theme's size tokens (e.g., "$4") or a specific number. Adjusts padding, font size, and icon sizes.

  • variant

    "outlined" | undefined

    Applies the "outlined" button style.

  • disabled

    boolean

    If true, the button will be non-interactive and visually disabled. Sets `pointerEvents: "none"`.

  • theme

    string

    Apply a theme just to the button and its children.

  • icon

    React.ReactNode | React.ComponentType<{ color?: string, size?: number }>

    Pass any React element or a component. Appears before the text. If a component is passed, 'color' and 'size' props are passed to it.

  • iconAfter

    React.ReactNode | React.ComponentType<{ color?: string, size?: number }>

    Pass any React element or a component. Appears after the text. If a component is passed, 'color' and 'size' props are passed to it.

  • iconSize

    SizeTokens

    Explicitly set the size of the icon, overriding the default size derived from the Button's 'size' prop. Uses theme size tokens (e.g., "$2").

  • scaleIcon

    number

    Scale the icon by this factor. Default is 1. Applied after 'iconSize' or the default size calculation.

  • circular

    boolean

    Forces a circular button. Applies border radius to make the button a circle.

  • chromeless

    boolean | "all"

    Removes default Tamagui visual styles (background, border) for a more minimal appearance, while keeping layout and interactions. If "all", removes hover/press/focus styles too.

  • unstyled

    boolean

    Removes all Tamagui default styles, including layout, interactions, and accessibility attributes. Prefer 'chromeless' for removing only visual styles.

  • // Text Styling

    ---

    To style the text inside the Button (e.g., color, fontWeight), use `styled(Button, { ... })` or create a custom button component using `Button.Text`. Direct text props are not passed to the inner text element for performance and simplicity.