Penpot's unique Flex Layout allows you to create flexible designs that can adapt automatically. Resize, fit, and fill content and containers without the need to do it manually.
To help you learn the fundamentals of Flex Layout here’s a dedicated website where you will find a video tutorial and a playground template.
Flex Layout is based on CSS standards
Penpot's proposal tries to get as close as possible to the final output that we will see on the web. Design and development speak the same language in order to embrace web standards and improve communication between roles. Penpot's Flex Layout is built over Flexbox, a CSS module that provides a more efficient way to lay out, align and distribute space among items in a container. As there are already many comprehensive explations about Flexbox we are not going to write another one. If you are interested we can recommend you to read the one at CSS Tricks.Image from CSS Tricks
Add Flex Layout
You can add Flex Layout to any layer, group, board or a selection including any of these. Once Flex Layout Flex is added the selected elements will be contained into a board with the Flex Layout properties. You have several ways to do this:
- From the Design panel at the right sidebar.
- From the option at the selection menu (right click button).
- Pressing Ctrl/⌘ + A.
Arrange and reorder objects to a Flex Layout
To add an object to a Flex Layout you can just drag it at the position of your choice. You can also create or paste elements like in any regular board.
To reorder elements you can drag them or use the UP/DOWN keystrokes.
Flex Layout properties
You have properties for direction, align, justify, gap, padding, margin and sizing. Those are the same properties that you can use with CSS Flexbox. You can read here detailed explanations about Flexbox properties.
Flex Layout properties:
- Direction: Row, reverse row, column, reverse column.
- Wrap (Direction): Align content start / center / end / space-around / space-between.
- Align items: Start, center, end.
- Justify content: start, center, end, space-between, space-around, space-evenly.
- Gap: Row, column.
- Padding: Top, right, bottom, left.
- Sizing: Fix/fit width, Fix/fit height.
Positioning Flex elements
Static position is the default option for flex elements, meaning that they will be included in the flex flow, using flex properties.
Selecting absolute position will exclude the element from the Flex layout flow allowing you to freely position an element in a specific place regardless of the size of the layout where it belongs.
With the z-index option you can decide the order of overlapping elements while maintaining the layers order.
Managing flex spacing
When creating Flex layouts, the spacing is predicted, helping you to maintain your design composition.
Set paddings, margins and gaps using their respective numeric inputs.
You can also click and drag to resize them while visualizing the value that is being edited:
- Hold Shift/⇧ while dragging to change the value of opposite sides evenly.
- Hold Alt/⌥ while dragging to change the value of all sides evenly.
Get code and specifications
Designing with Flex Layout generates ready for production code. Select the flex board or its inner elements and then open the Inspect tab to obtain its properties, detailed info and raw code.
Flex Layout basic examples
How to create a button
A classic example that will help you create flexible buttons that grow depending on its content.
How to create a list
Extremely useful for ordering list items. Remember to set fit height to the container so it can adapt to the number of items.
How to create a grid
Use the wrap property along with row direction to get the elements positioned in multiple lines.