Button

Displays a button or a component that looks like a button.

Installation

pnpm dlx cubix@latest add button --base aria

Usage

Import
import { Button } from "@/components/cubix/button"
Example
<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

PropTypeDefaultDescription
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.
renderReact.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.
asChildboolean-Radix: merge props onto the child element instead of rendering a button.
nativeButtonbooleantrueBase UI: set to false when render points at a non-button host such as an anchor or Link.
disabledbooleanfalseDisables the button and prevents interaction.
aria-invalidboolean-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.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

Variants

PropTypeDefaultDescription
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

PropTypeDefaultDescription
xsh-6-Extra-compact control for dense chrome.
smh-7-Compact button for dense UIs.
defaulth-8-Standard height button.
lgh-9-Large button for prominent actions.
icon-xssize-6-Extra-small square button for icon-only actions.
icon-smsize-7-Small square button for icon-only actions.
iconsize-8-Square button for icon-only actions.
icon-lgsize-9-Large square button for icon-only actions.