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

# Box

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

The padding and margin box. It mirrors the css spec for shorthands.
The numbers supplied are multiplied by the spacing unit. The default spacing unit is 4px.

Example: You set `<Box pr={4} />` will have a padding right of 4 \* 4 = 16px;

## Overriding

Note that, due to the way css works, more specific values will overwrite less specific values.
This can be used to overriding specific padding and margin values when needed.

Example: `<Box p={3} pl={5} />` will have 12 px of padding on all sides but the left side which will have 20px

## Responsive props

The `Box` component can be overriden depending on screen size. Any props that the `Box` component takes can also be sent
in the screen breakpoint props of `sm`, `md`, `lg` and `xl`. The props are applied from the smallest up using a media query with `min-width`.
That means if you set any prop on for example `sm` it will also be applied to `md`, `lg` and `xl` if not overriden, this is a property of how css works.
Any property set to the component root is the equivalent of setting it to `xs` breakpoint, i.e. it will be set for all screen sizes unless overriden.

In the example, the padding will be 5 \* 4px = 20px when on an `xs` and `sm` size screen. When the breakpoint for `md`
has passed the padding will be set to 20 \* 4px = 80px.

```mdx
<Box p={5} md={{ p: 20 }}>
  Content
</Box>
```

In this example, due to the way css works, the margin will stay the same on any screen size, it will be 10 \* 4px = 40px. It can be overridden at any larger breakpoint by passing a new `m` value

```mdx
<Box p={5} m={10} md={{ p: 20 }}>
  Content
</Box>
```

## Props

<ArgsTable of={Box} />
