Declarative design systems

When I wrote about the idea of declarative design it really resonated with a lot of people.

I think that there’s a general feeling of frustration with the imperative approach to designing and developing—attempting to specify everything exactly up front. It just doesn’t scale. As Jason put it, the traditional web design process is fundamentally broken:

This is the worst of all worlds—a waterfall process creating dozens of artifacts, none of which accurately capture how the design will look and behave in the browser.

In theory, design systems could help overcome this problem; spend a lot of time up front getting a component to be correct and then it can be deployed quickly in all sorts of situations. But the word “correct” is doing a lot of work there.

If you’re approaching a design system with an imperative mindset then “correct” means “exact.” With this approach, precision is seen as valuable: precise spacing, precise numbers, precise pixels.

But if you’re approaching a design system with a declarative mindset, then “correct” means “resilient.” With this approach, flexibility is seen as valuable: flexible spacing, flexible ranges, flexible outputs.

These are two fundamentally different design approaches and yet the results of both would be described as a design system. The term “design system” is tricky enough to define as it is. This is one more layer of potential misunderstanding: one person says “design system” and means a collection of very precise, controlled, and exact components; another person says “design system” and means a predefined set of boundary conditions that can be used to generate components.

Personally, I think the word “system” is the important part of a design system. But all too often design systems are really collections rather than systems: a collection of pre-generated components rather than a system for generating components.

The systematic approach is at the heart of declarative design; setting up the rules and ratios in advance but leaving the detail of the final implementation to the browser at runtime.

Let me give an example of what I think is a declarative approach to a component. I’ll use the “hello world” of design system components—the humble button.

Two years ago I wrote about programming CSS to perform Sass colour functions. I described how CSS features like custom properties and calc() can be used to recreate mixins like darken() and lighten().

I showed some CSS for declaring the different colour elements of a button using hue, saturation and lightness encoded as custom properties. Here’s a CodePen with some examples of different buttons.

See the Pen Button colours by Jeremy Keith (@adactio) on CodePen.

If these buttons were in an imperative design system, then the output would be the important part. The design system would supply the code needed to make those buttons exactly. If you need a different button, it would have to be added to the design system as a variation.

But in a declarative design system, the output isn’t as important as the underlying ruleset. In this case, there are rules like:

For the hover state of a button, the lightness of its background colour should dip by 5%.

That ends up encoded in CSS like this:

button:hover {
    background-color: hsl(
        var(--button-colour-hue),
        var(--button-colour-saturation),
        calc(var(--button-colour-lightness) - 5%)
    );
}

In this kind of design system you can look at some examples to see the results of this rule in action. But those outputs are illustrative. They’re not the final word. If you don’t see the exact button you want, that’s okay; you’ve got the information you need to generate what you need and still stay within the pre-defined rules about, say, the hover state of buttons.

This seems like a more scalable approach to me. It also seems more empowering.

One of the hardest parts of embedding a design system within an organisation is getting people to adopt it. In my experience, nobody likes adopting something that’s being delivered from on-high as a pre-made sets of components. It’s meant to be helpful: “here, use this pre-made components to save time not reinventing the wheel”, but it can come across as overly controlling: “we don’t trust you to exercise good judgement so stick to these pre-made components.”

The declarative approach is less controlling: “here are pre-defined rules and guidelines to help you make components.” But this lack of precision comes at a cost. The people using the design system need to have the mindset—and the ability—to create the components they need from the systematic rules they’ve been provided.

My gut feeling is that the imperative mindset is a good match for most of today’s graphic design tools like Figma or Sketch. Those tools deal with precise numbers rather than ranges and rules.

The declarative mindset, on the other hand, increasingly feels like a good match for CSS. The language has evolved to allow rules to be set up through custom properties, calc(), clamp(), minmax(), and so on.

So, as always, there isn’t a right or wrong approach here. It all comes down to what’s most suitable for your organisation.

If your designers and developers have an imperative mindset and Figma files are considered the source of truth, than they would be better served by an imperative design system.

But if you’re lucky enough to have a team of design engineers that think in terms of HTML and CSS, then a declarative design system will be a force multiplier. A bicycle for the design engineering mind.

Have you published a response to this? :

Responses

Matthias Ott

“If you’re approaching a design system with a declarative mindset, then ‘correct’ means ‘resilient.’ With this approach, flexibility is seen as valuable: flexible spacing, flexible ranges, flexible outputs.” 👏👏👏, @adactio Declarative design systems adactio.com/journal/19131

blog.jim-nielsen.com

Jeremy has all the right words for getting at nebulous concepts in the industry. This time he’s writing about declarative design systems:

another person says “design system” and means a predefined set of boundary conditions that can be used to generate components.

I like this definition of a design system: a set of boundaries. It’s about saying “don’t go there” rather than “you can only go here”. This embraces the idea of constraints as the mother of invention: it opens the door to creativity while keeping things bounded.

