affectUI › Components › Buttons
Button
Primary, secondary, ghost and destructive buttons with icons, sizes and a shimmering loading state.
Free and open source (MIT). Install: npx shadcn@latest add https://www.affectui.com/r/button.json · Import from @/components/ui/button
When to use
- Any action a user triggers: submit a form, send a message, open a dialog
- Async actions that take a moment – the loading state keeps the label readable while it works
When not to use
- Navigation to another page – use a link so it can be opened in a new tab
- Switching between views – a segmented control or tabs show the current state
Usage
import { Button } from "@/components/ui/button";
export function Actions() {
return (
<>
<Button variant="ghost">Cancel</Button>
<Button>Save changes</Button>
</>
);
}Props
| Name | Type | Default | Description |
|---|---|---|---|
variant | "primary" | "secondary" | "ghost" | "destructive" | "primary" | Dark filled, white with an outline, text only, or red for deleting |
size | "sm" | "md" | "lg" | "md" | 32, 40 or 48px high |
loading | boolean | false | Swaps the left icon for a spinner, shimmers the label, sets aria-busy and ignores clicks |
icon | ReactNode | Icon before the label; without children the button becomes square | |
iconRight | ReactNode | Icon after the label | |
...props | button attributes | Everything a native button takes, including ref, type and disabled |
Keyboard
- Enter / Space: Activate the button
Accessibility
- A native button element, so focus, keyboard and form submission work as expected
- While loading it stays focusable and announces aria-busy instead of becoming disabled
- Icon-only buttons need an aria-label – the icon itself is hidden from screen readers
Responsive
- Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
Requirements
- React 19
Related
- Chat Composer – Prompt composer with model picker, voice input, app connections and approval request