Flex
Flex is the default layout container: a <div> with display: flex that arranges its children with token
spacing, direction and alignment. It is layout only — no background, border, shadow or typography. When a block needs a
visible surface, use Paper.When to use
- You arrange children in a row or column with token spacing (
gap). - You align, wrap or reorder children without writing a styled component.
- You decide how each child grows or shrinks (
flex).
Usage
flexDirection defaults to column. gap takes a spacing token.
Sizing children (flex)
Set flex on a child to choose how it shares the free space:
fluid—1 1 0%: grows and shrinks, ignoring its content size.auto—1 1 auto: grows and shrinks from its content size.initial—0 1 auto: never grows, shrinks when needed.none— neither grows nor shrinks; pins a child between fluid siblings.
<Flex flexDirection="row" wrap="wrap" gap="small"> <Paper flex="fluid">…</Paper> <Paper flex="none">…</Paper> <Paper flex="fluid">…</Paper> </Flex>
Inline flex (display)
A Flex is always a flex container. display picks the variant: flex (default, block-level) or inline-flex
(flows inside text). To hide a Flex in a slot, use a responsive channel: cq={{ md: { display: 'none' } }}.
<Text>
Status:{' '}
<Flex display="inline-flex" flexDirection="row" gap="micro">
…
</Flex>
</Text>Responsive layout
Base props are the mobile style. cq reacts to the width of the container's own slot (see
Container Queries); viewportMedias reacts to the viewport and suits page shells.
Both take one object per size and carry layout props only.
<Flex gap="small" cq={{ md: { flexDirection: 'row', gap: 'large' } }} />
<Flex viewportMedias={{ md: { flexDirection: 'row' }, xl: { p: 'small' } }} />To type a layout object that also sets as, annotate it as FlexProps:
import type { FlexProps } from '@apollion-dsi/core/containers/flex';
const shell: FlexProps = { as: 'section', gap: 'large', viewportMedias: { md: { flexDirection: 'row' } } };Accessibility
Flexrenders a plain<div>with no role. Useas(section,nav,ul) when the group has meaning.row-reverse,column-reverseandorderchange the visual order only. Focus and screen-reader order follow the DOM, so keep the source order logical.
Properties
Flex takes the layout props — spacing, size, position, the flex props and the cq /
viewportMedias channels — plus display and the native <div> attributes.