Gonk Design: Pattern Library

View the website ←

CSS Compositions

These are flexible, compositional layouts that follow the CUBE CSS composition principles.

Configuration

If you want to change the value of a custom property, you can either set a value in your context, or target the composition itself (E.G .sidebar) for extra specificity.

The default values are fallbacks for custom properties, so are easily overridden.

Gutters and Spacing

All compositions use a consistent --gutter Custom Property to manage spacing between items. You can either set a value for this in context, just like in the configuration section above, or you can use the gutter utility classes.

For example, you could increase the gutter on the sidebar like this: <div class="sidebar gutter-xl">.

Justification and alignment

Each composition has a vertical and horizontal alignment Custom Property if applicable, but you can also use the items and justify Tailwind utility classes like this: <div class="repel items-center">.


Flow

The flow utility provides flow and rhythm between direct sibling elements. Where --flow-space is not defined: the default value is 1em, which equals the font size of the affected element.

More info

Configuration

Property Default value Description
--flow-space 1em This defines the space between each item.

Example

Nullam id dolor id nibh ultricies vehicula ut id elit. Nulla vitae elit libero, a pharetra augue.

Nulla vitae elit libero, a pharetra augue. Cras justo odio, dapibus ac facilisis in, egestas eget quam.

--flow-space set with an inline style to 3em: style="--flow-space: 3em"

You can also use the flow-space generated utility that allows you to use the spacing design tokens. For example, If you want that last paragraph

to have M spacing, from the spacing scale, you would change the code to the following:

Example

Nullam id dolor id nibh ultricies vehicula ut id elit. Nulla vitae elit libero, a pharetra augue.

Nulla vitae elit libero, a pharetra augue. Cras justo odio, dapibus ac facilisis in, egestas eget quam.

--flow-space is set to use XL on the spacing scale, using the flow-space-xl utility class.

Grid

.grid

A flexible layout that will create an auto-fill grid with configurable grid item sizes.

Configuration

Property Default value Description
--gutter var(--space-m) This defines the space between each item.
--grid-min-item-size 20rem How large each item should be, as a minimum
--grid-placement auto-fill Set either auto-fit or auto-fill to change how empty grid tracks are handled

Examples

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8

Cluster

.cluster

A layout that lets you to distribute items with consitent spacing, regardless of their size.

Configuration

Property Default value Description
--gutter var(--space-m) This defines the space between each item.
--cluster-horizontal-alignment flex-start How items should align horizontally. Can be any acceptable flexbox alignment value..
--cluster-vertical-alignment center How items should align vertically. Can be any acceptable flexbox alignment value..

Examples

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8

Repel

A little layout that pushes items away from each other where there is space in the viewport and stacks on small viewports.

.repel

Property Default value Description
--gutter var(--space-m) This defines the space between items.
--repel-vertical-alignment 20rem How items should align vertically. Can be any acceptable flexbox alignment value..

Examples

Item 1 repels item 2
Item 2 repels item 1

.sidebar

A layout that allows you to have a flexible main content area and a "fixed" width sidebar that sits on the left or right. If there is not enough viewport space to fit both the sidebar width and the main content minimum width, they will stack on top of each other

Configuration

Property Default value Description
--gutter var(--space-m) This defines the space between the sidebar and main content.
--sidebar-target-width 20rem How large the sidebar should be
--sidebar-content-min-width 50% The minimum size of the main content area

Exceptions

Exception Description
.sidebar[data-direction='rtl'] Flips the sidebar to be on the right.
.sidebar[data-reversed] Switches the flex direction so you can maintain content ordering while visually appearing flipped.

Examples

A standard sidebar.

Switcher

.switcher

A layout that allows you to lay 2 items next to each other until there is not enough horizontal space to allow that.

Configuration

Property Default value Description
--gutter var(--space-m) This defines the space between each item
--switcher-vertical-alignment flex-start How items should align vertically. Can be any acceptable flexbox alignment value.
--switcher-target-container-width 30rem How large the container needs to be to allow items to sit inline with each other

Examples

Item 1
Item 2

Wrapper

A horizontally centered wrapper that provides a consistent central column.

This should be used in all contexts where the content needs to be in the center of the page.

<div class="wrapper">I am centered and have a nice, consistent gutter.</div>

Examples

I am centered and have a nice, consistent gutter.

Gonk Design: Pattern Library

View the website ←