Flex
A flexible box container for building flexbox layouts with full control over direction, alignment, and spacing.
import { Flex } from "@ninna-ui/layout"pnpm add @ninna-ui/layoutRequires @ninna-ui/core (auto-installed) + CSS setup.
Usage
Import and use the Flex component in your application.
import { Flex } from "@ninna-ui/layout";
export default function Example() { return ( <Flex gap="4" align="center"> <Avatar /> <Text>Username</Text> </Flex> );}Basic
Basic flex layout with row direction.
Direction
Control flex direction with row, column, and reverse variants.
row
column
row-reverse
column-reverse
Gap Spacing
Control spacing between items with the gap prop.
gap="0"
gap="2"
gap="4"
gap="6"
gap="8"
Alignment
Align items on the cross axis.
align="start"
align="center"
align="end"
align="stretch"
align="baseline"
Justify
Distribute items along the main axis.
justify="start"
justify="center"
justify="end"
justify="between"
justify="around"
justify="evenly"
Wrap
Flex items can wrap to multiple lines.
Inline
Use inline-flex for inline layout.
inline=false (default)
Takes full width
inline=true
Shrinks to content
Use Cases
Common patterns using Flex for layouts.
API Reference
Complete list of props for the Flex component.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
direction | 'row' | 'column' | 'row-reverse' | 'column-reverse' | 'row' | Flex direction |
gap | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '8' | '10' | '12' | '16' | - | Gap between items |
align | 'start' | 'center' | 'end' | 'stretch' | 'baseline' | - | Align items on cross axis |
justify | 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly' | - | Justify items on main axis |
wrap | 'wrap' | 'nowrap' | 'wrap-reverse' | - | Flex wrap behavior |
inline | boolean | false | Use inline-flex instead of flex |
className | string | - | Additional CSS classes |
Accessibility
- Flex is a pure layout component with no semantic meaning
- Use appropriate semantic HTML elements as children
- For navigation, wrap in a nav element
- Ensure proper focus order is maintained