Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Layout & primitives

Button

Free12.5 KB gzipped

The library's primary action control. Pill-shaped, bold, with a springy press. Renders a native <button type="button">, or an <a> when href is passed.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Enter, Space · Full report

Import

tsx
import { Button, IconButton, ButtonGroup } from "@vjdesigns/vjdesigns-ui";

Importing only Button adds about 12.5 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Variants

variant sets the visual style; tone sets the color separately, so any style works with any tone.

tsx
import { Button, Flex } from "@vjdesigns/vjdesigns-ui";

export function Variants() {
  return (
    <Flex gap={3} wrap="wrap" justify="center">
      <Button variant="solid">Solid</Button>
      <Button variant="soft">Soft</Button>
      <Button variant="outline">Outline</Button>
      <Button variant="ghost">Ghost</Button>
      <Button variant="link">Link</Button>
    </Flex>
  );
}

Tones

tsx
import { Button, Flex } from "@vjdesigns/vjdesigns-ui";

export function Tones() {
  return (
    <Flex gap={3} wrap="wrap" justify="center">
      <Button tone="primary">Primary</Button>
      <Button tone="neutral">Neutral</Button>
      <Button tone="accent">Accent</Button>
      <Button tone="success">Success</Button>
      <Button tone="danger">Danger</Button>
    </Flex>
  );
}

Sizes

tsx
import { Button, Flex } from "@vjdesigns/vjdesigns-ui";

export function Sizes() {
  return (
    <Flex gap={3} align="center" wrap="wrap" justify="center">
      <Button size="sm">Small</Button>
      <Button size="md">Medium</Button>
      <Button size="lg">Large</Button>
    </Flex>
  );
}

With icons

Icons passed as startIcon or endIcon are decorative and hidden from screen readers.

tsx
import {
  ArrowRightIcon,
  Button,
  Flex,
  PlusIcon,
  TrashIcon,
} from "@vjdesigns/vjdesigns-ui";

export function WithIcons() {
  return (
    <Flex gap={3} wrap="wrap" justify="center">
      <Button startIcon={<PlusIcon />}>New project</Button>
      <Button variant="outline" tone="danger" startIcon={<TrashIcon />}>
        Delete
      </Button>
      <Button variant="soft" endIcon={<ArrowRightIcon />}>
        Continue
      </Button>
    </Flex>
  );
}

Loading

While loading, the button keeps its width, sets aria-busy and ignores clicks.

tsx
import { useState } from "react";
import { Button } from "@vjdesigns/vjdesigns-ui";

export function Loading() {
  const [saving, setSaving] = useState(false);

  function save() {
    setSaving(true);
    setTimeout(() => setSaving(false), 2000);
  }

  return (
    <Button loading={saving} loadingText="Saving…" onClick={save}>
      Save changes
    </Button>
  );
}

Icon buttons

Icon-only buttons need an aria-label; the types require it.

tsx
import {
  ChevronRightIcon,
  Flex,
  IconButton,
  PlusIcon,
  TrashIcon,
} from "@vjdesigns/vjdesigns-ui";

export function IconButtons() {
  return (
    <Flex gap={3} align="center">
      <IconButton aria-label="Add item">
        <PlusIcon />
      </IconButton>
      <IconButton aria-label="Delete item" variant="soft" tone="danger">
        <TrashIcon />
      </IconButton>
      <IconButton aria-label="Next page" variant="outline" tone="neutral">
        <ChevronRightIcon />
      </IconButton>
    </Flex>
  );
}

Groups

ButtonGroup passes variant, tone, size and disabled to every button inside. attached joins them edge to edge.

tsx
import {
  Button,
  ButtonGroup,
  ChevronLeftIcon,
  ChevronRightIcon,
  IconButton,
  Stack,
} from "@vjdesigns/vjdesigns-ui";

