Skip to content

Button

Download .md

A button starts an action on the current page; use a link when the action takes the person somewhere else.

  • Use one default button for the main action of a form, card or dialog.
  • Use secondary or outline for the other actions next to it.
  • Use ghost in toolbars and dense rows, and link inside running text.
  • Use destructive only for actions that delete or cancel something.
  • Don’t use a button to navigate to another page; use a link.
React
Vue
DoUse one default button for the main action; the others are outline or secondary.
Don'tDon't give two actions the same weight; people can't tell which one moves them forward.
123
  1. 1Container, on the control radius
  2. 2Label
  3. 3Outline variant for a second action

A button is a label, with an optional icon before or after it. It sits on the control radius (radius-md, 8px) and is never a pill.

Variant Looks Use it for
default primary fill, primary-foreground text The main action. One per area.
secondary secondary fill A second action with less weight.
outline border outline on background Neutral actions next to the main one.
ghost No fill until hover Toolbars, table rows, icon buttons.
destructive destructive text on a soft destructive fill Delete, reject or cancel.
link primary text, underlined on hover Actions inside a sentence.

Sizes: xs, sm, default, lg, and square icon, icon-xs, icon-sm, icon-lg for icon-only buttons.

React Vue Flutter Type Default Use
variant variant named constructor (ShadButton.outline) see Variants default Visual weight.
size size size (ShadButtonSize) see Variants default Height and padding.
disabled disabled enabled: false boolean false Blocks the action.
onClick @click onPressed function none Runs the action.
import { Button } from "@/components/ui/button"
export default function ButtonDemo() {
return (
<div className="flex flex-wrap items-center gap-2">
<Button>Simpan</Button>
<Button variant="secondary">Simpan draf</Button>
<Button variant="outline">Lihat detail</Button>
<Button variant="ghost">Batal</Button>
<Button variant="destructive">Hapus</Button>
<Button variant="link">Pelajari lebih lanjut</Button>
</div>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/button.json
  • Renders a native button, so Enter and Space trigger it.
  • Every icon-only button needs an aria-label.
  • The focus ring uses ring and shows only for keyboard focus.
  • Keep the label to the action itself: “Simpan”, not “Klik di sini”.