Skip to content

Action

Button

Triggers an action or event.

import { Button } from '@var-ui/react';

Button

Triggers an action or event. With href, Button renders React Aria’s Link, so it honours RouterProvider for client-side routing.

Examples

Default

The default button uses tone="neutral" and appearance="subtle".

Demo.tsxTSX
import { Button } from '@var-ui/react';

<Button>Click me</Button>

Variants

Use tone and appearance to control color and surface treatment — the same vocabulary as Badge, Alert, and Banner.

  • tone — neutral, accent, success, warning, danger, info
  • appearance — solid, outline, subtle, ghost

Each row below is one appearance; each button in the row is a different tone.

Demo.tsxTSX
import { Button, HStack, Stack } from '@var-ui/react';

const tones = ['neutral', 'accent', 'success', 'warning', 'danger', 'info'] as const;
const appearances = ['solid', 'outline', 'subtle', 'ghost'] as const;

<Stack gap="lg">
  {appearances.map((appearance) => (
    <HStack key={appearance} gap="sm" wrap>
      {tones.map((tone) => (
        <Button key={tone} tone={tone} appearance={appearance}>
          {tone}
        </Button>
      ))}
    </HStack>
  ))}
</Stack>

Sizes

size (xs, sm, md, lg, xl) falls back to the surrounding control size, then md, so a button inside an InputGroup, a Toolbar or a Select.Root matches its neighbours without its own size.

Demo.tsxTSX
import { Button, HStack } from '@var-ui/react';

<HStack gap="sm" align="center" wrap>
  <Button size="xs">Extra small</Button>
  <Button size="sm">Small</Button>
  <Button size="md">Medium</Button>
  <Button size="lg">Large</Button>
  <Button size="xl">Extra large</Button>
</HStack>

xs is for dense rows, tags and code-block headers. Its box is 20px, under the 24px minimum target in WCAG 2.2 (2.5.8), so an invisible layer grows the pointer target to 24px without changing layout. Leave at least 4px between neighbouring xs buttons so their targets don’t overlap. xs and xl are button-only: text inputs and selects stop at sm–lg.

Disabled

Pass disabled to remove the button from the tab order and block press events.

Demo.tsxTSX
import { Button, HStack } from '@var-ui/react';

<HStack gap="sm" wrap>
  <Button disabled>Disabled</Button>
  <Button tone="accent" appearance="solid" disabled>
    Disabled primary
  </Button>
</HStack>

HTML

Set data-tone and data-appearance on a .var-ui-button element (plus data-size and data-layout when needed). In TypeScript, use button({ tone, appearance }) from @var-ui/core.

Props

Accessibility

Built on React Aria Components where applicable.