Skip to content

Flex ​

A layout container based on CSS Flexbox; attributes control direction, main/cross-axis alignment, gap and wrapping.

Basic usage ​

Horizontal and gap

Tag 1Tag 2Tag 3

Direction ​

The vertical shorthand equals direction="vertical" (stacked vertically).

Vertical direction

Stacked verticallyTop to bottomAdjustable gap

Equivalent direction syntax

direction="vertical"Same as vertical

Main-axis alignment ​

justify — full enumeration

justify="start" (default)123justify="center"123justify="end"123justify="between"123justify="around"123justify="evenly"123

Cross-axis alignment ​

align — full enumeration

align="stretch" (default)ButtonTagalign="start"ButtonTagalign="center"ButtonTagalign="end"ButtonTagalign="baseline"ButtonTag

A fixed 80px-height container with items of different heights (button 32px / tag 20px) shows the cross-axis difference of each align variant; stretch stretches items to the container height.

Wrapping ​

wrap is a boolean attribute: when present, flex-wrap: wrap; otherwise nowrap.

Wrap

12345678910

Fill ​

fill makes items grow equally to fill the container (the flex: 1 equivalent); fill-ratio (percent, default 100) distributes proportionally — settable per item, with the container-level fill-ratio as the default.

fill — equal fill

One
Two
Three

fill-ratio — proportional

1
2 (200%)
3
Container default 300%
Also 300%

About per-item order: oas-flex has no child-item component carrier (children are arbitrary host elements), so per-item order has no reasonable API and is intentionally not provided in this version. It will be revisited if an item component (oas-flex-item) scenario emerges later.

Responsive ​

direction and gap support breakpoint shorthand: a space-separated base value plus several breakpoint:value tokens (e.g. direction="column md:row", gap="8px md:16px"). Below a breakpoint width the base value applies; from the breakpoint up (mobile-first min-width) the breakpoint value applies.

Breakpoints:

BreakpointWidth
sm640px
md768px
lg1024px
xl1280px

Responsive direction: stacked on narrow, row from md

Button 1Button 2Button 3

Responsive gap: 8px base, 24px from md

123456

Narrow the browser window to watch direction switch from row back to column and the gap tighten.

Empty container ​

With no children the height is 0 — no error, no placeholder.

Empty container

API ​

oas-flex ​

Attributes ​

AttributeDescriptionTypeDefault
alignCross-axis alignmentstringstretch
directionMain-axis direction; supports breakpoint shorthand: space-separated base value + several breakpoint:value tokens (e.g. column md:row). Breakpoints sm=640px / md=768px / lg=1024px / xl=1280px (mobile-first min-width); below a breakpoint the base value applies. Illegal breakpoint names/values fall back to the base value with a dev warningstringrow
fillMake items grow equally to fill the container (the flex: 1 equivalent)boolean—
fill-ratioDistribution ratio for fill (percent, default 100): settable per item, container-level as the defaultstring—
gapGap between items; supports breakpoint shorthand (e.g. 8px md:16px, breakpoints as direction)string—
justifyMain-axis alignment: start/center/end/between/around/evenly (bidirectionally compatible with legacy flex-*/space-* values)stringstart
verticalVertical shorthand (= direction:column; takes precedence over direction)boolean—
wrapWrapping (boolean; present means wrap)boolean—

Slots ​

NameDescription
defaultFlex layout children

CSS Variables ​

CSS VariableDefault
--oas-flex-direction${dirBase}
--oas-flex-gap${toLen(gapShorthand.base) || 'normal'}

Released under the MIT OR Apache-2.0 License.