import { Story, Preview, ArgsTable } from '@storybook/addon-docs/blocks';
import { Flexbox } from './Flexbox';

# Flexbox

<Preview>
  <Story id="layout-flexbox--default-props" />
</Preview>

Flexbox is the main layout component of the library. It's used to setup one-dimensional layouts, and simpler two-dimensional ones.
It's based on the [flexbox css spec](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox).

## Containers and items

The Flexbox component has two main props that need to be set, `container` and `item`. Containers decide the positioning of the items inside while items contains the content.

The container and item booleans decide which props you can use for the component. The flexbox component can be both a container and an item as can be seen in the story below.

<Preview>
  <Story id="layout-flexbox--both-container-and-item" />
</Preview>

## Gutter

You can add spacing between the flexbox items using the `gutter` prop. It takes a number which is multiplied with the spacing unit of 4px.
Example: If you send in 3 as the gutter, 3 \* 4 = 12px which means there will be 12px between each item

## Column size

The column size is a number of how many columns the item should take in a 12 column grid. Similar to how bootstrap works.
You can use this to simplify defining layout widths. It's recommended to use it to define larger sections of layout such as page layout rather than components.

For more complex layouts, use the `CssGrid` component.

## Responsive props

`Flexbox` includes responsive props `sm`, `md`, `lg` and `xl`. They can be used to override any styling flexbox prop depending on screen size.
This is a pure css solution so html attribute props are not included. You can read more about responsive props in the Responsive props section of the [Box documentation](?path=/docs/layout-box--default-props#responsive-props).

## Props

<ArgsTable of={Flexbox} />
