Skip to content

Unigrid

A layout system for React, set on the B‑module of the National Park Service publications.

A layout in the construction of the 1985 specification, with its band and its bar, is authored on twelve columns and stands as written while its window holds them all. As the window narrows, its cells move onto the whole modules each width holds.

The module

Every layout is built from one module, 84 by 80 pixels by default, with 12 pixels between columns and 10 between rows. A container holds as many of them as fit whole.

From picas to pixels

The 1985 specification sets the B‑module 7 picas wide and 80 points tall: 84 by 80 points.

Unigrid reads those points as CSS pixels, so the figures carry across unchanged. CSS sets 96 pixels and 72 points to its inch, so the module in pixels is three quarters of the module in points.

Whole modules, centred

A container holds as many complete modules as its width allows: the width and one interval, divided by the 96 pixel pitch, rounded down. CSS auto-fill arrives at the same count; Unigrid computes it itself, so it can centre the field and place every cell on it.

In a fluid layout, what is left over is always smaller than a module and its interval, and it is divided evenly between the two sides. An authored layout stops at its own columns and centres its field in the rest.

Composition

A cell is placed by its coordinates when its position matters, or in sequence by its span. Both stand on the same module.

Coordinates, released together

With a numeric authoredColumns, a cell can carry an x, y, w and h, counted in modules.

When the container holds fewer columns, every coordinate is released at once and the cells take their source order. A reader sees the layout you wrote complete, or every cell in sequence.

Spans in sequence

With authoredColumns set to fluid and reflowFlow set to pack, cells carry spans only. They keep their size and fill each row in source order.

The field takes every complete module the container holds.

No format in the Unigrid System requires any alteration in size of type, maps, or illustrations. Small formats are not miniatures of larger formats.

National Park Service, Unigrid Design Specifications, 1985

Read it, then resize it

Each drawing is Unigrid itself, given the props in its code and shown with its guide, at the width you set.

import { Unigrid, Cell }
  from '@khannaoffice/unigrid'
 
<Unigrid
  authoredColumns={6}
  initialColumns={6}
>
  <Cell x={0} y={0} w={4} h={2}>
    Main
  </Cell>
  <Cell x={4} y={0} w={2} h={2}>
    Aside
  </Cell>
</Unigrid>
Main
Aside

Install

Unigrid needs only React. The command installs both.

npm install @khannaoffice/unigrid react
Size
About 10 KB, minified and gzipped. The layout arithmetic alone is about 2 KB.
React
Version 18 or 19, the peer range >=18 <20. Tested with 18.3.1 and 19.2.6.
Format
ES modules, with TypeScript declarations.
Dependencies
None.
Next.js
Use it inside a client component. The package does not include the "use client" directive.
Licence
KhannaOffice Unigrid License 1.0, source-available. You may use it in the websites and web applications you make, for yourself or for clients. You may not redistribute it as a library, template or other reusable product.
Published