Examples

Variants

Use one primary action per view. Secondary and tertiary for alternatives, ghost for low emphasis, destructive only for irreversible actions.

Preview
Example.tsx
import { Button, HStack } from '@reactloom/ui';

export default function Example() {
  return (
    <HStack wrap justify="center">
      <Button>Primary</Button>
      <Button variant="secondary">Secondary</Button>
      <Button variant="tertiary">Tertiary</Button>
      <Button variant="outline">Outline</Button>
      <Button variant="ghost">Ghost</Button>
      <Button variant="destructive">Delete</Button>
      <Button variant="link">Link</Button>
    </HStack>
  );
}

Sizes

Small 28 px, medium 32 px (default), large 40 px. Density on the ThemeProvider shifts all of them.

Preview
Example.tsx
import { Button, HStack } from '@reactloom/ui';

export default function Example() {
  return (
    <HStack>
      <Button size="sm">Small</Button>
      <Button size="md">Medium</Button>
      <Button size="lg">Large</Button>
    </HStack>
  );
}

With icons

Icons are decorative and hidden from assistive technology.

Preview
Example.tsx
import { Button, HStack } from '@reactloom/ui';
import { ArrowRight, Download, Plus } from 'lucide-react';

export default function Example() {
  return (
    <HStack wrap justify="center">
      <Button startIcon={<Plus />}>New project</Button>
      <Button variant="secondary" startIcon={<Download />}>Export CSV</Button>
      <Button variant="outline" endIcon={<ArrowRight />}>Continue</Button>
    </HStack>
  );
}

Loading

Blocks clicks and form submission, keeps focus, and announces the loading text.

Preview
Example.tsx
import { Button } from '@reactloom/ui';
import { useState } from 'react';

export default function Example() {
  const [saving, setSaving] = useState(false);
  const save = () => {
    setSaving(true);
    setTimeout(() => setSaving(false), 1600);
  };
  return (
    <Button loading={saving} loadingText="Saving" onClick={save}>
      Save changes
    </Button>
  );
}

As a link

asChild renders your element — an anchor or your router’s Link — with button styling.

Preview
Example.tsx
import { Button } from '@reactloom/ui';
import { ArrowUpRight } from 'lucide-react';

export default function Example() {
  // With a router, pass your <Link to="…"> instead of <a>.
  return (
    <Button asChild variant="secondary" endIcon={<ArrowUpRight />}>
      <a href="#pricing">View pricing</a>
    </Button>
  );
}

Form footer

A typical layout: low-emphasis destructive action on the left, primary flow on the right.

Preview
Example.tsx
import { Button, HStack, Spacer } from '@reactloom/ui';

export default function Example() {
  return (
    <HStack style={{ width: '100%', maxWidth: 520 }}>
      <Button variant="ghost">Discard draft</Button>
      <Spacer />
      <Button variant="secondary">Save as draft</Button>
      <Button type="submit">Publish</Button>
    </HStack>
  );
}

API reference

Button props
PropTypeDefault
variant
Visual emphasis.
'primary' | 'secondary' | 'tertiary' | 'outline' | 'ghost' | 'destructive' | 'link''primary'
size
Control height and type size.
'sm' | 'md' | 'lg''md'
radius
Corner radius; defaults to the theme (--pl-button-radius).
'none' | 'sm' | 'md' | 'lg' | 'full'—
loading
Show a spinner; block activation while keeping focus.
booleanfalse
loadingText
Announced while loading.
string'Loading'
startIcon / endIcon
Decorative icons.
ReactNode—
fullWidth
Stretch to the container width.
booleanfalse
asChild
Render the single child element with button behaviour and styling.
booleanfalse
type
Native type. Note the safer default.
'button' | 'submit' | 'reset''button'
…
All native attributes and the ref go to the <button>.
ButtonHTMLAttributes—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

CSS variables

VariableDefault
--pl-button-radiusvar(--pl-radius-md

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-disabled]present when on
[data-full-width]present when on
[data-loading]present when on
[data-radius]none · sm · md · lg · full
[data-size]sm · md · lg
[data-variant]primary · secondary · tertiary · outline · ghost · destructive · link

Theme tokens it reads

--pl-color-accent-fg --pl-color-accent-solid --pl-color-accent-solid-active --pl-color-accent-solid-hover --pl-color-accent-subtle --pl-color-accent-subtle-hover --pl-color-bg-muted --pl-color-bg-subtle --pl-color-bg-surface --pl-color-border-default --pl-color-border-strong --pl-color-danger-on-solid --pl-color-danger-solid --pl-color-danger-solid-hover --pl-color-fg-default --pl-color-fg-disabled --pl-color-fg-link --pl-color-fg-on-accent --pl-control-height-lg --pl-control-height-md --pl-control-height-sm --pl-focus-ring-color --pl-focus-ring-offset --pl-focus-ring-width --pl-font-size-lg --pl-font-size-md --pl-font-size-sm --pl-radius-full --pl-radius-lg --pl-radius-md --pl-radius-none --pl-radius-sm --pl-shadow-xs

Accessibility

  • Native button semantics: role, focus and Enter/Space activation come from the browser.
  • Loading uses aria-disabled rather than disabled, so keyboard focus stays where it was.
  • The label stays in the accessible name while loading (“Save changes Saving”).
  • Icon-only buttons must have a name — use IconButton, which requires one.
Keyboard interactions
KeyAction
Enter / SpaceActivate the button
TabMove focus to the next control

Usage guidelines

Do

  • Write labels as verbs: “Save changes”, “Invite member”.
  • Keep one primary button per view.
  • Use loading for async actions instead of disabling.

Don’t

  • Don’t use disabled buttons to explain why something is unavailable — say why in text.
  • Don’t use the link variant for navigation; use Link.
  • Don’t put two destructive buttons side by side.