---
title: "Compose items from parts"
description: "Build with a root and named parts, style any part by its data-slot, and pass your router's Link through render."
url: https://gelatinui.com/docs/composition
markdown_url: https://gelatinui.com/docs/composition.md
docs_index: https://gelatinui.com/docs/llms.txt
prompt: "Read https://gelatinui.com/docs/composition.md. Check each Gelatin UI component in this project against its three rules, and fix each break. The rules: parts sit inside their root, styles go on a part or its slot, and links come in through render. Done when no component breaks a rule."
---

> Docs index: https://gelatinui.com/docs/llms.txt

# Compose items from parts

> Build with a root and named parts, style any part by its data-slot, and pass your router's Link through render.

Every Gelatin UI component has the same shape: a root and named parts. Learn the three rules below once, and you can use and change any component.

## One root, named parts

A component is a root and the parts you place inside it. The root keeps the state. Each part draws one piece. If you leave a part out, it does not show.

```tsx
<Frame>
  <FrameHeader>
    <FrameTitle>Invoices</FrameTitle>
    <FrameDescription>Paid in 2026</FrameDescription>
  </FrameHeader>
  <FramePanel>
    <InvoiceList />
  </FramePanel>
  <FrameFooter>3 invoices</FrameFooter>
</Frame>
```

Put each part inside its own root. Text and structure come in as parts and children, not as props.

## Style a part by its slot

Every part has a `data-slot` attribute. You have two ways to style a part:

| To style               | Do this                                     |
| ---------------------- | ------------------------------------------- |
| One part               | Give that part a `className`.               |
| Every part of one kind | Set a `*:data-[slot=…]:` class on the root. |

```tsx
// One part: its className merges with the part's own classes.
<FramePanel className="p-6">…</FramePanel>

// Every panel of this frame: style the slot from the root.
<Frame className="*:data-[slot=frame-panel]:p-6">…</Frame>
```

- **Your class wins.** Your `className` merges with the classes of the part, and yours comes last.
- **The slot name comes from the part name.** `FramePanel` is `frame-panel`, and `FrameFooter` is `frame-footer`.
- **Other props reach the element.** An `id`, `aria-*` and `data-*` attributes, and event handlers pass through.

## Bring your own link

A part that can be a link takes a `render` prop. Pass the `Link` of your router to it. The part keeps its classes and state, and the component ships no router code. A Button that renders a link also needs `nativeButton={false}`.

### TanStack Router

```tsx
import { Link } from "@tanstack/react-router";

<Button nativeButton={false} render={<Link to="/pricing" />}>
  See pricing
</Button>;
```

### Next.js

```tsx
import Link from "next/link";

<Button nativeButton={false} render={<Link href="/pricing" />}>
  See pricing
</Button>;
```

### React Router

```tsx
import { Link } from "react-router";

<Button nativeButton={false} render={<Link to="/pricing" />}>
  See pricing
</Button>;
```

Our components import no router. So they work the same way in Vite, Next.js, and TanStack Start.

## Next steps

- [Install the agent skill](https://gelatinui.com/docs/agent-skill.md): teach your agent these rules once.
- [Get a newer version](https://gelatinui.com/docs/updates.md): Gelatin UI is in alpha, so a newer version can break your code.
