# Flex A flexible layout component for arranging children with configurable gap, direction, justification, alignment, and wrapping. ```jsx featured Item 1 Item 2 Item 3 ``` ```css preview .flex { display: flex; /* Gap */ &[data-gap="0"] { gap: 0; } &[data-gap="1"] { gap: calc(4px * var(--lcs-spacing, 1)); } &[data-gap="2"] { gap: calc(8px * var(--lcs-spacing, 1)); } &[data-gap="3"] { gap: calc(12px * var(--lcs-spacing, 1)); } &[data-gap="4"] { gap: calc(16px * var(--lcs-spacing, 1)); } &[data-gap="5"] { gap: calc(20px * var(--lcs-spacing, 1)); } &[data-gap="6"] { gap: calc(24px * var(--lcs-spacing, 1)); } &[data-gap="7"] { gap: calc(28px * var(--lcs-spacing, 1)); } &[data-gap="8"] { gap: calc(32px * var(--lcs-spacing, 1)); } /* Direction */ &[data-direction="row"] { flex-direction: row; } &[data-direction="column"] { flex-direction: column; } &[data-direction="row-reverse"] { flex-direction: row-reverse; } &[data-direction="column-reverse"] { flex-direction: column-reverse; } /* Justify Content */ &[data-justify="start"] { justify-content: flex-start; } &[data-justify="end"] { justify-content: flex-end; } &[data-justify="center"] { justify-content: center; } &[data-justify="between"] { justify-content: space-between; } &[data-justify="around"] { justify-content: space-around; } &[data-justify="evenly"] { justify-content: space-evenly; } /* Align Items */ &[data-align-items="flex-start"] { align-items: flex-start; } &[data-align-items="flex-end"] { align-items: flex-end; } &[data-align-items="center"] { align-items: center; } &[data-align-items="baseline"] { align-items: baseline; } &[data-align-items="stretch"] { align-items: stretch; } /* Wrap */ &[data-wrap="wrap"] { flex-wrap: wrap; } &[data-wrap="nowrap"] { flex-wrap: nowrap; } &[data-wrap="wrap-reverse"] { flex-wrap: wrap-reverse; } } ``` [View Source](https://github.com/LocusInc/locus-ui/tree/main/packages/locus-ui/src/components/flex) ## Anatomy ```jsx code no-header ``` ## Examples ### Gaps The `gap` prop controls the spacing between child elements using predefined scale values `0` through `8`. ```jsx {["0", "1", "2", "3", "4", "5", "6", "7", "8"].map((gap) => ( {gap} Item 1 Item 2 ))} ``` ### Directions The `direction` prop sets the flex direction: `row`, `row-reverse`, `column`, or `column-reverse`. ```jsx {["row", "row-reverse", "column", "column-reverse"].map((direction) => ( {direction} Item 1 Item 2 ))} ``` ### Justify The `justify` prop controls the main-axis alignment: `start`, `end`, `center`, `between`, `around`, or `evenly`. ```jsx {["start", "end", "center", "between", "around", "evenly"].map( (justify) => ( {justify} Item 1 Item 2 ), )} ``` ### Align The `align` prop controls the cross-axis alignment: `start`, `end`, `center`, `stretch`, or `baseline`. ```jsx {["start", "end", "center", "stretch", "baseline"].map((align) => ( {align} Item 1 Item 2 ))} ``` ### Wrap The `wrap` prop controls flex wrapping: `nowrap`, `wrap`, or `wrap-reverse`. ```jsx {["nowrap", "wrap", "wrap-reverse"].map((wrap) => ( {wrap} Item 1 Item 2 Item 3 ))} ```