export function Groups() {
  return (
    <Stack gap={4} align="center">
      <ButtonGroup variant="outline" tone="neutral" aria-label="Text alignment">
        <Button>Left</Button>
        <Button>Center</Button>
        <Button>Right</Button>
      </ButtonGroup>
      <ButtonGroup attached variant="soft" aria-label="Pagination">
        <IconButton aria-label="Previous page">
          <ChevronLeftIcon />
        </IconButton>
        <Button compact>1</Button>
        <Button compact>2</Button>
        <IconButton aria-label="Next page">
          <ChevronRightIcon />
        </IconButton>
      </ButtonGroup>
    </Stack>
  );
}

Pass href to render a link that looks like a button.

tsx
import { ArrowRightIcon, Button } from "@vjdesigns/vjdesigns-ui";

export function AsLink() {
  return (
    <Button href="https://www.npmjs.com/package/@vjdesigns/vjdesigns-ui" variant="outline" endIcon={<ArrowRightIcon />}>
      View on npm
    </Button>
  );
}

Accessibility

An IconButton requires aria-label in its types, so a missing name is a compile error. loading keeps the button's width and focus and sets aria-busy; loadingText is shown and announced. A disabled link drops its href and gets aria-disabled.

Disabled link
tsx
import { Button, Flex, IconButton, TrashIcon } from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <Flex gap={3} align="center" wrap="wrap">
      <IconButton aria-label="Delete draft" variant="ghost" tone="danger">
        <TrashIcon />
      </IconButton>
      <Button loading loadingText="Saving…">
        Save
      </Button>
      <Button href="#example-accessibility" disabled variant="outline" tone="neutral">
        Disabled link
      </Button>
    </Flex>
  );
}

Focusable when unavailable

aria-disabled makes a button unavailable but keeps it focusable, so people can still reach it and read why, such as a countdown. It looks disabled and ignores clicks. Use disabled when the button shouldn't be reachable at all.

tsx
import { useState } from "react";
import { Button, useInterval } from "@vjdesigns/vjdesigns-ui";

export function FocusableWhenUnavailable() {
  const [wait, setWait] = useState(0);
  useInterval(() => setWait((seconds) => seconds - 1), wait > 0 ? 1000 : null);

  return (
    <Button variant="outline" aria-disabled={wait > 0} onClick={() => setWait(15)}>
      {wait > 0 ? `Resend code in 0:${String(wait).padStart(2, "0")}` : "Resend code"}
    </Button>
  );
}

Translated

In Arabic, startIcon sits on the right (the start of the line), and the announcement when loading starts comes from the locale. The labels are your own text.

