Button
An animated action button with solid save, share, and delete colors, optional icons, and success feedback.
How it works
Save uses emerald, share uses sky, and delete uses rose. A matching hover glow and spring press response keep each action lively. Optional feedback animates the label and icon, then returns to the original state after its duration. Motion is reduced when the user prefers reduced motion.
Accessibility
Uses native button or anchor semantics, an announced polite feedback label, visible keyboard focus, disabled link handling, and reduced-motion-aware transitions.
Limitations
This is a single-action control. Use a separate Toggle or Tabs component when the control represents persistent selection or a group of choices.
Features
- Use as a native button or provide href for an anchor link.
- Choose primary, secondary, outline, ghost, or soft visual variants.
- Choose small, medium, large, or icon sizing.
- Pass an optional icon and feedback label/icon for animated action confirmation.
- Adds an intent-matched hover glow, focus ring, lift, and press response.
- Keeps keyboard focus visible and respects reduced-motion preferences.
Installation
Choose the CLI command or install the component manually.
$ npx @istmx/ui add buttonCopies the install command for your selected package manager.
Dependencies
Usage
Import the component from the file you copied it to, then use it like any other React component.
import Button from '@/components/ui/button' <Button onClick={() => console.log('Saved')}> Save changes</Button> <Button icon={<BookmarkIcon />} feedback={{ label: 'Saved', icon: <CheckIcon /> }} onClick={saveItem}> Save</Button> <Button intent="share" feedback={{ label: 'Link copied' }} onClick={shareLink}> Share</Button> <Button intent="delete" feedback={{ label: 'Deleted' }} onClick={deleteItem}> Delete</Button> <Button href="/stays" variant="outline" size="lg"> Explore stays</Button>Composition
Button├── Surface and sheen└── Action contentAPI reference
childrenReactNodeButton label or content.
href?stringWhen provided, renders an anchor instead of a button.
variant?ButtonVariantprimary, secondary, outline, ghost, or soft. Defaults to primary.
intent?ButtonIntentSets the primary action color: save (emerald), share (sky), or delete (rose). Defaults to save.
size?ButtonSizesm, md, lg, or icon. Defaults to md.
disabled?booleanDisables a button or prevents navigation for an anchor.
icon?ReactNodeOptional leading icon shown beside the idle label.
feedback?{ label: string; icon?: ReactNode; duration?: number }After activation, briefly swaps to a confirmation label and optional icon. Defaults to a check mark and 1800 ms.
className?stringAdditional Tailwind classes for the control.
type?"button" | "submit" | "reset"Native button type; defaults to button.
The listed props match the current component implementation.
Data attributes
Button does not expose custom data attributes.
Examples
Use the primary variant for the main action and opt into feedback when the user needs confirmation that a save, send, or similar action completed. The component accepts native button props and anchor props when href is supplied.
Credits & inspiration
Created by Aryan (istmX) for ISTMX. The source-first, copy-and-own philosophy is inspired by shadcn/ui. About the creator