Flex
A flex container with direction, wrap, align, justify, gap and an inline form. Stack covers the common case.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- Built on native elements
- A plain element; adds no roles. Reversed directions change visual order only, so keep the source order meaningful.
- Styles in one file:
flex.css
Import
import '@monoline/css';
import {Flex} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add flex
Usage
import {Badge, Flex} from '@monoline/react';
<Flex justify="between" align="center" gap={3}>
<Badge>left</Badge>
<Badge>right</Badge>
</Flex>
Examples
Space between
Reversed column
Inline
Props
FlexProps
| Prop | Type | Default | Description |
|---|---|---|---|
direction | "row" | "column" | "row-reverse" | "column-reverse" | 'row' | Main axis: `row` (default), `column`, `row-reverse` or `column-reverse`. |
wrap | boolean | – | Lets children wrap onto new lines instead of shrinking. Default false. |
align | "center" | "start" | "end" | "stretch" | "baseline" | – | Cross-axis alignment (`align-items`): `start`, `center`, `end`, `stretch` or `baseline`. |
justify | "center" | "start" | "end" | "between" | "around" | – | Main-axis distribution (`justify-content`): `start`, `center`, `end`, `between` or `around`. |
gap | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | – | Step on the spacing scale: 1 = --s1 up to 9. |
inline | boolean | – | `inline-flex` instead of `flex`. |
asChild | boolean | – | Render the child element (a `ul`, `nav`, `section`) with the flex styles instead of a `div`. |
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
| Attribute | Stylesheet |
|---|---|
[data-align="baseline"] | flex.css |
[data-align="center"] | flex.css |
[data-align="end"] | flex.css |
[data-align="start"] | flex.css |
[data-align="stretch"] | flex.css |
[data-direction="column-reverse"] | flex.css |
[data-direction="column"] | flex.css |
[data-direction="row-reverse"] | flex.css |
[data-justify="around"] | flex.css |
[data-justify="between"] | flex.css |
[data-justify="center"] | flex.css |
[data-justify="end"] | flex.css |
[data-justify="start"] | flex.css |
CSS classes
| Class | Stylesheet |
|---|---|
.flex | flex.css |
.flex-inline | flex.css |
.flex-wrap | flex.css |
Customization
Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.
app.css
.flex {
border-color: var(--accent);
}
.flex[data-align="baseline"] {
background: var(--wash);
}
Accessibility
- A plain element; adds no roles. Reversed directions change visual order only, so keep the source order meaningful.