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
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.
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:
- Your class wins. Your
classNamemerges with the classes of the part, and yours comes last. - The slot name comes from the part name.
FramePanelisframe-panel, andFrameFooterisframe-footer. - Other props reach the element. An
id,aria-*anddata-*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
Next.js
React Router
Our components import no router. So they work the same way in Vite, Next.js, and TanStack Start.
Next steps
- Install the agent skill: teach your agent these rules once.
- Get a newer version: Gelatin UI is in alpha, so a newer version can break your code.