Button
Web/MobileDisplays a button or a component that looks like a button.
Installation
pnpm dlx cubix-ui@latest add button --base ariaUsage
import { Button } from "@/components/cubix/button"
<Button>
<Icon data-icon="inline-start" />
متن دکمه
<Icon data-icon="inline-end" />
</Button>
Examples
Primary
Solid brand, soft brand, and neutral foreground styles for the main call to action.
Destructive
Solid and soft danger styles, parallel to primary and secondary.
Variants
Lower-emphasis styles for neutral, bordered, quiet, and link-like actions.
Sizes
Text sizes from compact chrome to large actions.
Icon sizes
Square icon-only sizes. Icon-only buttons need an aria-label.
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
Use a square size and always provide an aria-label when there is no visible text.
Loading
Disable the control and show a spinning icon while an async action runs. Set aria-busy so assistive technology knows the action is in progress. Click the button to try it.
Spinner
Or compose the spinner yourself for a static loading state.
As link
Use render to style a Next.js Link as a button. It works the same on Base UI, React Aria, and Radix. Pass nativeButton={false} so Base UI does not treat the host as a native button (ignored on Aria and Radix).
Disabled
Custom styling
Button accepts a className merged with the shipped cn helper. Prefer design tokens over hardcoded colors.
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" | "foreground" | "secondary" | "gray" | "destructive" | "destructive-secondary" | "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 | - | Render the button as another element, such as a Next.js Link. The button children are passed to it. |
| nativeButton | boolean | true | Base UI: set to false when render points at a non-button host such as a Link. Accepted and ignored on React Aria and Radix so paste-ready code stays shared. |
| disabled | boolean | false | Disables the button and prevents interaction. |
| 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. |
| foreground | - | - | Solid foreground fill (black in light mode, inverts in dark mode). A neutral, high-contrast call to action that lifts with a soft shadow on hover; the scale is skipped when reduced motion is on. |
| secondary | - | - | Soft primary tint for secondary actions that stay on-brand. |
| gray | - | - | Neutral gray fill for low-emphasis actions. |
| destructive | - | - | Solid danger fill for irreversible actions. |
| destructive-secondary | - | - | Soft danger tint for secondary destructive actions. |
| outline | - | - | Bordered button that pairs well with gray 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 | 28px | - | Extra-compact control for dense chrome. |
| sm | 32px | - | Compact button for dense UIs. |
| default | 40px | - | Standard height button. |
| lg | 48px | - | Large button for prominent actions. |
| icon-xs | 28px | - | Extra-small square button for icon-only actions. |
| icon-sm | 32px | - | Small square button for icon-only actions. |
| icon | 40px | - | Square button for icon-only actions. |
| icon-lg | 48px | - | Large square button for icon-only actions. |