configure()

Specification

Applies global layout configuration.
Layout is meant to be configured once, on the root level of your application.
Calling Layout.configure() on your application's root mount is usually a good place:
1
import React, { useEffect } from 'react'
2
import ReactDOM from 'react-dom'
3
import Layout from 'atomic-layout'
4
5
const App = () => {
6
useEffect(() => {
7
// A single call to configure layout upon App's mount
8
Layout.configure(options)
9
}, [])
10
11
return <Tree />
12
}
13
14
ReactDOM.render(<App />, document.getElementById('root'))
Copied!

Options

defaultUnit

Value type
String
Default value
px
Description
Default measurement unit used as a suffix for numeric prop values.

Example

src/App.jsx
1
import Layout from 'atomic-layout'
2
3
Layout.configure({
4
defaultUnit: 'rem',
5
})
Copied!
src/components/SomeComponent.jsx
1
<Composition gap={2} /> // reads as "2rem" of "grid-gap"
Copied!

defaultBehavior

Value type
up | down | only
Default value
up
Description
Breakpoint behavior used for responsive props without explicit behavior.

Example

src/App.jsx
1
import Layout from 'atomic-layout'
2
3
Layout.configure({
4
defaultBehavior: 'down',
5
})
Copied!
src/components/SomeComponent.jsx
1
<Composition
2
template={...}
3
templateMd={...} />
Copied!
Template prop value is applied for md breakpoint and down, as contrary to the default, mobile-first behavior, which applies the value from the given breakpoint and up.

breakpoints

Value type
TBreakpoints
Default value
Bootstrap 4 breakpoints
Description
A map of custom breakpoints.

Type definition

1
type TBreakpoint = {
2
minHeight?: number,
3
maxHeight?: number,
4
minWidth?: number,
5
maxWidth?: number,
6
minResolution?: string,
7
maxResolution?: string,
8
aspectRatio?: string,
9
minAspectRatio?: string,
10
maxAspectRatio?: string,
11
scan?: 'interlace' | 'progressive',
12
orientation?: 'portrait' | 'landscape',
13
displayMode?: 'fullscreen' | 'standalone' | 'minimal-ui' | 'browser',
14
}
15
16
type TBreakpoints = {
17
[breakpointName: string]: TBreakpoint,
18
}
Copied!

Example

src/App.jsx
1
import Layout from 'atomic-layout'
2
3
Layout.configure({
4
breakpoints: {
5
mobile: {
6
maxWidth: 500,
7
},
8
tablet: {
9
minWidth: 501,
10
maxWidth: 764,
11
},
12
retina: {
13
minResolution: '300dpi',
14
},
15
},
16
})
Copied!
src/components/SomeComponent.jsx
1
<Composition
2
areasMobile={...}
3
areasTablet={...}
4
paddingRetina={10} />
Copied!
Make sure to explicitly provide a default breakpoint name when using custom breakpoints, so Atomic Layout knows when to apply props that have no breakpoint suffix.

defaultBreakpointName

Value type
String
Default value
"xs"
Description
The name of a default breakpoint used for the props without an explicit breakpoint suffix.

Example

src/App.jsx
1
import Layout from 'atomic-layout'
2
3
Layout.configure({
4
defaultBreakpointName: 'mobile',
5
breakpoints: {
6
mobile: {
7
maxWidth: 576,
8
},
9
desktop: {
10
minWidth: 768,
11
},
12
},
13
})
Copied!
src/components/SomeComponent.jsx
1
<Composition
2
padding={...}
3
paddingDesktop={...} />
Copied!
Breakpoint-less padding prop is now applied on the mobile breakpoint by default.