Flex
A powerful layout component built on top of Box
that provides flexbox functionality with an intuitive API. Flex
makes it easy to create flexible layouts with proper alignment and spacing.
Import
import { Flex } from '@beauginbey/vanilla-components';
Basic Usage
The Flex
component defaults to display: flex
and accepts all flexbox-related props.
Direction
Control the flex direction with the direction
prop.
Alignment
Use align
and justify
to control alignment.
Wrapping
Control flex wrapping with the wrap
prop.
Gap Utilities
Use gap
, gapX
, and gapY
for precise spacing control.
Responsive
All flex properties support responsive values.
Common Patterns
Navigation Bar
Card Layout
Centered Content
Props
Flex
accepts all Box
props plus the following flex-specific props:
Prop | Type | Default | Description |
---|---|---|---|
direction | 'row' | 'column' | 'row-reverse' | 'column-reverse' | 'row' | Sets the flex direction |
wrap | 'nowrap' | 'wrap' | 'wrap-reverse' | 'nowrap' | Controls flex wrapping |
justify | 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly' | - | Aligns items along the main axis |
align | 'start' | 'center' | 'end' | 'stretch' | 'baseline' | - | Aligns items along the cross axis |
gap | number | - | Sets gap between items |
gapX | number | - | Sets horizontal gap |
gapY | number | - | Sets vertical gap |
All props support responsive values.
Alignment Values
-
justify (main axis):
start
: flex-startcenter
: centerend
: flex-endbetween
: space-betweenaround
: space-aroundevenly
: space-evenly
-
align (cross axis):
start
: flex-startcenter
: centerend
: flex-endstretch
: stretchbaseline
: baseline