Button
A button starts an action on the current page; use a link when the action takes the person somewhere else.
When to use
Section titled “When to use”- Use one
defaultbutton for the main action of a form, card or dialog. - Use
secondaryoroutlinefor the other actions next to it. - Use
ghostin toolbars and dense rows, andlinkinside running text. - Use
destructiveonly for actions that delete or cancel something. - Don’t use a button to navigate to another page; use a link.
Do and don’t
Section titled “Do and don’t”Anatomy
Section titled “Anatomy”- 1Container, on the control radius
- 2Label
- 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.
Variants
Section titled “Variants”| 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> )}<script setup lang="ts">import { Button } from "@/components/ui/button"</script>
<template> <div class="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></template>import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';
class ButtonDemo extends StatelessWidget { const ButtonDemo({super.key});
@override Widget build(BuildContext context) { return Wrap( spacing: 8, runSpacing: 8, children: [ ShadButton(onPressed: () {}, child: const Text('Simpan')), ShadButton.secondary(onPressed: () {}, child: const Text('Simpan draf')), ShadButton.outline(onPressed: () {}, child: const Text('Lihat detail')), ShadButton.ghost(onPressed: () {}, child: const Text('Batal')), ShadButton.destructive(onPressed: () {}, child: const Text('Hapus')), ShadButton.link(onPressed: () {}, child: const Text('Pelajari lebih lanjut')), ], ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/button.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/button.jsonAccessibility
Section titled “Accessibility”- Renders a native
button, so Enter and Space trigger it. - Every icon-only button needs an
aria-label. - The focus ring uses
ringand shows only for keyboard focus. - Keep the label to the action itself: “Simpan”, not “Klik di sini”.
