VOOZH about

URL: https://ant.design/components/flex/

⇱ Flex - Ant Design


DividerGrid

When To Use

  • Good for setting spacing between elements.
  • Suitable for setting various horizontal and vertical alignments.

Difference with Space component

  • Space is used to set the spacing between inline elements. It will add a wrapper element for each child element for inline alignment. Suitable for equidistant arrangement of multiple child elements in rows and columns.
  • Flex is used to set the layout of block-level elements. It does not add a wrapper element. Suitable for layout of child elements in vertical or horizontal direction, and provides more flexibility and control.

Examples

API

This component is available since antd@5.10.0. The default behavior of Flex in horizontal mode is to align upward, In vertical mode, aligns the stretch, You can adjust this via properties.

Common props ref:Common props

PropertyDescriptionTypeDefaultVersionGlobal Config
verticalIs direction of the flex vertical, use flex-direction: columnbooleanfalse5.10.05.10.0
wrapSet whether the element is displayed in a single line or in multiple linesflex-wrap | booleannowrapboolean: 5.17.0×
justifySets the alignment of elements in the direction of the main axisjustify-contentnormal×
alignSets the alignment of elements in the direction of the cross axisalign-itemsnormal×
flexflex CSS shorthand propertiesflexnormal×
gapSets the gap between gridssmall | medium | large | string | number-×
componentcustom element typeReact.ComponentTypediv×
orientationdirection of the flexhorizontal | verticalhorizontal-×

Design Token

Global TokenHow to use?
Token NameDescriptionTypeDefault Value
paddingControl the padding of the element.number16
paddingLGControl the large padding of the element.number24
paddingXSControl the extra small padding of the element.number8
Basic

The basic usage.

align

Set align.

gap

Set the gap between elements, which has three preset sizes: small, medium, and large. You can also customize the gap size.

Wrap

Auto wrap line.

combination

Nesting can achieve more complex layouts.

Select justify :

Select align :

👁 avatar

“antd is an enterprise-class UI design language and React UI library.”

Get Started