Button
Starts an action. One blue primary per screen.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/button.jsonVariants
Sizes
Disabled and loading
Loading → done (motion)
Copy to clipboard (CopyButton)
524 021 7890
Step forward (iconEnd)
Footer pair
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?
Do and don't
One blue primary for the next stepEvery other action is secondary. The user sees at once what to do.
Two 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.
API
import { Button } from "@/components/ui/button"| Prop | Type | Default | Description |
|---|---|---|---|
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. |
icon | ReactNode | – | Leading Neat icon, 20 (16 at sm). Ignored on link. |
iconEnd | ReactNode | – | Trailing icon: only ArrowRightIcon on a step forward ("Lanjut: Cek data", "Impor 44 karyawan"). Ignored on link. |
loading | boolean | false | With 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. |
loadingText | string | – | Screen readers only: "Menyimpan…", "Mengirim…", "Menyiapkan…". Never shown. |
done · doneText | boolean · string | false | Success: 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. |
fullWidth | boolean | false | Dialog/Sheet footers: two buttons, equal width. |
render | ReactElement | (props) => ReactElement | – | Base UI render prop (the shadcn asChild equivalent). |
disabled · type · onClick · className | native button props | type="button" | className merges last (cn). Never override colour with it. |