Button
ActionsTriggers an action with native button behavior and an optional busy indicator.
Try it
Add to your project
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/button.jsonThe command includes the component’s shared dependencies. Your project keeps editable source files.
Include the complete example
This example also composes native-select, label, typography. Install its parts together:
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/button.json https://luv-jeri.github.io/cojeev-ui/r/native-select.json https://luv-jeri.github.io/cojeev-ui/r/label.json https://luv-jeri.github.io/cojeev-ui/r/typography.jsonUsing button
Use onClick for an action or set type="submit" when the button submits a form.
Set loading for busy feedback and disabled separately when repeat activation must be prevented.
API
Compose the exported parts below. The prop types are read from the React source during the registry build.
Native element or underlying primitive props are inherited where declared, including accessible labels, event handlers and refs.
ButtonProps
| Prop | Type | Required |
|---|---|---|
variant | "default" | "danger" | "accent" | "secondary" | "ghost" | "outline" | "block" | null | undefined | No |
size | "default" | "sm" | "lg" | null | undefined | No |
fullWidth | boolean | null | undefined | No |
asChildUse one native element (for example a link) as the interactive root. | boolean | No |
ref | React.Ref<HTMLButtonElement | HTMLAnchorElement> | No |
loading | boolean | No |
loadingIndicator | React.ReactNode | No |
Accessibility
Give the button a clear action name, including aria-label for icon-only content.
Keep a meaningful label while loading; the busy state is exposed with aria-busy.
States and appearance
For conditional content, keep a MotionPresence boundary around keyed MotionSurface children. The shared entrance and exit states work with native primitives and respect your motion preference.
Try pointer and keyboard interaction, and switch the appearance control in the navigation to compare light and dark mode. Motion respects reduced motion preferences.