Components
Flex

Flex

A flexible layout container for creating responsive and adaptable layouts in React applications using flexbox.

Import

import { VKFlex, VKFlexItem } from "@vivakits/react-components";

Direction

The flex component supports 4 different flex-direction properties that can be set using the direction prop.

Wrap

Specify whether the flex items should wrap onto multiple lines or stay on a single line using the wrap prop.

Justify

Align flex items along the main axis using the justify prop.

Align

Align flex items along the cross axis using the align prop.

Gap

Set the spacing between flex items using the gap prop.

Basis

Set the initial size of a flex item using the basis prop, corresponding to the flex-basis CSS property.

Item 1
Item 2
Item 3

Grow

Control the ability of a flex item to grow using the grow prop, corresponding to the flex-grow CSS property.

Item 1
Item 2
Item 3

Shrink

Control the ability of a flex item to shrink using the shrink prop, corresponding to the flex-shrink CSS property.

Item 1
Item 2
Item 3

Component

Specify a custom element type for the flex container using the component prop.

Available Variants

  • direction: row, row-reverse, column, column-reverse
  • justify: start, end, center, between, around, evenly
  • align: start, end, center, baseline, stretch
  • gap: sm, md, lg, xl, default, string, number
  • wrap: wrap, nowrap

API Reference

Flex

AttributeTypeDescriptionDefault
directionflex-directionSets the direction of flex itemsrow
wrapwrapnowrapbooleanSet whether the element is displayed in a single line or in multiple linesnowrap
justifystartendcenterbetweenaroundevenlySets the alignment of elements in the direction of the main axisstart
alignstartendcenterbaselinestretchSets the alignment of elements in the direction of the cross axisstart
gapsmmdlgxldefaultstringnumberSets the gap between flex items default
componentReact.ComponentTypeCustom element typediv

FlexItem

AttributeTypeDescriptionDefault
basisstringSets the initial main size of a flex item. Corresponds to `flex-basis` CSS property. Can be a pixel value, percentage, or autoauto
grownumberbooleanDefines the ability for a flex item to grow if necessary. Corresponds to `flex-grow` CSS property0
shrinknumberbooleanDefines the ability for a flex item to shrink if necessary. Corresponds to `flex-shrink` CSS property1