CSS Flexbox Playground
Visually configure CSS flexbox container and item properties with a live preview. Generate ready-to-use CSS code for flex-direction, justify-content, align-items, and more.
Presets
Container Properties
Item Properties
Live Preview
1
2
3
Container CSS
.flex-container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: stretch;
align-content: stretch;
gap: 8px;
}Items CSS
.flex-item-1 {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item-2 {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}
.flex-item-3 {
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
}Related Tools
About CSS Flexbox Playground
How It Works
- Adjust container properties like flex-direction, flex-wrap, justify-content, align-items, and align-content
- Add up to 6 flex items and configure each one independently with flex-grow, flex-shrink, flex-basis, align-self, and order
- Preview your layout in real time as you change any property
- Copy the generated container and item CSS code directly into your project
- Use presets to quickly explore common flexbox patterns
Common Use Cases
- Learning flexbox layout properties interactively
- Prototyping navigation bars, card grids, and sidebars
- Debugging tricky flexbox alignment issues
- Generating boilerplate CSS for common layout patterns
- Teaching CSS flexbox concepts to students
Frequently Asked Questions
What is the CSS Flexbox Playground?
The CSS Flexbox Playground is an interactive tool that lets you visually configure all flexbox container and item properties. Changes appear instantly in a live preview, and ready-to-use CSS code is generated automatically so you can copy it straight into your project.
What container properties can I configure?
You can configure all six main flex container properties: flex-direction (row, row-reverse, column, column-reverse), flex-wrap (nowrap, wrap, wrap-reverse), justify-content (flex-start, flex-end, center, space-between, space-around, space-evenly), align-items (stretch, flex-start, flex-end, center, baseline), align-content (stretch, flex-start, flex-end, center, space-between, space-around), and gap (pixel value).
What item properties can I configure per flex item?
Each flex item can be configured with: flex-grow (how much extra space the item takes), flex-shrink (how much the item shrinks when space is tight), flex-basis (the initial size), align-self (individual alignment override), and order (visual order in the container).
How many flex items can I add?
You can add up to 6 flex items. Click the '+ Add Item' button to add more items. Each item is color-coded so you can easily identify it in the preview and settings panel.
How do I select and edit a specific flex item?
Click on any numbered tab at the top of the Item Properties panel to select that item. You can also click directly on an item in the live preview to select it. The selected item will be highlighted with a colored border.
What are the presets and how do I use them?
Presets are ready-made flexbox configurations for common layout patterns: 'Centered Row' centers items horizontally and vertically, 'Centered Column' stacks items vertically and centers them, 'Space Between' distributes items evenly, 'Wrapping Grid' uses flex-wrap so items wrap to new lines, 'Stretched Items' uses flex-grow so items fill available space, and 'Reversed Row' reverses the item display order. Click a preset to instantly apply it, then customize further.
What does flex-grow do?
flex-grow defines how much a flex item grows relative to other items when there is extra space in the container. A value of 0 means the item will not grow. A value of 1 means it takes an equal share of extra space. A value of 2 means it takes twice as much space as an item with flex-grow: 1.
What does flex-shrink do?
flex-shrink defines how much a flex item shrinks relative to other items when there is not enough space in the container. A value of 0 prevents the item from shrinking. A value of 1 (default) means it shrinks proportionally. A value of 2 means it shrinks twice as fast as an item with flex-shrink: 1.
What values can flex-basis accept?
flex-basis sets the initial main-size of a flex item before free space is distributed. It accepts: 'auto' (uses the item's width or height), a length value like '100px' or '20%', 'content' (based on the item's content), or '0' (item starts from zero size). You can type any valid CSS value into the flex-basis input.
What is the difference between align-items and align-self?
align-items is a container property that applies to all flex items by default. align-self overrides align-items for an individual item. For example, if the container has align-items: center but one item has align-self: flex-end, all items will be centered except that one item which will be at the end of the cross axis.
What does the order property do?
The order property controls the visual order of flex items without changing the DOM order. Items with a lower order value appear first. The default value is 0. Setting order: -1 on an item will place it before all default items, while order: 1 will place it after all default items.
How do I copy the generated CSS?
There are two copy buttons: one for the container CSS and one for all CSS (container + items). Click either 'Copy CSS' button to copy the code to your clipboard. The container CSS includes the .flex-container selector, and the items CSS includes individual .flex-item-1, .flex-item-2, etc. selectors.