Tutorial: Create and share components in Penpot

Learn about creating components and libraries of shared components in Penpot for your team’s design system.

Tutorial: Create and share components in Penpot

In Penpot, you can make any object or group of objects into a reusable component, making it easier to share and reuse a pattern in your design. 

When you update the main component, any changes will be reflected in any copy (also known as “instance”) of that component used across your file, saving you time and effort.

0:00
/0:15

If your component is part of a shared library, Penpot will update its instances across your team’s projects.

A checkbox main component with placeholder label text and a component instance with Remember me as the label text.
A checkbox and label is an example of a simple component you’ll likely reuse across your designs.

You can override the component instance’s label with different text depending on where you’re using it.

Components save you the time and effort of repetitively creating similar designs. Component libraries are an integral part of design systems as they provide a collection of patterns that you can pull into your projects. With more consistent patterns, you can improve the user experience and the branding across your design projects.

Are you looking for how to use components and shared libraries in your Penpot projects? Check out my last tutorial for:

Create components

A main component is your component’s source of truth. You can create a main component by right-clicking an object or group and choosing Create component or using the keyboard shortcut.

0:00
/0:04
A main checkbox component selected on the canvas. In the layers panel, the layer name is checkbox and it has a double diamond icon.
You can identify a main component by its layer icon of two nested diamonds.

Any object on the canvas can be a component unless it already contains a main component.

The checkbox component in the Local library section of the Assets panel.
Once you’ve created a component, you can find it in the Assets panel in the left sidebar.

By default, your component will have the same name as the layer you used to create it, but you can rename the component by renaming the main component’s layer.

Penpot won’t stop you from creating multiple components with the same name, so consider your component names carefully if you don’t want to confuse yourself or your teammates in the future!

0:00
/0:19

You can switch between the thumbnail and list views in the Assets panel to make it easier to read longer component names. You can also group components to make them easier to organize and browse.

Component instances

Once you’ve created a component, you can use instances of that component in your design by dragging it from the Assets panel or copy-pasting the main component. Each component instance will have the same layer name as the main component, but you can rename the layer if you want.

You can tell a main component and its instance (or copy) apart by their layer icons. The main component has an icon of two nested diamonds; its instances have an icon of one diamond.

When you right-click a main component, you have options to:

When you right-click an instance of a component, you have options to:

  • Show the main component in the viewport.
  • Detach the instance so it is no longer connected to the main component.
  • Reset overrides to reset the instance to match the main component.
  • Update main component to change the main component to match the instance.

Nesting components

You can nest component instances inside main components, which is essential for more complex patterns and maintaining design systems. For example, in my checkbox example, the checkbox and label are components, and the checkbox itself could be a component, too.

A checkbox component nested inside a checkbox and label component.
You can nest components many levels deep if the parent component is not a main component.

Layout components

You can even save Flex and Grid layouts as components. Read more about layout components in my tutorial, and download a template full of layout component examples.

Component variants

If your component instance has a specific style or state you want to reuse elsewhere in your design, make it into its own reusable component variant.

I could create a variant of my checkbox with a cross icon instead of a check icon.

After you’ve created a new variation of your component, you can save your changes:

  1. Detach the component instance.
  2. Create a new component to save your changes.
  3. Give your new component a distinct name to help you find it later. (More on naming and organizing components below!)

Component variants work well with component swapping to switch between variants of the same component quickly.

Organize components

When working in a team, it’s helpful to provide documentation so your teammates understand the use cases and intention behind your component.

Naming components

Naming components is difficult. The number one rule is ensuring your whole team agrees on a shared language that helps everyone name new components and find existing components.

Here are a few tips I’ve found that help me when naming my Penpot components:

  • Keep the names descriptive but concise and readable. For example, avatar is more specific than round picture.
  • Choose names based on meaning rather than visual features such as color or pixel size. If you change the visual design later, you don’t want the component name to lose relevance. For example, blue button won’t age as well as primary button.
  • Create naming conventions by reusing the same keywords for related components. For example, card overview hovered and link underlined hovered makes it easy to find all components with a hovered state.
  • Use words separated by spaces to help you easily find the component when you search using a keyword. For example, check icon is easier to find than check-icon.
  • If you repeatedly use the same keyword, it might be easier to create a group of components with that shared keyword as the name.
  • Group components to make them easier to find, browse, and load faster during browsing.
Right-clicking a component in the Assets panel brings up a menu of options to rename, group, or delete.
After you’ve named your component, you can change its name by changing the main component’s layer name.

Alternatively, you can find the component in the Assets panel and right-click it to rename, group, or delete the component.

Grouping components

You can group your Assets, including components, into groups and sub-groups using slashes in the asset name. For example, a component named checkbox / active / enabled will appear as a component named enabled inside the active group inside the checkbox group. You can nest groups as deeply as you like.

A component called checkbox / active / enabled which appears as an enabled component in the active group, inside the checkbox group.
You can ungroup groups and rename components and groups from the Assets panel.

Component swapping

Nested components pair nicely with component swapping to switch between component variants. For example, I could nest an icon component inside the checkbox component and then quickly swap the check icon out for the cross icon.

Searching for close in the components swap menu brings up three icons with closed keywords.
You can also browse or search for components from the Swap component menu.

Annotating components

Annotations can also help you remind your future self how to use that component! You can do this from the Design panel:

  1. Select your component on the canvas.
  2. From the component menu in the Design panel, choose Create annotation
  3. Enter your annotation text (maximum 300 characters.)
  4. Use the check icon button to save your annotation text.
0:00
/0:12

Once you’ve added an annotation to your component, it is displayed in the Design and Inspect panels whenever the component is selected.

When you select the main component or a component instance in Inspect mode, the annotation is displayed at the end of the right sidebar.

Publish your components as a shared library for your team

Our user guide explains how to publish shared libraries with your team.  You can also read my tutorial on shared icon libraries for how to:

A component library and organized assets are a great starting point for your design system with Penpot. With a free Penpot account with unlimited seats, you can share your design patterns with your team today.