Button
Displays a button or a component that looks like a button.
Installation
pnpm dlx cubix@latest add button --base ariaUsage
import { Button } from "@/components/cubix/button"<Button variant="outline">Button</Button>Examples
Variants
Sizes
With icon
Render an icon inside the button. Use data-icon="inline-start" and data-icon="inline-end" so padding follows reading direction in LTR and RTL.
Icon only
Loading
Disable the button and compose a spinner while an async action is in flight. Click the button below to try it:
If you prefer full control, compose the spinner yourself:
As link
Use render (Base UI / React Aria) or asChild (Radix) to render a Next.js <Link /> with button styles. On Base UI pass nativeButton={false}.
Custom styling
Every prop accepts a className merged with the shipped cn helper:
Invalid
Set aria-invalid to switch to destructive border and ring styles - no extra prop needed:
Disabled
RTL
To enable RTL support, see the Direction guide. Icon padding uses inline-start / inline-end so it stays correct under dir="rtl".
API Reference
Note: Mark icons and spinners with data-icon so spacing follows reading direction. Icon-only buttons need an aria-label.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | "default" | The visual style of the button. |
| size | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "default" | The size of the button. |
| render | React.ReactElement | - | Base UI / React Aria: render the button as another element, such as a Next.js Link. Pass nativeButton={false} on Base UI when that element is not a native button. |
| asChild | boolean | - | Radix: merge props onto the child element instead of rendering a button. |
| nativeButton | boolean | true | Base UI: set to false when render points at a non-button host such as an anchor or Link. |
| disabled | boolean | false | Disables the button and prevents interaction. |
| aria-invalid | boolean | - | Marks the button as invalid and applies destructive border and ring styles. |
| type | "button" | "submit" | "reset" | "button" | Native button type. Defaults to button so it does not submit enclosing forms. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
Variants
| Prop | Type | Default | Description |
|---|---|---|---|
| default | - | - | Solid primary button. The main call-to-action style. |
| secondary | - | - | A softer alternative to the default variant for secondary actions. |
| destructive | - | - | For destructive actions such as deleting data. |
| outline | - | - | Bordered button that pairs well with secondary or ghost buttons. |
| ghost | - | - | No background until hover. Ideal for toolbars and menus. |
| link | - | - | Looks like a link but behaves like a button. |
Sizes
| Prop | Type | Default | Description |
|---|---|---|---|
| xs | h-6 | - | Extra-compact control for dense chrome. |
| sm | h-7 | - | Compact button for dense UIs. |
| default | h-8 | - | Standard height button. |
| lg | h-9 | - | Large button for prominent actions. |
| icon-xs | size-6 | - | Extra-small square button for icon-only actions. |
| icon-sm | size-7 | - | Small square button for icon-only actions. |
| icon | size-8 | - | Square button for icon-only actions. |
| icon-lg | size-9 | - | Large square button for icon-only actions. |