tsx
import {
  Button,
  Flex,
  PlusIcon,
  LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

export function Translated() {
  return (
    <LocaleProvider locale="ar" messages={ar}>
      <Flex gap={3} align="center" wrap="wrap">
        <Button startIcon={<PlusIcon />}>إضافة عنصر</Button>
        <Button loading variant="outline" tone="neutral">
          حفظ
        </Button>
      </Flex>
    </LocaleProvider>
  );
}

API reference

Button

Button props
PropTypeDefault
children

The visible label.

ReactNode—
startIcon

Decorative icon before the label. Hidden from assistive technology.

ReactNode—
endIcon

Decorative icon after the label. Hidden from assistive technology.

ReactNode—
loading

Shows an inline spinner, sets aria-busy, and ignores clicks. The button keeps its width and stays focusable.

booleanfalse
loadingText

Label shown (and announced) next to the spinner while loading. Defaults to keeping the normal label as the accessible name.

ReactNode—
loadingLabel

Announced to screen readers when loading starts (a plain string loadingText is announced instead). Localize it here.

string"Loading"
fullWidth

Stretches the button to fill its container. Inherits from a surrounding ButtonGroup.

booleanfalse
compact

Tighter side padding, so a short label (a page number, "OK") makes a button no wider than it is tall.

booleanfalse
variant

Visual style. Inherits from a surrounding ButtonGroup.

"solid""soft""outline""ghost""link""inverse""solid"
tone

Semantic color. Inherits from a surrounding ButtonGroup.

"neutral""primary""accent""success""warning""danger""info""primary"
size

Control height, padding, and type size. Inherits from a surrounding ButtonGroup.

"sm""md""lg""md"
radius

Corner rounding. When omitted, uses --control-radius (pill).

"none""xs""sm""md""lg""xl""2xl""pill""pill"
disabled

Disables the control. Buttons use the native disabled attribute; links drop href and get aria-disabled.

booleanfalse
href

Pass a URL to render the control as a link (<a>).

string—
as

A component to render instead, usually a client-side router link (React Router or Next.js Link); its props (e.g. to) are accepted and typed. It must forward ref, className, onClick, and aria-* to an <a>. While disabled or loading, a plain <a role="link" aria-disabled="true"> is rendered instead, since router links can't render without a destination.

ElementType—

Also accepts native <button> attributes, plus className, style and ref.

IconButton

A square (or circular, by default) button that shows only an icon. aria-label is required. At least 32x32 at every size.

IconButton props
PropTypeDefault
size

Control size. xs (24px, the minimum target size) fits inside a sm field without making it taller. Inherits from a surrounding ButtonGroup.

"sm""md""lg""xs""md"
aria-labelRequired

Accessible name. Required, since an icon button has no visible label.

string—
childrenRequired

The icon. Hidden from assistive technology; aria-label names the button.

ReactNode—
loading

Replaces the icon with a spinner, sets aria-busy, and ignores clicks.

booleanfalse
disabled

Disables the control. Buttons use the native disabled attribute; links drop href and get aria-disabled.

booleanfalse
variant

Visual style. Inherits from a surrounding ButtonGroup.

"solid""soft""outline""ghost""link""inverse""solid"
tone

Semantic color. Inherits from a surrounding ButtonGroup.

"neutral""primary""accent""success""warning""danger""info""primary"
radius

Corner rounding. When omitted, uses --control-radius (pill).

"none""xs""sm""md""lg""xl""2xl""pill""pill"
href

Pass a URL to render the control as a link (<a>).

string—
as

A component to render instead, usually a client-side router link (React Router or Next.js Link); its props (e.g. to) are accepted and typed. It must forward ref, className, onClick, and aria-* to an <a>. While disabled or loading, a plain <a role="link" aria-disabled="true"> is rendered instead, since router links can't render without a destination.

ElementType—

Also accepts native <button> attributes, plus className, style and ref.

ButtonGroup

Groups related buttons (role="group"). Give it an aria-label or aria-labelledby when the group's purpose isn't clear from context.

ButtonGroup props
PropTypeDefault
attached

Joins buttons edge to edge, sharing borders, with rounding on the outer corners only.

booleanfalse
orientation

Layout direction.

"horizontal""vertical""horizontal"
gap

Space between buttons (a --space-* step). Ignored when attached.

Space2
fullWidth

Stretches the group to fill its container and makes buttons share the space equally.

booleanfalse
children

The buttons. size, variant, tone, radius, and disabled are passed down; a button's own props win.

ReactNode—
variant

Visual style. Inherits from a surrounding ButtonGroup.

"solid""soft""outline""ghost""link""inverse""solid"
tone

Semantic color. Inherits from a surrounding ButtonGroup.

"neutral""primary""accent""success""warning""danger""info""primary"
size

Control height, padding, and type size. Inherits from a surrounding ButtonGroup.

"sm""md""lg""md"
radius

Corner rounding. When omitted, uses --control-radius (pill).

"none""xs""sm""md""lg""xl""2xl""pill""pill"
disabled

Disables the control. Buttons use the native disabled attribute; links drop href and get aria-disabled.

booleanfalse

Also accepts native <div> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

Button targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

36 passed · 0 failed · 29 not applicable · 10 to check by hand

Dark mode

Score 100

36 passed · 0 failed · 29 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabMoves focus to the button. A disabled button is skipped; a loading one stays focusable.
EnterSpaceActivates the button. As a link (href), Enter follows it.

Roles and states

Roles and states
ElementRoleStates and properties
<button type="button">buttonaria-disabled and aria-busy while loading
<a> (with href)linkaria-disabled when disabled
IconButtonbuttonaria-label (required)
ButtonGroupgrouparia-label

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)