Button

Button is the primary control for triggering an action, submitting data, or confirming a decision.

tsx
import { Button } from '@/components/ui/wideset/button/Button';

<Button>Continue</Button>

Installation

pnpm dlx wideset add button

Copies the component and any Wideset components it uses into your project.

Examples

Variants

Colour carries meaning, not emphasis. Primary is the action the view is for; secondary is a supporting action next to it. Danger is for actions that destroy something, success for a confirmation that completes a flow. Inverse is only for dark or coloured surfaces.

tsx
import { Button } from '@/components/ui/wideset/button/Button';

export default function ButtonVariants() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-center">
      <Button variant="primary">Save changes</Button>
      <Button variant="secondary">Preview</Button>
      <Button variant="danger">Delete project</Button>
      <Button variant="success">Approve</Button>
      <div className="bg-ws-static-inverse-background rounded-ws-container-md p-ws-8">
        <Button variant="inverse">Upgrade plan</Button>
      </div>
    </div>
  );
}

Presets

The preset sets the emphasis. Filled is the one action the view is for, so use it once per view. Border is a real alternative the user may take instead. Ghost is the way out (cancel, back, dismiss) and the quiet action in dense layouts.

tsx
import { Button } from '@/components/ui/wideset/button/Button';

export default function ButtonPresets() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-center">
      <Button preset="filled">Publish</Button>
      <Button preset="border">Save draft</Button>
      <Button preset="ghost">Cancel</Button>
    </div>
  );
}

Sizes

Medium is the default. Extra small and small fit toolbars, table rows and other compact layouts; large gives a page's main call to action more presence and a bigger hit area. Buttons that sit side by side share one size.

tsx
import { Button } from '@/components/ui/wideset/button/Button';

export default function ButtonSizes() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-center">
      {(['xs', 'sm', 'md', 'lg'] as const).map((size) => (
        <Button key={size} size={size}>
          Save changes
        </Button>
      ))}
    </div>
  );
}

Icons

An icon before the label reinforces what the action does; an icon after it suggests direction or a next step. The icon is hidden from screen readers, so the label alone names the button. Keep the label: a button with only an icon is an Icon button and needs an aria-label.

tsx
import { RiArrowRightLine, RiDownloadLine } from '@remixicon/react';
import { Button } from '@/components/ui/wideset/button/Button';

export default function ButtonIcons() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-center">
      <Button preset="border">
        <Button.Icon icon={RiDownloadLine} />
        Download invoice
      </Button>
      <Button>
        Continue
        <Button.Icon icon={RiArrowRightLine} />
      </Button>
    </div>
  );
}

States

Hover, press and keyboard focus are live. A disabled button cannot be focused or clicked and gives no reason why, so disable an action only while it is temporarily unavailable and the user can tell what will enable it, such as an empty required field.

tsx
import { Button } from '@/components/ui/wideset/button/Button';

export default function ButtonStates() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-center">
      <Button>Send invite</Button>
      <Button disabled>Send invite</Button>
    </div>
  );
}

API reference

Button

NameDescriptionDefault
asChild

Whether to render the button styling onto its child element via Radix Slot.

boolean
—
children

Button label or custom content rendered inside the root.

ReactNode
—
className

Additional CSS classes merged with the button root.

string
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
disabled

Disables the button visually and functionally.

boolean
—
onClick

Called when the user activates the button.

MouseEventHandler<HTMLButtonElement>
—
preset
'border''filled''ghost'
'filled'
size
'xs''sm''md''lg'
'md'
type

Native button type used for form behavior.

'button''submit''reset'
—
variant
'primary''secondary''danger''success''inverse'
'primary'
Every other prop of <button> is passed through to it. See MDN: <button>.

Button.Icon

NameDescriptionDefault
icon*

Icon component rendered inside the button.

RemixiconComponentType
—
children—
className

Additional CSS classes merged onto the SVG icon.

string
—

Button.TruncatedText

No props of its ownIt takes its content as children and nothing else.

Accessibility

  • Button.Icon is hidden from screen readers; the label names the button. A button with no label is an IconButton and needs aria-label.
  • With asChild, the child element carries the semantics: use <a href> for navigation.
PartRendersDescription
Button<button>An action button with optional composed content.
Button.Icon—An icon rendered within `Button`.
Button.TruncatedText—A label that truncates with an ellipsis.
tsx
import { Button } from '@/components/ui/wideset/button/Button';

<Button>Continue</Button>

Appearance

Variant
Style
Size

Content

Label
Icon

State

Disabled