Button

Starts an action. One blue primary per screen.

$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/button.json

Variants

5 variants. Nothing else exists: an unlisted variant (ghost, outline, tinted) is a bug, not an option.

Sizes

default 44 everywhere; sm 36 only in dense rows and toolbars.

Disabled and loading

Disabled = 60 % opacity. Loading with an icon ("Unduh PDF") = disabled + shimmering: the label and icon dim to 50 %, a band sweeps across the words, the icon becomes a spinner. Loading without an icon ("Simpan") = the label turns into the spinner, same width. The fill and the focus stay. loadingText ("Menyimpan…") is read by screen readers only.

Loading → done (motion)

Press a button: loading for 1.5 s, then done: a check that draws itself in the button's own colour for 2 s, at full colour, then back (the app sets loading, then done, then clears it). "Unduh PDF" (icon): dimmed label with the shimmer, the icon slot swaps icon · spinner · check. "Simpan" (no icon): the label swaps label · spinner · check in its own width. Motion: 09 Icon swap (250 ms, scale + 2 px blur + fade; from .9 for the label) + the 10 Success check path draw. Reduced motion: no sweep, a 150 ms cross-fade, the check whole.

Copy to clipboard (CopyButton)

The copy icon swaps to a check that draws itself in the icon's colour (09 Icon swap + the 10 Success check path draw, 250 ms; the "Salin" button uses the Button's own done state) ON THE CLICK, before the clipboard answers, then goes back after 2 s. No toast. Refused: a red alert icon in the same slot and "Gagal menyalin" for screen readers. Icon (ghost, 44 or sm 36, aria-label required) or a "Salin" button.

BCA524 021 7890

Step forward (iconEnd)

Multi-step pages only: the primary ends with arrow-right ("Lanjut: Cek data →"), padding 24 / 20 (the icon side tighter). Kembali = secondary + chevron-left. "Lihat daftar karyawan" is the flow exit: a real link (render <a>) with the primary look, the one nav-primary exception (docs/buttons.md).

Lihat daftar karyawan

Footer pair

Dialog and Sheet footers: Batal left, confirm right, equal widths.

When to use

  • An action that does something: submit, save, open a sheet, download ("Ajukan cuti", "Simpan", "Unduh PDF").
  • The two equal footer buttons of a Dialog or Sheet (Batal + the confirm).

When not to use

  • Going to another page or item → ListRow (dark text + grey chevron). Navigation is never a Button.
  • Icon only (close, bell, prev/next) → IconButton.
  • Picking one of 2–4 values → SegmentedControl.
  • A menu of actions on a row → DropdownMenu with an IconButton trigger.

Which one?

Does it go to another page or item?├─ Yes → not a Button. Use ListRow (dark text + grey chevron).└─ No   Is it destructive or hard to undo?   ├─ Yes → Is it the final confirm inside a Dialog?   │        ├─ Yes → variant="destructive"   │        └─ No  → variant="destructive-secondary" (it opens the Dialog)   └─ No      Is it the single next step on this screen (and no other primary exists)?      ├─ Yes → variant="primary"      └─ No         Is it a short inline action inside a row or card header that changes data?         ├─ Yes → variant="link"         └─ Default → variant="secondary"

Do and don't

DoOne blue primary for the next stepEvery other action is secondary. The user sees at once what to do.
Don'tTwo primaries and a solid red triggerNo hierarchy, and "Lihat slip" is navigation (use ListRow). Solid red belongs only to the confirm inside the Dialog.

Installation

Add Button with the shadcn CLI (your project needs a components.json and the MaHR theme: https://mahrdesign.faizintifada.com/r/theme.json), or copy the files by hand.

terminal
bunx --bun shadcn@latest add https://mahrdesign.faizintifada.com/r/button.json

API

import { Button } from "@/components/ui/button"
PropTypeDefaultDescription
variant"primary" | "secondary" | "destructive" | "destructive-secondary" | "link""secondary"Closed set. See the tree above.
size"default" | "sm""default"44 / 36. sm only inside dense rows and toolbars.
iconReactNode–Leading Neat icon, 20 (16 at sm). Ignored on link.
iconEndReactNode–Trailing icon: only ArrowRightIcon on a step forward ("Lanjut: Cek data", "Impor 44 karyawan"). Ignored on link.
loadingbooleanfalseWith an icon: disabled + shimmering (label and icon at 50 %, a band sweeps across the label, the icon or else the end icon becomes a spinner). Without an icon: the label turns into the spinner. Clicks are ignored; the fill and the focus stay (aria-disabled); the width stays.
loadingTextstring–Screen readers only: "Menyimpan…", "Mengirim…", "Menyiapkan…". Never shown.
done · doneTextboolean · stringfalseSuccess: the slot that spins shows a check that draws itself, in the icon's own colour. Set it when the action worked, clear it after about 2 s. doneText ("PDF diunduh") is for screen readers.
<CopyButton value variant aria-label>string · "icon" | "button" · string–import { CopyButton } from "@/components/ui/copy-button". Copy icon → drawn check on the click, back after 2 s; refused → red alert icon. No toast.
fullWidthbooleanfalseDialog/Sheet footers: two buttons, equal width.
renderReactElement | (props) => ReactElement–Base UI render prop (the shadcn asChild equivalent).
disabled · type · onClick · classNamenative button propstype="button"className merges last (cn). Never override colour with it.