Base · Actions
Button
Triggers an action or event when pressed.
HTML / JSDraftReactStableReact NativeDraftSwift (SwiftUI)DraftGodotDraftVueDraftSvelteDraftSolidDraft
Reviewed
Props
tsx
import { Button } from "@/components/ui/button"
<Button>Save changes</Button>Overview
Buttons start actions: submitting a form, opening a dialog, confirming a choice. The variant signals how important the action is relative to the others around it.
When to use
- To start an action on the current screen: save, send, delete, open.
- Use one default (solid) button per view for the main action; use outline, secondary or ghost for everything else.
- Use the destructive variant for actions that remove data or cannot be undone.
When not to use
- To navigate to another page: use a link, or the link variant only when it must sit in a row of buttons.
- To switch a setting on or off: use a Switch or Toggle.
- To choose between views: use Tabs.
Anatomy
Container
The pressable surface. Height comes from the size prop; corner radius from component.button.radius.
Label
A short verb phrase in sentence case, such as “Save changes”.
Icon (optional)
Sits before or after the label. An icon-only button needs an accessible name.
Props
The contract every language implements. Names follow each language’s conventions (camelCase in React, snake_case in Rust).
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "outline" | "secondary" | "ghost" | "destructive" | "link" | default | Visual emphasis. |
| size | "xs" | "sm" | "default" | "lg" | default | Control height and padding. |
| disabled | boolean | false | Prevents interaction and dims the button. |
| label | string | Save changes | The button text. Passed as children. |
| onClick | function | – | Called when the button is pressed. `onPress` in React Native, `onclick` in Dioxus, the trailing closure in Swift, the `pressed` signal in Godot. |
States
- Rest
- Default appearance.
- Hover
- Fill shifts one step. Pointer devices only.
- Pressed
- Moves down 1px on web; dims on touch platforms.
- Focus-visible
- 3px focus ring in color.border.focus, shown for keyboard focus only.
- Disabled
- 50% opacity, no pointer events, removed from the tab order.
Accessibility
Role: button
| Keys | Action |
|---|---|
| Enter/Space | Activates the button. |
| Tab | Moves focus to the next focusable element. |
- Icon-only buttons must have an accessible name (aria-label, accessibilityLabel).
- Label contrast against the fill meets WCAG AA in every theme: the on-solid color is chosen automatically.
- Minimum touch target is 44pt on mobile; the React Native build extends the hit area for smaller sizes.
Design tokens
Change any of these in Foundations and this component follows, in every language.
Platform notes
- HTML / JS
- Draft
- Renders a native <button>; `variant` and `size` are data attributes.
- React
- Stable
- Matches the contract with no platform differences.
- React Native
- Draft
- Built on Pressable. Hover styles apply on web and pointer devices only.
- Swift (SwiftUI)
- Draft
- A SwiftUI Button with PdcButtonStyle (also usable on its own). Heights follow the touch ladder: 44pt by default.
- Godot
- Draft
- Extends Godot's Button. Variants are theme type variations in pdc_theme_*.tres; `size` is `button_size` because Control already has `size`.
- Vue
- Draft
- Usage snippet only; same props and behavior as the React component.
- Svelte
- Draft
- Usage snippet only; same props and behavior as the React component.
- Solid
- Draft
- Usage snippet only; same props and behavior as the React component.