Flex

Single-axis layout with responsive direction, alignment, and child sizing.

Add it to your project

Eject the complete flex group, then import from its generated local barrel. The copied source and CSS belong to your application.

bash
pnpm exec toucan eject flex
app.tsx
import { Flex, FlexItem } from '@/components/toucan/flex';

Use when

Content should flow in one primary direction and needs consistent alignment or gaps.

Avoid when

Rows and columns must align in two dimensions; use Grid instead.

Example

ReactTypeScriptCSSAccessibilityTokens
Left content

Jane Doe

Product Engineer

ReactTypeScriptDesign Systems

API reference

Generated from packages/react/src/components. Only Toucan-specific props are listed; forwarded native props remain available as noted for each export.

FlexFlexItem

Flex

Props type: FlexProps

NameTypeDefaultRequiredDescription
align"start" | "center" | "end" | "stretch" | "baseline" | { base?: FlexAlign; sm?: FlexAlign; md?: FlexAlign; lg?: FlexAlign; xl?: FlexAlign; }undefinedNoAlignment within the component layout.
gap0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16undefinedNoSpace between child items from the Toucan scale.
justify"start" | "center" | "end" | "between" | { base?: FlexJustify; sm?: FlexJustify; md?: FlexJustify; lg?: FlexJustify; xl?: FlexJustify; }undefinedNoMain-axis distribution within the component layout.
rowboolean | "sm" | "md" | "lg" | "xl"undefinedNoSwitch flex direction to a row, optionally at a breakpoint.
wrapbooleanfalseNoAllow child items to wrap onto additional lines.

Also accepts the native div attributes that are not replaced by a Toucan prop.

FlexItem

Props type: FlexItemProps

NameTypeDefaultRequiredDescription
align"auto" | "start" | "center" | "end" | "stretch" | "baseline" | { base?: SelfAlign; sm?: SelfAlign; md?: SelfAlign; lg?: SelfAlign; xl?: SelfAlign; }undefinedNoAlignment within the component layout.
growbooleanfalseNoAllow the flex item to grow into available space.
shrinkbooleantrueNoAllow the flex item to shrink below its content size.

Also accepts the native div attributes that are not replaced by a Toucan prop.

Type exports

FlexItemProps, FlexProps

Accessibility

  • Flex and FlexItem are visual wrappers and do not change reading order or semantics.

Token families

scale

Related components