Declarative design systems are about setting boundaries and then ceding control to the individual elements (replace “elements” with “children” here and this starts to sound a lot like parenting…)

The systematic approach is at the heart of declarative design; setting up the rules and ratios in advance but leaving the detail of the final implementation to the browser at runtime.

We might not see ourselves as creating a system of authoritarianism, but if we’re trying to dictate and control every aspect of design that can (and “should”) happen in a system, well, that’s precisely what we’re doing. We might think of our system as a benevolent tool we endow on others, but it’s very possible that’s not how they see it.

One of the hardest parts of embedding a design system within an organisation is getting people to adopt it. In my experience, nobody likes adopting something that’s being delivered from on-high as a pre-made sets of components. It’s meant to be helpful: “here, use this pre-made components to save time not reinventing the wheel”, but it can come across as overly controlling: “we don’t trust you to exercise good judgement so stick to these pre-made components.”

We really need to check this impulse for control. Again, I think a declarative design system doesn’t try to prescribe what can and can’t happen, but rather provide boundaries to circumscribe an area within which anything can happen — or at least be explored.

It makes me think skiing. There’s the groomed runs if you’re starting out and just want to get familiar with the territory. There’s the (often forested) area between groomed runs if you want to explore new areas rarely trodden. And then there’s the ski area boundary: beware all ye who enter here, you’re on your own.

I see good design systems a bit like ski resorts: they groom well-trodden areas, make room for and encourage exploration around the groomed areas, and set limits for exploration beyond logical boundaries which prevent a unified cohesion of the overall whole.

Lastly, I really liked this this observation from Jeremy about design tools:

My gut feeling is that the imperative mindset is a good match for most of today’s graphic design tools like Figma or Sketch. Those tools deal with precise numbers rather than ranges and rules.

The declarative mindset, on the other hand, increasingly feels like a good match for CSS

We shape our tools and our tools shape us. In a way, tools are a part of design system too, in that they define and set boundaries on what’s we think of as possible (or controllable).

As an industry, we love Figma and what we can make with it (I know I do). But it’s worth asking: what does Figma make with us? Where does it limit our creative vision of what’s possible and what we can or even should build?

We often choose to build what we can given the tools we have. But what’s possible beyond the boundaries of our tools? What can we build that our tools don’t yet support? Not only because they haven’t been built into the tool yet, but also because they simply haven’t been imagined yet?

An imperative design system doesn’t entertain these kinds of questions — or at least it creates a lot of friction to asking them. In contrast, a declarative system builds space for this kind of questioning as an exercise in the design system’s process, architecture, and essence.

# Saturday, June 4th, 2022 at 7:00pm

Egor Kloos

This. This is what I’ve been doing. Designer wants a 3 column card layout and I want a column layout with content next to each other that’s legible. Could be three columns, could be more or less. It depends. Being precise without context is design debt. twitter.com/adactiojournal…

# Posted by Egor Kloos on Sunday, June 5th, 2022 at 8:33pm

Aditya Agarwal

Very different way to think about design systems. Instead of restricting what you can do, it suggests what not to do, very akin to how CSS is supposed to mentor browsers not dictate precise values. adactio.com/journal/19131

1 Like

# Liked by Marty McGuire on Tuesday, May 31st, 2022 at 3:58pm

Related posts

Button types

Ideas for some declarative shortcuts.

Five questions

I gave five answers to Oliver, who’s organising the Pixel Pioneers event in Bristol.

Design systems thinking

Do you have a design system or do you have a design analytical?

When should there be a declarative version of a JavaScript API?

If the JavaScript API requires a user gesture, maybe it’s time for a new button type.

Standards processing

Pushing for a share button type—the story so far…

Related links

Retrofitting fluid typography | Clagnut by Richard Rutter

Here’s a taste of what Rich will be delivering at Patterns Day on Thursday—can’t wait!

Tagged with

Invokers (Explainer) | Open UI

This is a really interesting proposal, and I have thoughts.

Tagged with

Pixel Pioneers Bristol 2023 Speaker Spotlight: Jeremy Keith

Oliver asked me some questions about my upcoming talk at Pixel Pioneers in Bristol in June. Here are my answers.

Tagged with

Jeremy Keith – Declarative Design – SOTR - YouTube

Here’s the video of the talk I gave at Monday’s meet-up here in Brighton—it’s a very condensed version of my longer conference talk on declarative design.

Tagged with

Container Queries and Typography

I feel like we need a name for this era, when CSS started getting real good.

I think this is what I’ve been calling declarative design.

Tagged with

Previously on this day

3 years ago I wrote Summertime in England

Won’t you meet me in the country?

5 years ago I wrote The World-Wide Work

You need to see Ethan’s closing talk from this year’s New Adventures conference.

9 years ago I wrote 100 words 070

Day seventy.

12 years ago I wrote Pepys out

The end of an internet era.

15 years ago I wrote Awe Dee Oh

HTML5 and Flash, sitting in a tree.

17 years ago I wrote Alasgone

The land of the midnight sun.