Build your component library
This topic takes your React components from your repo to tiles on the Components tab that authors can drag, bind and style. Bring your own components for everything that makes your site yours. Studio's built-in components fill the gaps. If you haven't yet, read Your components in Studio for what registration does and what stays yours.
Every page in this topic uses one example, the team blog.
- Content. The Blog post content type
blog_post, whose entries live under/blog. Its entry AI 101 is at/blog/ai-101. - Components.
BlogHero, insrc/components/BlogHero.tsx, with the propstitle,summaryandimage.Avatar, with the propssrcandsize, andByline, with the proptext.Stack, with the propsdirectionandgapand the slotchildren.Avatar,BylineandStacksit inside the Author card section, which is linked to theauthor_cardglobal field. Authors build the card from them in Studio, so it isn't registered as one component. - Groups.
BlogHerogoes inBlog · Componentson the Components tab. The atomic pieces,AvatarandByline, go inBlog · Elements, and the layout componentStackgoes inBlog · Layout. - A second template, only where a page needs one. Featured post, at
/blog/featured.
Check what Studio already ships
Studio ships 19 components, such as Header, Image, Button and Repeater. Before you build a heading or an image component, check Built-in components. Build your own when a built-in doesn't match your design.
The order to build in
- From a design to components. Decide what to register, and what not to.
- Component shape checklist. Check that each component can be bound, selected and styled.
- Register a component. Make it a tile on the Components tab, and check it works.
- Component schema: props, types and defaults. Look up every prop type and option.
Then refine, when you need to.
- Group components and add thumbnails, so authors find your tiles.
- Lazy-load components, so heavy components don't slow the first load.
- Share state between components, such as a value one component sets and another reads.
- Render rich text and embedded entries.
Pick your path
- You're starting from a Figma design. Go to From a design to components.
- You already have a React component library. Go to Register a component. To have the CLI write the registration code for you, use
studio:component:registerfrom CLI commands. - Your components already register, but authors can't find them on the Components tab. Go to Group components and add thumbnails.
Where components go next
- Build sections from your components: Build sections.
- Give a component's props values from content: Bind a component.
- Let authors style your components with your design tokens: Make your components styleable.