v0.1.0 · MIT · SCSS

Layout, and nothing else.

Container, grid, span, gap and offset. Five primitives, configured at compile time and generated for every breakpoint. No colors, no typography, no components to fight with.

Quick start

Working layout in three steps.

No build step required. Grab the compiled CSS, or use the SCSS source when you want to change the defaults.

1

Include the CSS

Download narleaf-full.css (every utility) or narleaf-core.css (the essentials).

<link rel="stylesheet" href="narleaf-full.css">
2

Nest three layers

Container → grid → children. Every class belongs to exactly one of these layers.

<div class="nar-container nar-pi-auto"> <div class="nar-grid nar-gap-auto"> <div class="nar-span-12 nar-span-md-6">…</div> <div class="nar-span-12 nar-span-md-6">…</div> </div> </div>
3

Configure (optional)

Using Dart Sass? Change columns, breakpoints or namespace in one place.

@use "narleaf" with ( $namespace: "layout", $grid-columns: 16, $container-max: 1440px );

How it thinks

Three layers. Three rules.

A class only works on the layer it belongs to. Put it anywhere else and it doesn't throw an error. It just does nothing.

1 · Padding goes on the container

pi-* sits on the same element as container or container-full.

class="nar-container nar-pi-24" class="nar-pi-24"

2 · Gap goes on the grid

gap-*, gi-* and gb-* sit on the same element as grid.

class="nar-grid nar-gap-24" class="nar-gap-24"

3 · Columns go on direct children

span, offset and col-* only work one level below a grid.

.nar-grid > .nar-span-6 .nar-grid > div > .nar-span-6

Playground

Drag the width. Watch the classes.

The preview is a real viewport, so media queries fire exactly as they would in a browser. The code panel highlights which class wins at the current width.

1024 px lg

active overridden waiting for a wider screen

Reference

One naming pattern for everything.

narnamespaceconfigurable - spanutilitywhat it sets - mdbreakpointoptional - 6valuestep or count

No breakpoint means “always”. With a breakpoint it means “from this width up”. Mobile first, every time.

ClassDoesGoes on
containerCenters content, caps width at 1280px.any wrapper
container-fullSame as container, no max width.any wrapper
pi-{0·16·24·32·40}Horizontal padding of the container.container
pi-autoPadding that scales per breakpoint: 16 → 24 → 32 → 40px.container
grid12 equal columns.any element
gap-{0·8·16·24·32·40·48}Row and column gap together.grid
gi-{…} · gb-{…}Column gap only · row gap only.grid
gap-autoGap that scales per breakpoint: 16 → 24px.grid
span-{1–12} · span-autoHow many columns the element takes.grid child
offset-{1–11} · offset-autoPushes the element N columns right.grid child
col-start-{1–13} · col-end-{1–13}Exact start / end column line.grid child

Add a breakpoint to any utility except container, grid, pi-auto and gap-auto:

base0px +
sm640px +
md768px +
lg1024px +
xl1280px +

Make it yours

Configured once. Checked at build time.

Every token is an SCSS variable. Change it in one place and all classes and responsive variants regenerate to match.

  • Any column count, any breakpoint names
  • Namespace applied to classes and CSS variables
  • Turn off utility groups you don't use
  • Optional :where() selectors and @layer
@use "narleaf" with ( $breakpoints: ( mobile: 480px, tablet: 768px, desktop: 1200px ), $container-padding-inline-auto: ( base: 16px, mobile: 16px, tablet: 24px, desktop: 40px ), $gap-auto-values: ( base: 16px, mobile: 16px, tablet: 24px, desktop: 24px ), $nar-output-col-end-utilities: false );

Forget the tablet key in $gap-auto-values and the build stops instead of shipping broken CSS:

Error: [Narleaf] `$gap-auto-values` is missing breakpoint key `tablet`, which exists in `$breakpoints`. Add a `tablet` entry to `$gap-auto-values`.