--- title: Button description: A button or a component that looks like a button. --- ## Installation CLI Manual ```bash npx shadcn@latest add @coss/button ``` Install the following dependencies: ```bash npm install @base-ui/react ``` Import the following variables into your CSS file ```css @theme inline { --color-destructive-foreground: var(--destructive-foreground); } :root { --destructive-foreground: var(--color-red-700); } .dark { --destructive-foreground: var(--color-red-400); } ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx import { Button } from "@/components/ui/button" ``` ```tsx ``` ## Link You can use the [`render`](https://base-ui.com/react/utils/use-render#migrating-from-radix-ui) prop to make another component look like a button. Here's an example of a link that looks like a button. ```tsx import Link from "next/link" import { Button } from "@/components/ui/button" export function LinkAsButton() { return } ``` ## API Reference This is a custom component using Base UI's `useRender` hook, not a direct Base UI wrapper. ### Button A button component with variant, size, and loading states. | Prop | Type | Default | Description | | --------- | ----------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------- | | `variant` | `"default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "outline" \| "secondary"` | `"default"` | Controls the button styling | | `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xl" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` | `"default"` | Controls the button size | | `loading` | `boolean` | `false` | Shows a spinner and forces disabled button behavior while loading | | `render` | `React.ReactElement` | - | Render as a different element (e.g., Link) | When `loading` is `true`, the component: - Renders a spinner (`data-slot="button-loading-indicator"`) - Adds `data-loading` on the button root - Forces the native `disabled` attribute - Sets `aria-disabled="true"` - Preserves button width by hiding content visually instead of unmounting it ## Examples ### Default ### Outline ### Secondary ### Destructive ### Destructive Outline ### Ghost ### Link ### Extra-small Size ### Small Size ### Large Size ### Extra-large Size ### Disabled ### Icon ### Icon Small Size ### Icon Large Size ### With Icon ### With Link ### Loading (Built-in Prop) ### Loading (Custom Composition)