--- title: 08· Flexible Layouts ---
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. At Penpot you have unique ways to create and manage adaptative layouts that have all the advantages of CSS standards.
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.
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. There are many comprehensive explanations about Flexbox, if you are interested we recommend you to read the one at CSS Tricks.
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:
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.
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.
Static position is the default option for flex elements, meaning that they will be included in the flex flow, using flex properties.
Selecting absolute positioning 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.
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:
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.
A classic example that will help you create flexible buttons that grow depending on its content.
Extremely useful for ordering list items. Remember to set fit height to the container so it can adapt to the number of items.
Use the wrap property along with row direction to get the elements positioned in multiple lines.
Grid Layout allows you to efficiently organize, align, and distribute items in 2-dimensional layouts. You can create rows and columns of elements, giving you fine-grained control over their expansion, alignment, and responsiveness to various screen sizes. It's a powerful tool for creating responsive designs.
Penpot's Grid Layout is built over CSS Grid, a fairly new CSS module. If you are interested to know more about this CSS module we recommend checking out the comprehensive explanation Guide to CSS Grid at CSS Tricks.
You can add Grid Layout to any layer, group, board or selection. Once Grid Layout Flex is added the selected elements will be contained into a board that handles its space through Grid Layout properties. You have several ways to add Grid Layout:
There are properties both for Grid containers and Grid items (cells, rows, cols). Those are the same properties that you can use with CSS Grid. You can read here detailed explanations about CSS Grid properties.
These are different ways to manage the element's position that therefore have different code representation.
grid-column
and grid-row
.Align self (vertically and horizontally): Start, center, end, stretch.
To place elements inside a grid layout, just drag them or paste them in a cell or area.
Tip: Drag an element over a grid and then press Ctrl to place it as auto. That way the layer will be positioned automatically in the first available cell or area.
To edit grid layouts (rows, columns, units, cells, areas, etc) you can either select the board and press the "Edit grid" button or double click over the board.
You have several ways to edit rows and columns:
From the design sidebar you will be able to:
Tip: You cand drag columns and rows while leaving the elements in the same position if you perform the action while pressing Ctrl.
From the design viewport you will be able to:
Tip: You can drag columns and rows while leaving the elements in the same position if you perform the action while pressing Ctrl.
To launch the contextual menu of rows and columns you can right click over a column or row header or left click on the menu button.
From the contextual menu of rows and columns you will be able to:
You can use different units at your grid columns and cells:
Areas are compositions of any number of grid cells.
You have two ways to create areas:
1. Select more than one cell pressing left click while holding Ctrl, then press right click to open the menu and then press the option "Merge cells".
2. Select one cell pressing left click, then hover near the limit to the cell you want to merge the selected cell with until the cursor changes. Then drag the cursor to merge the selected area to other areas in the same direction.
To name an area, select the "Area" option at the grid cell properties (right sidebar) and fill the name of the area.
To turn areas back to regular cells, just select the "Auto" option at the grid cell properties (right sidebar).
Grid layout at Penpot behaves just like CSS Grid because it is actually using the CSS Grid standard. This means that you can just switch to Inspect mode, get the code and use it in real websites.