# Slot

Merges attributes onto a single child without adding a DOM wrapper.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

<DocsBaseSwitcher base="web" component="slot" />

<ComponentPreview name="slot" title="slot.tsx">
<SlotDemo />
</ComponentPreview>

Slot clones one child element and merges its attributes onto that element, allowing a wrapper to add styles and behavior without adding another DOM node.

## Installation [#installation]

<CodeTabs>
<TabsList>
<TabsTrigger value="cli">
Command
</TabsTrigger>

<TabsTrigger value="manual">
Manual
</TabsTrigger>
</TabsList>

<TabsContent value="cli">
```bash
npx frakment add slot
```
</TabsContent>

<TabsContent value="manual">
<Steps>
<Step>
Copy and paste the following code into your project.
</Step>

<ComponentSource name="slot" title="components/ui/slot.tsx" />

<Step>
Update the import paths to match your project setup.
</Step>
</Steps>
</TabsContent>
</CodeTabs>

## Usage [#usage]

<ComponentPreview name="slot-demo" title="slot-demo.tsx" src="examples/slot-demo.tsx">
<SlotDemo />
</ComponentPreview>

Pass one element as `children`; Slot applies its attributes to that element.

```tsx
import { Slot } from "@/components/ui/slot";

<Slot className="rounded-md bg-primary px-4 py-2 text-primary-foreground">
  <a href="/docs/getting-started">Open documentation</a>
</Slot>
```

## API [#api]

### Slot [#slot]

Slot accepts standard `React.HTMLAttributes<HTMLElement>` and a single React element as `children`.

<PropsTable rows={[{"name":"children","type":"React.ReactNode","description":"A valid React element to clone; Slot renders null when it is not valid."},{"name":"className","type":"string","description":"Combines the Slot class before the child's class."},{"name":"style","type":"React.CSSProperties","description":"Merges styles, with the child's values taking precedence."},{"name":"ref","type":"React.Ref<HTMLElement>","description":"Merges the Slot ref with the child's ref."}]} />

Other child props override matching Slot props. When both elements provide the same event handler, the child's handler runs before the Slot handler.