Flex

Lays out its children in a row or a column with flexbox.

Usage

Code
import { Flex } from '@leverui/components';

export function FlexUsage() {
  return (
    <Flex>
      <div />
      <div />
    </Flex>
  );
}

Examples

Direction

Use direction to change the flex direction.

Align

Use align to position children on the cross axis.

Justify

Use justify to align children on the main axis.

flex-start
center
flex-end
space-between

Order

Use CSS order to change the visual order of children.

1
2
3

Auto Margin

Push a flex item away from its siblings with auto margin.

Spacer

Use Spacer to fill space between two flex items.

Box 1
Box 2

Wrap

Use wrap when children should move to another line.

Props

PropDefaultTypeDescription
align—Responsive CSS alignmentAlign children on the cross axis.
justify—Responsive CSS alignmentAlign children on the main axis.
wrap—Responsive CSS wrap valueWhether children wrap onto a new line.
direction—Responsive CSS directionDirection the children flow in.
basis—Responsive CSS sizeFlex basis, the element's starting size.
grow—Responsive numberHow much the element grows into free space.
shrink—Responsive numberHow much the element shrinks when space is tight.
inlinefalseBooleanUse inline-flex instead of flex.
asdivNative HTML tagHTML tag to render.
asChild—Solid render callbackRender your own root element.
unstyledfalseBooleanTurn off the shared presentation styles.

align, justify, wrap, and direction set the matching CSS flex properties. For gaps, padding, and other styling, add your own class.

order and direction can change the order on screen. Keyboard and screen-reader users follow the HTML order, so make sure it still makes sense.