Skip to content

Button

Terminal window
npx bambiui init
npx bambiui add button

The CLI copies self-contained Button source into your project. The installed output includes framework source, recipe.ts, types.ts, and button.css.

Import global tokens once:

@import "./styles/bambi.css";
import { Button } from './components/ui/button';
<Button intent="primary">Save changes</Button>

Use intent for semantic meaning. Intent controls the base color tokens.

IntentPurpose
primaryMain page or form action
secondaryLower-emphasis action
dangerDestructive action
successPositive confirmation
warningCautionary action
<Button intent="primary">Create</Button>
<Button intent="secondary">Cancel</Button>
<Button intent="danger">Delete</Button>
<Button intent="success">Approve</Button>
<Button intent="warning">Review</Button>

Use appearance for visual treatment without changing the semantic intent.

AppearanceBehavior
solidFilled button, default for primary actions
outlineTransparent background with border
ghostMinimal button for toolbars or quiet actions
linkText-link styling while preserving button behavior
<Button appearance="solid">Solid</Button>
<Button appearance="outline">Outline</Button>
<Button appearance="ghost">Ghost</Button>
<Button appearance="link">Link</Button>
SizeUse case
smDense UI and compact forms
mdDefault size
lgProminent actions
iconIcon-only buttons

Icon-only buttons must have an accessible name:

<Button size="icon" aria-label="Add item">
<PlusIcon aria-hidden="true" />
</Button>

loading shows the spinner, sets aria-busy, and disables interaction. disabled uses the native disabled state.

<Button loading>Saving</Button>
<Button disabled>Unavailable</Button>

Use normal HTML/CSS attributes for layout. React uses className; Svelte, Vue, and Astro use class.

<Button className="w-full">Continue</Button>
.w-full {
width: 100%;
}
PropTypeDefaultDescription
intent'primary' | 'secondary' | 'danger' | 'success' | 'warning''primary'Semantic action intent
appearance'solid' | 'outline' | 'ghost' | 'link''solid'Visual treatment
size'sm' | 'md' | 'lg' | 'icon''md'Button size
loadingbooleanfalseShows spinner and disables interaction
disabledbooleanfalseNative disabled state
type'button' | 'submit' | 'reset''button'Native button type

All other native <button> attributes are forwarded.

Button styling is driven by stable attributes:

AttributeSource
data-intentintent
data-appearanceappearance
data-sizesize
data-loadingloading
  • The default type is button, preventing accidental form submits.
  • Loading buttons set aria-busy and are disabled.
  • Icon-only buttons need aria-label or another accessible name.
  • Visible focus styles are token-driven through Button and global state tokens.