Flex Component

The Flex component provides a flexible and powerful way to manage layouts in your React applications. With a rich set of variants and customization options, it allows you to easily control the direction, alignment, and spacing of child elements.

Installation

Ensure that have the @zyxui library installed in your project:

If you haven't install and setup @zyxui before please follow the installation guide

Basic Usage

Import the Flex component and use it to create flexible layouts:

01
02
03
04

Customization

Tailor the behavior of the Flex component to suit your layout needs with the following customization options.

Direction

The direction prop allows you to control the direction of flex container. This porp can have many values: column | column-reverse | row | row-reverse, and the default value is: row.

Change Direction Value:
01
02
03
04
05

Justify

The justify prop, allows you to align items along the main axis. You can check all about this prop values in API Reference Section

justify: flex-start

01
02
03

justify: center

01
02
03

justify: flex-end

01
02
03

justify: space-between

01
02
03

justify: space-around

01
02
03

justify: space-evenly

01
02
03

justify: stretch

01
02
03

justify: normal

01
02
03

Align

The align prop, allows you to align items along the corss axis. You can check all about this prop values in API Reference Section

Align Start Example

01
02
03

Align Stretch Example

01
02
03

Align End Example

01
02
03

Align Center Example

01
02
03

Align Baseline Example

01
02
03

Wrap

With wrap prop, you are able to control wether the flex container should wrap it's children or not. Values that should be provided to this prop: wrap | wrap-reverse | nowrap, and the default value is 'nowrap'.

wrap: nowrap

Directions:

Content 01
Content 02
Content 03

wrap: wrap

Directions:

Content 01
Content 02
Content 03

wrap: wrap-reverse

Directions:

Content 01
Content 02
Content 03

Gap

The gap prop, allows you to adjust the gap between child elements. Accepted values for this prop are: sm | md | lg | xl | undefined/null

Gap Sizes:

API Reference

The Flex component exposes a range of customization options to tailor the behavior of your layout. Here's an overview of the available props:

PropertyDescriptionTypeDefault
directionControl the direction of the flex container.reference flex-directionrow
justifyAlign items along the main axis.reference justify-contentflex-start
alignAlign items along the cross axis.reference align-itemsstretch
wrapControl whether the flex container should wrap its children.reference flex-wrapnowrap
gapAdjust the gap between child elements.sm | md | lg | xl | nonenone
classNameAdding custom class names to your text element.stringundefined