Skip to main content

Button

Button is an interactive control that triggers an action, such as submitting a form, adding an item, or deleting a draft.

Import

import { Button } from '@vortexlabs/vortex-native';
import type { ButtonProps } from '@vortexlabs/vortex-native';

Other links

import { Button } from "@vortexlabs/vortex-native";

<Button
  variant="primary"
  size="md"
  loading={false}
>
  Button
</Button>

Features

  • Supports primary, secondary, and tertiary variants with a critical tone.
  • Supports responsive sizes and width.
  • Shows a loading spinner and supports text or icons.
  • Supports press shrink and haptics.

Variants

Use primary for the main action, secondary for supporting actions, and tertiary for quieter actions.

<Stack direction="row" gap={2}>
  <Button variant="primary">Primary</Button>
  <Button variant="secondary">Secondary</Button>
  <Button variant="tertiary">Tertiary</Button>
</Stack>

Icons

Use the Icon source example to define Hexagon.

<Stack direction="row" gap={2}>
  <Button startIcon={Hexagon}>Add item</Button>
  <Button onlyIcon={Hexagon} ariaLabel="Add item" />
</Stack>

Sizes

Set size to match the surrounding controls. Buttons grow when the system text size needs more room.

<Stack direction="row" align="center" gap={2} wrap>
  <Button size="xs">Button</Button>
  <Button size="sm">Button</Button>
  <Button size="md">Button</Button>
  <Button size="lg">Button</Button>
</Stack>

Responsive Sizes

Pass a breakpoint object to change the size with the window width.

<Button size={{ xs: "sm", md: "lg" }}>Button</Button>

Shape

Set rounded for fully rounded corners.

<Stack direction="row" gap={2} wrap>
  <Button>Button</Button>
  <Button rounded>Button</Button>
</Stack>

Width

Set fullWidth to fill the available width of the parent.

<Stack width={240} maxWidth="100%" gap={2}>
  <Button>Button</Button>
  <Button fullWidth>Button</Button>
</Stack>

States

Set disabled when the action is unavailable and loading while it runs. Use loadingText to keep the label beside the spinner.

<Stack direction="row" gap={2}>
  <Button disabled>Button</Button>
  <Button loading>Button</Button>
  <Button loading loadingText>Button</Button>
</Stack>

Tone

Use tone="critical" for destructive actions.

<Stack direction="row" gap={2} wrap>
  <Button tone="critical">Delete</Button>
  <Button variant="secondary" tone="critical">Delete</Button>
</Stack>

Button.Group

Place related buttons directly inside the group to join their edges and add separators.

<Button.Group>
  <Button variant="secondary">One</Button>
  <Button variant="secondary">Two</Button>
  <Button variant="secondary">Three</Button>
</Button.Group>

Button.Align

Wrap a single button to align its content with the surrounding layout. The start and end edges follow the reading direction.

<Stack padding={3}>
  <Text>Account</Text>
  <Button.Align edges="start">
    <Button variant="tertiary">Edit</Button>
  </Button.Align>
</Stack>

Configure feedback through the provider haptics setup. Use pressShrink={false} to turn off press shrink for a single button.

Accessibility

Description
Provide ariaLabel with onlyIcon.
loading marks the button as busy for assistive technology.
Leave enough room around small buttons for their expanded touch area.