Skip to content

Commit

Permalink
docs(size-scales): Add reference of sizing scales in documentation (#…
Browse files Browse the repository at this point in the history
…2327)

Co-authored-by: Lachlan Campbell <lachlanjc@hey.com>
  • Loading branch information
simenandre and lachlanjc authored Sep 24, 2022
1 parent b3f29d4 commit d968cb1
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/docs/src/pages/theming.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,47 @@ For other units, use string values, e.g. `'1em'`.
}
```

## Value scales

The following theme keys are used to define scales for values that can be used in other parts of a theme:

- `space` (margin, padding, gap, etc)
- `sizes` (width, height, etc)
- `borders` (border)
- `borderWidths` (border-width)
- `borderStyles` (border-style)
- `radii` (border-radius)
- `shadows` (box-shadow)
- `zIndices` (z-index)

For example, after setting `space` like this in your theme:

```js
space: [0, 4, 8, 16, 32, 64, 128, 256, 512],
```

You can reference the array values in your theme styles, by index:

```js
<Box
sx={{
padding: 2 // Equals 8px
}}
/>
```

The values can also be named using an object, like this:

```js
sizes: {
wide: 2048,
container: 1024,
narrow: 512,
},
```

Then used by name, such as `sx={{ maxWidth: 'narrow' /* 512px */ }}`.

## Styles

Styles for elements rendered in MDX can be added to the `theme.styles` object.
Expand Down

0 comments on commit d968cb1

Please sign in to comment.