Files
Pasquale Vitiello fd72ad7430 docs: general improvements (#628)
* docs: add API Reference sections to all component documentation

- Add comprehensive API Reference sections to 36 component docs
- Document custom props, variants, and behaviors for each component
- Distinguish between Base UI aliases and custom components
- Include prop tables with Type, Default, and Description columns
- Follow alert-dialog.mdx as the reference standard for quality

Co-Authored-By: pasquale@cal.com <pasquale@cal.com>

* docs: add essential inline examples and 'Also exported as' notes

- Add inline code example for Menu's inset prop showing alignment pattern
- Add 'Also exported as ToggleGroupItem' note to Toggle component
- Add ToggleGroupSeparator to toggle-group documentation
- Add 'Also exported as RadioGroupItem' note to Radio component

Co-Authored-By: pasquale@cal.com <pasquale@cal.com>

* docs: fix section ordering - API Reference before Examples

Co-Authored-By: pasquale@cal.com <pasquale@cal.com>

* docs: remove references to non-exported components

Co-Authored-By: pasquale@cal.com <pasquale@cal.com>

* docs: fix inaccurate API documentation per Cubic AI review

Co-Authored-By: pasquale@cal.com <pasquale@cal.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: pasquale@cal.com <pasquale@cal.com>
2026-01-13 09:40:05 +00:00

173 lines
3.5 KiB
Plaintext

---
title: Button
description: A button or a component that looks like a button.
---
<ComponentPreview name="p-button-1" />
## Installation
<CodeTabs>
<TabsList>
<TabsTab value="cli">CLI</TabsTab>
<TabsTab value="manual">Manual</TabsTab>
</TabsList>
<TabsPanel value="cli">
```bash
npx shadcn@latest add @coss/button
```
</TabsPanel>
<TabsPanel value="manual">
<Steps>
<Step>Install the following dependencies:</Step>
```bash
npm install @base-ui/react
```
<Step>Import the following variables into your CSS file</Step>
```css
@theme inline {
--color-destructive-foreground: var(--destructive-foreground);
}
:root {
--destructive-foreground: var(--color-red-700);
}
.dark {
--destructive-foreground: var(--color-red-400);
}
```
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource name="button" title="components/ui/button.tsx" />
<Step>Update the import paths to match your project setup.</Step>
</Steps>
</TabsPanel>
</CodeTabs>
## Usage
```tsx
import { Button } from "@/components/ui/button"
```
```tsx
<Button>Button</Button>
```
## 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 <Button render={<Link href="/login" />}>Login</Button>
}
```
## 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 and size options.
| 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 |
| `render` | `React.ReactElement` | - | Render as a different element (e.g., Link) |
## Examples
### Default
<ComponentPreview name="p-button-1" />
### Outline
<ComponentPreview name="p-button-2" />
### Secondary
<ComponentPreview name="p-button-3" />
### Destructive
<ComponentPreview name="p-button-4" />
### Destructive Outline
<ComponentPreview name="p-button-5" />
### Ghost
<ComponentPreview name="p-button-6" />
### Link
<ComponentPreview name="p-button-7" />
### Extra-small Size
<ComponentPreview name="p-button-8" />
### Small Size
<ComponentPreview name="p-button-9" />
### Large Size
<ComponentPreview name="p-button-10" />
### Extra-large Size
<ComponentPreview name="p-button-11" />
### Disabled
<ComponentPreview name="p-button-12" />
### Icon
<ComponentPreview name="p-button-13" />
### Icon Small Size
<ComponentPreview name="p-button-14" />
### Icon Large Size
<ComponentPreview name="p-button-15" />
### With Icon
<ComponentPreview name="p-button-16" />
### With Link
<ComponentPreview name="p-button-17" />
### Loading
<ComponentPreview name="p-button-18" />