📚 Add doc for variants (#7258)
BIN
docs/img/variants/01-variants-create.webp
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
docs/img/variants/02-variants-created.webp
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
docs/img/variants/03-variants-property-add.webp
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
docs/img/variants/04-variants-properties-edit.webp
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
docs/img/variants/05-variants-use.webp
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
docs/img/variants/06-variants-combine.webp
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
docs/img/variants/variants-connections-conditions.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
@@ -7,19 +7,20 @@ desc: Streamline your design workflow with Penpot's Components guide! Learn to c
|
|||||||
<p class="main-paragraph">Speed your workflow with the reusable power of components.</p>
|
<p class="main-paragraph">Speed your workflow with the reusable power of components.</p>
|
||||||
<p>A component is an object or group of objects that can be reused multiple times across files. This can help you maintain consistency across a group of designs.</p>
|
<p>A component is an object or group of objects that can be reused multiple times across files. This can help you maintain consistency across a group of designs.</p>
|
||||||
|
|
||||||
<p>A component has two parts:</p>
|
<h2 id="components-basics">Components basics</h2>
|
||||||
|
<p>A component consists of two elements:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>Main component</strong>: This is the source of truth, a single object in which the main properties of the component are defined.</li>
|
<li><strong>Main component</strong>: The original source of truth. It defines the core properties of the component.</li>
|
||||||
<li><strong>Component copy</strong> (also known as instance): These are duplicates of Main components that inherit its properties.</li>
|
<li><strong>Component copy</strong> (also known as instance): A duplicate of the main component that inherits its properties.</li>
|
||||||
</ol>
|
</ul>
|
||||||
<figure>
|
<figure>
|
||||||
<img src="/img/components/components-main-copy.webp" alt="Components main and copy" />
|
<img src="/img/components/components-main-copy.webp" alt="Components main and copy" />
|
||||||
<figcaption>Mains and copies have different icons. Mains also have a title header at the viewport.</figcaption>
|
<figcaption>Mains and copies have different icons. Mains also have a title header at the viewport.</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
<p>All component copies used in a file are linked in a way that updates made to the Main component can reflect in their component copies. You can override properties for component copies, so that you can manage singularities while maintaining properties in common.</p>
|
<p>All component copies used in a file are linked in a way that updates made to the Main component can reflect in their component copies. You can override properties for component copies, so that you can manage singularities while maintaining properties in common.</p>
|
||||||
|
|
||||||
<h2 id="component-create">Creating components</h2>
|
<h3 id="component-create">Create components</h3>
|
||||||
<h3>Create a component</h3>
|
<h4>Create a component</h4>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Select an object or a group of them.</li>
|
<li>Select an object or a group of them.</li>
|
||||||
<li>Press <kbd>Ctrl</kbd> + <kbd>K</kbd> or right click and select the option “Create component” at the object menu.</li>
|
<li>Press <kbd>Ctrl</kbd> + <kbd>K</kbd> or right click and select the option “Create component” at the object menu.</li>
|
||||||
@@ -30,10 +31,10 @@ desc: Streamline your design workflow with Penpot's Components guide! Learn to c
|
|||||||
</video>
|
</video>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h3>Duplicate a component</h3>
|
<h4>Duplicate a component</h4>
|
||||||
<p>You can duplicate a component <a href="/user-guide/layer-basics/#duplicating-layers">the same way</a> you can duplicate any other layer. When duplicating a component, you are creating a component copy that will be linked to its main component.</p>
|
<p>You can duplicate a component <a href="/user-guide/layer-basics/#duplicating-layers">the same way</a> you can duplicate any other layer. When duplicating a component, you are creating a component copy that will be linked to its main component.</p>
|
||||||
|
|
||||||
<h3>Duplicate as main component</h3>
|
<h4>Duplicate as main component</h4>
|
||||||
<p>You can duplicate a component as a new main component from the assets sidebar. Just select the component at the library, open the menu with right click and select the option "Duplicate main".</p>
|
<p>You can duplicate a component as a new main component from the assets sidebar. Just select the component at the library, open the menu with right click and select the option "Duplicate main".</p>
|
||||||
<figure>
|
<figure>
|
||||||
<video title="Duplicate main component" muted="" playsinline="" controls="" width="auto" poster="/img/components/components-duplicate-main.webp" height="auto">
|
<video title="Duplicate main component" muted="" playsinline="" controls="" width="auto" poster="/img/components/components-duplicate-main.webp" height="auto">
|
||||||
@@ -41,7 +42,7 @@ desc: Streamline your design workflow with Penpot's Components guide! Learn to c
|
|||||||
</video>
|
</video>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h3>Delete a main component</h3>
|
<h4>Delete a main component</h4>
|
||||||
<p>You can delete main components and its copies anytime <a href="/user-guide/layer-basics/#deleting-layers">the same way</a> you can delete any other layer.</p>
|
<p>You can delete main components and its copies anytime <a href="/user-guide/layer-basics/#deleting-layers">the same way</a> you can delete any other layer.</p>
|
||||||
<p>Deleting a main component at the viewport means deleting it at the assets library and viceversa, so be careful!</p>
|
<p>Deleting a main component at the viewport means deleting it at the assets library and viceversa, so be careful!</p>
|
||||||
<figure>
|
<figure>
|
||||||
@@ -50,7 +51,7 @@ desc: Streamline your design workflow with Penpot's Components guide! Learn to c
|
|||||||
</video>
|
</video>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h3>Restore a main component</h3>
|
<h4>Restore a main component</h4>
|
||||||
<p>If a main component has been deleted and you have access to a copy of it, you can use the copy to restore its main. There are two ways to do it:</p>
|
<p>If a main component has been deleted and you have access to a copy of it, you can use the copy to restore its main. There are two ways to do it:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>From the <strong>viewport menu</strong>: Select the component copy of a deleted main component, right click and press the option "Restore main component".</li>
|
<li>From the <strong>viewport menu</strong>: Select the component copy of a deleted main component, right click and press the option "Restore main component".</li>
|
||||||
@@ -61,11 +62,36 @@ desc: Streamline your design workflow with Penpot's Components guide! Learn to c
|
|||||||
<figcaption>Mains and copies have different icons. Mains also have a title header at the viewport.</figcaption>
|
<figcaption>Mains and copies have different icons. Mains also have a title header at the viewport.</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h2 id="component-group">Group components</h2>
|
<h3 id="component-find">Find main components</h3>
|
||||||
<h3>Create component groups</h3>
|
<p>Where's my component? There are ways to find main components at the assets panel and at the design viewport.</p>
|
||||||
|
|
||||||
|
<h4>Find a main component at the assets panel</h4>
|
||||||
|
<p>Select a main component at the viewport and then press "Show in assets panel" at the options of the right sidebar.</p>
|
||||||
|
<figure>
|
||||||
|
<video title="Show main component in the assets library" muted="" playsinline="" controls="" width="100%" poster="/img/components/components-show-asset.webp" height="auto">
|
||||||
|
<source src="/img/components/components-show-asset.mp4" type="video/mp4">
|
||||||
|
</video>
|
||||||
|
</figure>
|
||||||
|
|
||||||
|
<h4>Find a main component at the viewport</h4>
|
||||||
|
<p>Select a component copy and then press "Show main component" at the viewport menu or the right sidebar menu.</p>
|
||||||
|
<figure>
|
||||||
|
<video title="Show main component" muted="" playsinline="" controls="" width="100%" poster="/img/components/components-show-main.webp" height="auto">
|
||||||
|
<source src="/img/components/components-show-main.mp4" type="video/mp4">
|
||||||
|
</video>
|
||||||
|
</figure>
|
||||||
|
|
||||||
|
<h3 id="component-main-components-page">Main components page</h3>
|
||||||
|
<p>If you find a page at a file called "Main components" this will probably mean that the file had assets with the previous components system and has been migrated to the current components system. The previous system didn't have the components as layers at the design file, only at the assets library, so when migrating a file to the new version Penpot automatically creates a page where to place all the components, grouping them using the library groups structure.</p>
|
||||||
|
<figure>
|
||||||
|
<img src="/img/components/components-page-main.webp" alt="Main components page" />
|
||||||
|
</figure>
|
||||||
|
|
||||||
|
<h2 id="working-with-components">Working with components</h2>
|
||||||
|
<h3 id="component-group">Group components</h3>
|
||||||
<p>At the Components section from the Assets library, there are two ways to create groups in a components library.</p>
|
<p>At the Components section from the Assets library, there are two ways to create groups in a components library.</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li><strong>Using slashes (/):</strong> Select one component and rename it as follows: "FOLDER NAME/COMPONENT NAME". For example, "Buttons/Alert Button".</li>
|
<li><strong>Using slashes (/):</strong> Select one component and rename it as follows: "<i>FOLDER NAME/COMPONENT NAME</i>". For example, "<i>Buttons/Alert Button</i>".</li>
|
||||||
<li><strong>Using the "Group" option:</strong> Select one or more components at the Assets library, right click to show the menu and then select "Group".</li>
|
<li><strong>Using the "Group" option:</strong> Select one or more components at the Assets library, right click to show the menu and then select "Group".</li>
|
||||||
</ol>
|
</ol>
|
||||||
<figure>
|
<figure>
|
||||||
@@ -74,10 +100,10 @@ desc: Streamline your design workflow with Penpot's Components guide! Learn to c
|
|||||||
</video>
|
</video>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h3>Ungroup components</h3>
|
<h4>Ungroup components</h4>
|
||||||
<p>You can ungroup the components the same ways you can group them, via the menu option ("Ungroup" in this case) or renaming them.</p>
|
<p>You can ungroup the components the same ways you can group them, via the menu option ("Ungroup" in this case) or renaming them.</p>
|
||||||
|
|
||||||
<h3>Drag components to groups</h3>
|
<h4>Drag components to groups</h4>
|
||||||
<p>One very direct way to move components between groups at the assets library is by dragging them.</p>
|
<p>One very direct way to move components between groups at the assets library is by dragging them.</p>
|
||||||
<figure>
|
<figure>
|
||||||
<video title="Drag components" muted="" playsinline="" controls="" width="auto" poster="/img/components/components-drag.webp" height="auto">
|
<video title="Drag components" muted="" playsinline="" controls="" width="auto" poster="/img/components/components-drag.webp" height="auto">
|
||||||
@@ -85,26 +111,40 @@ desc: Streamline your design workflow with Penpot's Components guide! Learn to c
|
|||||||
</video>
|
</video>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h2 id="component-find">Find components</h2>
|
<h3 id="component-detach">Detach components</h3>
|
||||||
<p>Where's my component? There are ways to find some components at the assets panel and at the design viewport.</p>
|
<p>Detach a component copy to unlink it from its Main component and transform it into a group layer. Press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>K</kbd> or right click and select the option “Detach instance” at the component menu.</p>
|
||||||
|
<p>You can also detach components in bulk by selecting several components and performing the same action.</p>
|
||||||
|
|
||||||
<h3>Find a main component at the assets panel</h3>
|
<h3 id="component-annotate">Annotate components</h3>
|
||||||
<p>Select a main component at the viewport and then press "Show in assets panel" at the options of the right sidebar.</p>
|
<p>You can add text annotations to main components. The annotations are shown in every component copy. It is extremely useful to attach specifications that can be read at each component copy.</p>
|
||||||
<figure>
|
<figure>
|
||||||
<video title="Show main component in the assets library" muted="" playsinline="" controls="" width="100%" poster="/img/components/components-show-asset.webp" height="auto">
|
<video title="Annotating components at Penpot" muted="" playsinline="" controls="" width="auto" poster="/img/components/components-annotation.webp" height="auto">
|
||||||
<source src="/img/components/components-show-asset.mp4" type="video/mp4">
|
<source src="/img/components/components-annotation.mp4" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h3>Find a main component at the viewport</h3>
|
<p>The annotations are also shown at the <a href="/user-guide/inspect">Inspect tab</a>, as another option to improve communication between designers and developers.</p>
|
||||||
<p>Select a component copy and then press "Show main component" at the viewport menu or the right sidebar menu.</p>
|
|
||||||
<figure>
|
<figure>
|
||||||
<video title="Show main component" muted="" playsinline="" controls="" width="100%" poster="/img/components/components-show-main.webp" height="auto">
|
<img src="/img/components/components-annotations-inspect.webp" alt="Annotations at inspect tab" />
|
||||||
<source src="/img/components/components-show-main.mp4" type="video/mp4">
|
</figure>
|
||||||
|
|
||||||
|
<h2 id="component-overrides-relationships">Component Overrides & Relationships</h2>
|
||||||
|
<h3 id="component-overrides">Component overrides</h3>
|
||||||
|
<p>Main components represent the more generic information of an element in a design system. You will usually need to change specific things (like a text, a color or an icon) in a component while maintaining the inheritance of the rest of it properties. Component overrides allows you to do that in Penpot.</p>
|
||||||
|
<p>Overrides are modifications made in a specific copy that are not in its main component. With overrides you can keep changes at the component copies while maintaining synchronization with the Main component.</p>
|
||||||
|
<figure>
|
||||||
|
<img src="/img/components/components-overrides.webp" alt="Components overrides" />
|
||||||
|
</figure>
|
||||||
|
|
||||||
|
<h4>Reset overrides</h4>
|
||||||
|
<p>Right click and select the option “Reset overrides” at the component menu to get it to the state of the Main component.</p>
|
||||||
|
<figure>
|
||||||
|
<video title="Reset component overrides" muted="" playsinline="" controls="" width="auto" poster="/img/components/components-reset-overrides.webp" height="auto">
|
||||||
|
<source src="/img/components/components-reset-overrides.mp4" type="video/mp4">
|
||||||
</video>
|
</video>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h2 id="component-update">Update main component from copy</h2>
|
<h3 id="component-update">Update main from copies</h3>
|
||||||
<p>You can push changes made at a component copy to a main component:</p>
|
<p>You can push changes made at a component copy to a main component:</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Select a component copy that has changes that override one or more properties of its main component.</li>
|
<li>Select a component copy that has changes that override one or more properties of its main component.</li>
|
||||||
@@ -118,27 +158,7 @@ desc: Streamline your design workflow with Penpot's Components guide! Learn to c
|
|||||||
<img src="/img/components/components-update-shared.webp" alt="Prompt shown to update a main component that is in a shared library" />
|
<img src="/img/components/components-update-shared.webp" alt="Prompt shown to update a main component that is in a shared library" />
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h2 id="component-overrides">Component overrides</h2>
|
<h3 id="component-swap">Swap components</h3>
|
||||||
<p>Main components represent the more generic information of an element in a design system. You will usually need to change specific things (like a text, a color or an icon) in a component while maintaining the inheritance of the rest of it properties. Component overrides allows you to do that in Penpot.</p>
|
|
||||||
<p>Overrides are modifications made in a specific copy that are not in its main component. With overrides you can keep changes at the component copies while maintaining synchronization with the Main component.</p>
|
|
||||||
<figure>
|
|
||||||
<img src="/img/components/components-overrides.webp" alt="Components overrides" />
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<h3>Reset overrides</h3>
|
|
||||||
<p>Right click and select the option “Reset overrides” at the component menu to get it to the state of the Main component.</p>
|
|
||||||
<figure>
|
|
||||||
<video title="Reset component overrides" muted="" playsinline="" controls="" width="auto" poster="/img/components/components-reset-overrides.webp" height="auto">
|
|
||||||
<source src="/img/components/components-reset-overrides.mp4" type="video/mp4">
|
|
||||||
</video>
|
|
||||||
</figure>
|
|
||||||
|
|
||||||
<h2 id="component-detach">Detach component</h2>
|
|
||||||
<p>Detach a component copy to unlink it from its Main component and transform it into a group layer. Press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>K</kbd> or right click and select the option “Detach instance” at the component menu.</p>
|
|
||||||
<p>You can also detach components in bulk by selecting several components and performing the same action.</p>
|
|
||||||
|
|
||||||
|
|
||||||
<h2 id="component-swap">Swap components</h2>
|
|
||||||
<p>Penpot allows you to easily substitute component copies with other component copies.</p>
|
<p>Penpot allows you to easily substitute component copies with other component copies.</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Select a component <strong>copy</strong>. You can not swap main components.</li>
|
<li>Select a component <strong>copy</strong>. You can not swap main components.</li>
|
||||||
@@ -153,21 +173,166 @@ desc: Streamline your design workflow with Penpot's Components guide! Learn to c
|
|||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
|
|
||||||
<h2 id="component-annotate">Annotate components</h2>
|
|
||||||
<p>You can add text annotations to main components. The annotations are shown in every component copy. It is extremely useful to attach specifications that can be read at each component copy.</p>
|
<h2 id="component-variants">Component Variants</h2>
|
||||||
|
<p>Variants allow you to group similar components, such as buttons, icons, or toggles, into a single, customizable component. Rather than navigating through separate components for every possible state, size, or style, you can manage them all from one unified component using clearly defined properties.</p>
|
||||||
|
<p>Imagine a single button component that can switch between primary and secondary styles, active and disabled states, and small to large sizes. Useful, right? That’s the power of Variants.</p>
|
||||||
|
|
||||||
|
<h3 id="component-variants-why-are-variants-important">Why are Variants Important?</h3>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Cleaner libraries</strong><br>
|
||||||
|
Keep related designs organized in the Design viewport, Layers panel, and swap menu. Variants streamline your components into tidy, manageable sets, allowing you to retain overrides when switching between them.
|
||||||
|
</li>
|
||||||
|
<li><strong>Faster design workflows</strong><br>
|
||||||
|
Make it easier to find and select the right version by quickly switching between states or styles using simple property controls.
|
||||||
|
</li>
|
||||||
|
<li><strong>Better team collaboration</strong><br>
|
||||||
|
With variants, you can match the way states are handled in code, helping designers and developers stay in sync, fostering better collaboration between design and development teams.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<figure>
|
<figure>
|
||||||
<video title="Annotating components at Penpot" muted="" playsinline="" controls="" width="auto" poster="/img/components/components-annotation.webp" height="auto">
|
<iframe
|
||||||
<source src="/img/components/components-annotation.mp4" type="video/mp4">
|
width="672px"
|
||||||
</video>
|
height="378px"
|
||||||
|
src="https://www.youtube.com/embed/3iWc-dwjA30?start=6"
|
||||||
|
title="Penpot Variants Demo"
|
||||||
|
frameborder="0"
|
||||||
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||||
|
allowfullscreen>
|
||||||
|
</iframe>
|
||||||
|
<figcaption>Penpot – Variants sneak peek</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<p>The annotations are also shown at the <a href="/user-guide/inspect">Inspect tab</a>, as another option to improve communication between designers and developers.</p>
|
<h3 id="component-understanding-variants-properties-and-values">Understanding variants: properties and values</h3>
|
||||||
|
<p>A component’s variants are organized by properties and their values.</p>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Properties</strong> define the dimensions that distinguish your variants (for example: <em>Color</em>, <em>Size</em>, <em>State</em>).</li>
|
||||||
|
<li><strong>Values</strong> are the specific options within a property (for example: <em>Primary/Secondary</em>, <em>Small/Large, Default/Hover/Pressed</em>)</li>
|
||||||
|
</ul>
|
||||||
|
<p>Each variant is simply one unique combination of values across all properties (for example, <code class="language-js">Color=Primary + Size=Small + State=Hover</code>).</p>
|
||||||
|
<p>Variants must have at least one property, and property values should be kept consistent to make switching predictable and to preserve overrides across connected layers.</p>
|
||||||
|
|
||||||
|
<h3 id="component-create-and-modify-variants">Create and modify variants</h3>
|
||||||
|
|
||||||
|
<h4 id="component-create-variants">Create variants</h4>
|
||||||
|
<p>You can create variants from an existing component or from another variant:</p>
|
||||||
|
<ul>
|
||||||
|
<li><strong>From a component:</strong> Press Ctrl + K or right-click and select the menu option <strong>Create variant</strong>.</li>
|
||||||
|
<li><strong>From a variant:</strong> Select the variant and press Ctrl + K or right-click and select the menu option <strong>Create variant</strong>.</li>
|
||||||
|
<li><strong>By dragging:</strong> Drag a main component into an existing component with variants to add it as a new variant.</li>
|
||||||
|
<li><strong>From the Design tab</strong> (right sidebar): Select a component or a variant, open the context menu next to the component name and select the menu option <strong>Create variant</strong>.</li>
|
||||||
|
</ul>
|
||||||
<figure>
|
<figure>
|
||||||
<img src="/img/components/components-annotations-inspect.webp" alt="Annotations at inspect tab" />
|
<img src="/img/variants/01-variants-create.webp" alt="Variants creation button" />
|
||||||
|
</figure>
|
||||||
|
<p><strong>When a variant is created:</strong></p>
|
||||||
|
<ul>
|
||||||
|
<li>It appears next to the original in a dedicated variant area (by default in horizontal flex layout).</li>
|
||||||
|
<li>Shared layers between variants are automatically connected (<a href="#component-understanding-overrides">connection conditions</a>) so that overrides can be preserved.</li>
|
||||||
|
<li>Variants are named using their property values (e.g., <em>Primary / Hover</em>).</li>
|
||||||
|
</ul>
|
||||||
|
<figure>
|
||||||
|
<img src="/img/variants/02-variants-created.webp" alt="Variant created" />
|
||||||
</figure>
|
</figure>
|
||||||
|
|
||||||
<h2 id="component-main-components-page">Main components page</h2>
|
<h4 id="component-manage-variant-properties">Manage variant properties</h4>
|
||||||
<p>If you find a page at a file called "Main components" this will probably mean that the file had assets with the previous components system and has been migrated to the current components system. The previous system didn't have the components as layers at the design file, only at the assets library, so when migrating a file to the new version Penpot automatically creates a page where to place all the components, grouping them using the library groups structure.</p>
|
<p>Properties are key to defining and differentiating your variants. They appear in the Design tab when a variant or component with variants is selected.</p>
|
||||||
<figure>
|
<figure>
|
||||||
<img src="/img/components/components-page-main.webp" alt="Main components page" />
|
<img src="/img/variants/03-variants-property-add.webp" alt="Add variant property" />
|
||||||
</figure>
|
</figure>
|
||||||
|
<h5>Add new properties</h5>
|
||||||
|
<ul>
|
||||||
|
<li><strong>From the Design tab:</strong> When the component or one of its variants is selected, you can add a new property via a menu. This property will be added to all existing variants with a default value (e.g., <em>Value 1</em>).</li>
|
||||||
|
<li><strong>From the Layers panel:</strong> using the formula <code class="language-js">[property_name]=[value]</code>.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h5>Edit properties</h5>
|
||||||
|
<ul>
|
||||||
|
<li><strong>From the Design tab:</strong> Select a component or a variant, then click on the property name to edit its name and/or value.</li>
|
||||||
|
<li><strong>From the Layers panel:</strong> using the formula <code class="language-js">[property_name]=[value]</code>.</li>
|
||||||
|
</ul>
|
||||||
|
<figure>
|
||||||
|
<img src="/img/variants/04-variants-properties-edit.webp" alt="Edit variant property" />
|
||||||
|
</figure>
|
||||||
|
|
||||||
|
<h5>Delete properties</h5>
|
||||||
|
<ul>
|
||||||
|
<li><strong>From the Design tab:</strong> Select the main component (not an individual variant) and press the minus button next to the property.</li>
|
||||||
|
<li><strong>From the Layers panel:</strong> You can delete a property by editing the names of all variants so that none of them contain that property in their formula.</li>
|
||||||
|
</ul>
|
||||||
|
<p class="advice">Variants must have at least one property. You can’t delete the last one.</p>
|
||||||
|
<p>When <strong>multiple variants are selected</strong>, the Design tab will show all their properties and values. If a property has different values across the selected variants, it will display “Mixed,” allowing you to override them collectively.</p>
|
||||||
|
|
||||||
|
<h4 id="component-delete-variants">Delete Variants</h4>
|
||||||
|
<ul>
|
||||||
|
<li>Select the variant, press right-click, and select the menu option <strong>Delete</strong>.</li>
|
||||||
|
<li><strong>Dragging</strong> a variant outside its component turns it into an independent component instead of deleting it.</li>
|
||||||
|
</ul>
|
||||||
|
<p class="advice">If you delete the last variant, the entire component is removed.</p>
|
||||||
|
|
||||||
|
<h4 id="component-restore-variants">Restore Variants</h4>
|
||||||
|
<p>If you have a copy of a variant whose original was deleted, you can restore it:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Select the variant copy, press right-click, and select the menu option <strong>Restore variant</strong> (will show if the main component still exists).</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3 id="component-use-variants">Use variants</h3>
|
||||||
|
<p>Once you have created your variants, you can place a copy of a component with variants into your design and then switch between its different versions.</p>
|
||||||
|
|
||||||
|
<h4 id="component-from-the-assets-tab">From the Assets tab</h4>
|
||||||
|
<p>Drag and drop a component with variants from the Assets tab onto the design viewport, just like you would with any other component. Once placed, you can then use its properties in the Design tab to switch to the desired variant.</p>
|
||||||
|
|
||||||
|
<h4 id="component-from-the-design-tab">From the Design tab</h4>
|
||||||
|
<p>When a variant is selected:</p>
|
||||||
|
<ul>
|
||||||
|
<li>You’ll see its properties and values.</li>
|
||||||
|
<li>Change one or more property values to switch to another variant.</li>
|
||||||
|
<li>If your chosen combination doesn’t exist, Penpot will suggest the closest match.</li>
|
||||||
|
</ul>
|
||||||
|
<figure>
|
||||||
|
<img src="/img/variants/05-variants-use.webp" alt="Using variants" />
|
||||||
|
</figure>
|
||||||
|
|
||||||
|
<h4 id="component-understanding-overrides">Understanding overrides</h4>
|
||||||
|
<p>A key benefit of variants is the ability to <strong>preserve overrides when you switch between them</strong>. An override is a specific change you make to a component instance that diverges from its original definition (e.g., changing text content or a specific color).</p>
|
||||||
|
<p>Layers between variants are considered connected if they:</p>
|
||||||
|
<ol>
|
||||||
|
<li>Share the <strong>same name</strong>.</li>
|
||||||
|
<li><strong>Are the same type</strong>. Rectangle, ellipse, paths, and boolean operations count as the same type.</li>
|
||||||
|
<li><strong>Have the same hierarchy level.</strong> Groups, boards, and layouts are considered equivalent.</li>
|
||||||
|
</ol>
|
||||||
|
<figure>
|
||||||
|
<img src="/img/variants/variants-connections-conditions.png" alt="Variants connections conditions" />
|
||||||
|
</figure>
|
||||||
|
<p><strong>Example:</strong> If <code class="language-js">Variant 1</code> has a text layer named <em>label</em> with red color, and you change its content to <em>Click here</em> in an instance, then switch to <code class="language-js">Variant 2</code> (which also has a <em>label</em> text layer), the <em>Click here</em> content will be preserved, and <code class="language-js">Variant 2</code>’s color will be applied.</p>
|
||||||
|
<p><strong>Changing any of these</strong> (e.g., renaming or grouping a layer) breaks the connection, but reverting the change will restore it.</p>
|
||||||
|
|
||||||
|
<h4 id="component-bulk-converting-components-to-variants">Bulk converting components to variants</h4>
|
||||||
|
<p>If you already have multiple related components, you can combine them into a single component with variants:</p>
|
||||||
|
<ul>
|
||||||
|
<li><strong>From Assets tab</strong>: Select components in the same group and right-click → <strong>Combine as variants</strong>.</li>
|
||||||
|
<li><strong>From viewport</strong>: Select multiple components → Right-click → <strong>Combine as variants</strong>.</li>
|
||||||
|
<li><strong>From Design tab</strong>: If conditions are met, a Combine as variants button appears on the component card.</li>
|
||||||
|
</ul>
|
||||||
|
<figure>
|
||||||
|
<img src="/img/variants/06-variants-combine.webp" alt="Combining components as variants" />
|
||||||
|
</figure>
|
||||||
|
<p><strong>Conditions:</strong></p>
|
||||||
|
<ul>
|
||||||
|
<li>Components must be on the same page.</li>
|
||||||
|
<li>Components that already have variants cannot be combined.</li>
|
||||||
|
</ul>
|
||||||
|
<p><strong>When combined:</strong></p>
|
||||||
|
<ul>
|
||||||
|
<li>A variant area is created containing all former components.</li>
|
||||||
|
<li>Property names and values are generated from the component names.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h4 id="component-transforming-variants-back-into-components">Transforming Variants Back into Components</h4>
|
||||||
|
<p>To turn a variant into an independent component:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Drag it outside the variant area (Design viewport or Layers panel).</li>
|
||||||
|
<li>Cut and paste it outside the variant area.</li>
|
||||||
|
</ul>
|
||||||
|
<p>The new component’s name includes the original component name and the variant’s property values.</p>
|
||||||
@@ -263,6 +263,11 @@ desc: Get quickstart tips, shortcuts, and tutorials for Penpot! Learn interface
|
|||||||
<td style="text-align: center;"><kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>K</kbd></td>
|
<td style="text-align: center;"><kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>K</kbd></td>
|
||||||
<td style="text-align: center;"><kbd>⌘</kbd><kbd>⇧</kbd><kbd>K</kbd></td>
|
<td style="text-align: center;"><kbd>⌘</kbd><kbd>⇧</kbd><kbd>K</kbd></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Create Variant</td>
|
||||||
|
<td style="text-align: center;"><kbd>Ctrl</kbd><kbd>K</kbd></td>
|
||||||
|
<td style="text-align: center;"><kbd>⌘</kbd><kbd>K</kbd></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Flip horizontal</td>
|
<td>Flip horizontal</td>
|
||||||
<td style="text-align: center;"><kbd>Ctrl</kbd><kbd>H</kbd></td>
|
<td style="text-align: center;"><kbd>Ctrl</kbd><kbd>H</kbd></td>
|
||||||
|
|||||||