Button

A clickable control. The label is real HTML. The border and fill are a rough.js rectangle sitting behind it.

The border draws itself in on mount, then re-inks with a second seed on hover. Toggle animate in the playground to compare. See Animation for the library-wide pattern.

<Button variant="primary" size="md" roughness={1.5}>
  Draw me
</Button>

CLI install

npx doodleui-react add button

Usage

import { Button, DoodleUIProvider } from "doodleui-react";

<DoodleUIProvider>
  <Button variant="primary" size="md">
    Draw me
  </Button>
  <Button asChild>
    <a href="/docs">Docs link</a>
  </Button>
  <Button loading>Saving…</Button>
  <Button startIcon={<Icon />} aria-label="Add" />
  <Button animate={false}>Static sketch</Button>
</DoodleUIProvider>

Primary and secondary use hachure fills. Outline is stroke-only. Ghost hides the stroke until hover.

See Sizing, Icons, and Forms for shared conventions.

Props

PropTypeDefaultNotes
variant"primary" | "secondary" | "outline" | "ghost""primary"Fill treatment. Ghost hides the stroke until hover.
size"sm" | "md" | "lg""md"Padding and type size.
disabledbooleanfalseNative disabled state. Lowers opacity.
animatebooleantrueDraw-in on mount and seed-morph on hover. Set false for a static sketch. Overrides DoodleUIProvider. Reduced motion disables this unless the provider set forceAnimate.
roughnessnumber1.5How wobbly the stroke is. 0 is almost geometric. 3+ is messy.
seednumberprovider / randomLocks the sketch. Omit to follow SketchSeedProvider (Shuffle) or a mount-time random seed.
sketchColorstring#1f1d1aStroke color. Also tints primary/accent fills where relevant.
classNamestringundefinedPassed through to the root element.
styleCSSPropertiesundefinedPassed through to the root element.