Composition

Specification

Component that represents a layout composition.

Props

Composition inherits from Box component, thus is accepts the same props and CSS Grid props on top.

Prop name

Type

Description

inline

boolean

Renders composition with display: inline-grid.

circle-info

Composition supports all Prop aliases.

Usage

Define templates

Composition begins by defining a template string that consists of layout (grid) areas.

const areasMobile = `
  logo
  menu
`
circle-info

Template string is just an alias for grid-template-areasarrow-up-right.

Since Atomic layout comes with responsive built-in, you can define multiple layout templates for a single composition based on the breakpoints of your layout.

Render Composition

Once layout templates are defined, pass them as the respective areas props of the Composition. Each area in the template is turned into a React component and being exposed as an argument property of the children function:

circle-check

Configuration

Composition is meant to be configurable. There is a set of Prop aliases you can apply to make composition suit your needs. For example, we can specify a templateCols prop to control the behavior of our columns on different breakpoints:

Examples

Template-less composition

Composition can be used without any templates. In that case it serves as a display: grid wrapper for its children elements. All Prop aliases still apply.

Note that using the Box component is recommended when you don't wish to control elements composition, but want to distribute spacial relation of the parent element.

Boxchevron-right

Simple composition

Nested composition

Using areas templates

It is possible to describe the size of each column/row using a shorthand grid-template syntax.

  • To specify a row size put its numeric value right after the row areas declaration.

  • To specify a column size put a trailing slash (/) and provide each column's dimensions after it.

circle-info

Note that in order to use grid-template syntax you must provide the template string as a value of the template prop of the Composition component.

Last updated