Anderson Mendoza

Software engineer Cartagena, Colombia

All posts

How this site is made

The design system under this page

· 6 min read

A sheet of Mereframe Components: buttons, a segmented control, a list, facts, a list of contents and a toast, on panels in four hues

Everything on this site is drawn with Mereframe Components, a design system I wrote for my own products. It is the look of mereframe.com and of Lensfield, and it is 111 components in one stylesheet and one script, with no dependencies. The library is not published, so this is not a tour of all of it. It is an account of how it is put together, shown with the eleven parts this page uses, and every line quoted here is in the two files your browser has already fetched.

Six rules

The stylesheet opens with the rules it keeps everywhere:

  • no gradients and no glows, only solid tonal surfaces;
  • soft and rounded, never sharp-edged;
  • a control never grows, moves or reveals text on hover, and a press answers with shape, never with size;
  • hints live in tooltips, never inline;
  • nothing is printed on a photograph;
  • selection is ink, and a hue appears only where it means something.

A design system is mostly decisions made once, so that they are not made again in a hurry. These six settle more than they seem to. The globe on the first page is drawn by hand because the usual library for one draws a lit sphere with a glow around it, and the first rule forbids both.

Paper, panel, control

The page is paper. On it stand panels, which are rounded surfaces a thin gutter apart, and on a panel stand controls. Each surface tells whatever is inside it two things: the ground it is standing on, and the tone a control should take there.

.panel { background: var(--g); --here: var(--g); --tone: var(--g2); }
.btn   { background: var(--tone); color: var(--ink); }

So a button has no variant for each background. It reads its tone from wherever it has been put.

One button, written once, on three grounds.

A ground from one number

A panel’s colours are not chosen one by one. They are worked out from a hue, and from a chroma that says how strong it is, in OKLCH, where a step of lightness looks the same size whatever the hue.

.tone {
  --g:   light-dark(oklch(.915 … var(--h)), oklch(.265 … var(--h)));
  --ink: light-dark(oklch(.27 … var(--h)),  oklch(.96 … var(--h)));
}

The ground, a deeper tone for controls, a lighter one for cards, the ink and a quieter ink all come from that one hue, by day and by night. The lightnesses are fixed and only the hue turns, so the ink keeps its contrast on the ground whichever hue it is given. The side panel of this page is hue 245. Each of the three pictures on the first page stands on a panel whose hue was read off the picture itself.

Five panels, five numbers. Change the theme and each one turns with it.

State is ARIA

The chosen segment of a control is not marked with a class of its own. It carries the attribute a screen reader already reads, and the stylesheet styles that attribute.

.seg > :is([aria-pressed=true], [aria-checked=true], …) {
  background: var(--ink); color: var(--tile);
}

What is said and what is shown cannot drift apart, because they are the same thing. This one works:

Press one, or move between them with the arrow keys.

A press answers with shape

On a press, a button’s corners tighten and nothing else changes. Nothing grows, no shadow appears, and nothing beside it moves.

.btn        { border-radius: calc(var(--h) / 2); }
.btn:active { border-radius: calc(var(--h) * .29); }

The change overshoots a little and settles, as a spring would. The library’s springs are written as CSS easings, so none of this needs a script, and a reader who has asked for less motion gets the same change at once.

Press and hold one.

Hints, and one piece of news

A control explains itself in a tooltip, which comes after a beat on hover or on keyboard focus and never on touch. The same words reach a screen reader, as the control’s name if it has none and otherwise as its description. News arrives as a toast, one at a time, in a region that is announced.

Rest on it for the hint. Press it for the news.

That button is one element with two attributes, data-tip and data-copy. The script finds them, on this page and on anything added to it later.

What this page ships

The whole library is about 85 kB of stylesheet and 85 kB of script, gzipped. That is reasonable for a product and wasteful for a page of words that uses a tenth of it.

Both files are built in named parts, so this site’s build keeps the eleven it draws (button, icon button, segmented group, link, navigation, list of contents, list, facts, toast, tooltip and code) and leaves the rest out. The stylesheet goes from 400 kB to 59, and the script from 289 kB to 21, which is 15 kB and 8 kB gzipped. If a page uses a part that was left out, the build stops and names it.

None of the library’s thirty-three custom elements is among the eleven. Everything on this page is a plain element with a class, which is why it reads the same with the script off.

What it costs

Three things, so far.

It needs a browser from 2024 or later. light-dark(), registered colour properties and the spring easings have no fallback here, and an older browser gets the words without the surfaces.

Its neutrals are warm, and this site wanted them cool. There is no single switch for that. A panel’s hue is one number, but turning the neutrals took fourteen lines that state each one again.

And it looks like what it grew from. The shapes and the springs are Material 3 Expressive’s, and the typeface is Google’s. That suits a camera for Android. Here it is an accent I chose, not one I made.

Up next

  • The globe on this page

    · 5 min read

    The globe on my home page is 2,405 dots on a plain canvas, drawn from a map of one kilobyte. How it is built, and why it is not a library.

  • How diffusion models make images

    · 5 min read

    An image generator starts from static and removes it a little at a time. What it had to learn to do that, where the prompt comes in, and why it is fast.

For work, or about anything I’ve built: hello@mereframe.com