Skip to content
Gelatin UIAlpha

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.

How items work · step 1 of 3 · 2 min read

Prompt for your agent

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.

Your agent reads /docs/composition.md: the same text as this page, as Markdown.

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

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 styleDo this
One partGive that part a className.
Every part of one kindSet a *:data-[slot=…]: class on the root.
TSX
  • 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.

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

Next.js

TSX

React Router

TSX

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

Next steps