Search

Find a component, token or page

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

  1. Container

    The pressable surface. Height comes from the size prop; corner radius from component.button.radius.

  2. Label

    A short verb phrase in sentence case, such as “Save changes”.

  3. 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).

PropTypeDefaultDescription
variant"default" | "outline" | "secondary" | "ghost" | "destructive" | "link"defaultVisual emphasis.
size"xs" | "sm" | "default" | "lg"defaultControl height and padding.
disabledbooleanfalsePrevents interaction and dims the button.
labelstringSave changesThe button text. Passed as children.
onClickfunction–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

KeysAction
Enter/SpaceActivates the button.
TabMoves 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.

Related