Skip to content
Cojeev UI

Button

Actions

Triggers an action with native button behavior and an optional busy indicator.

React · copy into your project · light and dark themes

Try it

Loading preview…

Take it with you

Copy the example, API and usage notes for your editor or AI assistant.

Add to your project

Terminal
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/button.json

The 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:

Terminal
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.json

Using 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

PropTypeRequired
variant"default" | "danger" | "accent" | "secondary" | "ghost" | "outline" | "block" | null | undefinedNo
size"default" | "sm" | "lg" | null | undefinedNo
fullWidthboolean | null | undefinedNo
asChild

Use one native element (for example a link) as the interactive root.

booleanNo
refReact.Ref<HTMLButtonElement | HTMLAnchorElement>No
loadingbooleanNo
loadingIndicatorReact.ReactNodeNo

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

resthoverfocusactivedisabledbusy

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.