When Components Become Recipes: The Hidden Logic of Reusable Design
Hatched by min dulle
Aug 01, 2026
9 min read
1 views
61%
The real question hidden in “Recipes” and “Step 1: CSS(f)”
What if the hardest part of building on the web is not writing CSS at all, but deciding what kind of thing CSS should be?
That question sounds abstract until you notice a quiet shift happening in frontend development. For years, styling was treated like decoration, something attached after the real work was done. Then teams discovered that styling itself needed structure, repetition, constraints, and composition. A page was not just a page. A button was not just a button. Each one had variants, states, contexts, and rules that had to be managed consistently across a growing system.
This is where the idea of a recipe becomes unexpectedly powerful. A recipe is not a finished dish. It is a reusable method for producing many dishes with predictable qualities while still allowing variation. In the same way, modern styling is moving away from one-off declarations and toward patterned instructions that can generate interface parts reliably. The tension is not between design and code. It is between ad hoc output and repeatable creation.
CSS is not a paint layer, it is a production system
Most people first meet CSS as a language of appearance: colors, spacing, typography, borders. But once a project grows, CSS stops behaving like a surface treatment and starts behaving like a manufacturing process. The same card must appear in a list, a dashboard, a search result, and a preview panel. The same action button must handle hover, focus, disabled, loading, and destructive states. If each of those is styled independently, consistency decays quickly.
That is why the phrase Step 1: CSS(f) is more revealing than it first appears. It suggests that styling is no longer just CSS in the old sense. It is CSS as a function, a thing you invoke with inputs and expect to return a controlled output. This changes the mental model entirely. Instead of asking, “What style do I write here?” you ask, “What arguments does this component accept, and what visual result should those arguments produce?”
A useful analogy is a kitchen. Old CSS resembles scattered handwritten notes taped to every appliance: “Add 3 minutes when the oven is cold,” “Use less salt for this pan,” “Check the sauce by eye.” A recipe system turns those notes into a coherent method. You define ingredients, variants, and steps. Then the kitchen can reproduce results without reinventing the process each time.
The real value of CSS is not in describing style once. It is in describing style so it can be generated, repeated, and trusted.
This is why styling systems increasingly favor recipes, variants, and composable definitions. They recognize that the unit of value is not a single rule. It is a reusable styling contract.
The recipe mindset: from static rules to controlled variation
A recipe is fascinating because it sits between rigidity and freedom. If it is too strict, it becomes brittle and unusable. If it is too loose, it becomes useless. Good recipes define enough structure to guarantee outcomes while leaving room for meaningful variation. That balance is exactly what mature UI systems need.
Think about a button. At the surface, it seems trivial. But a real design system needs a button to express tone, size, emphasis, and state. It may need primary, secondary, destructive, subtle, and ghost variants. It may need compact and large sizes, icons, loading indicators, and different interaction states. Writing each combination as separate CSS classes quickly becomes a combinatorial mess.
A recipe approach changes the question from “How many classes do I need?” to “What dimensions of variation matter?” That is a profound shift. You stop encoding every visual possibility directly and instead define a parameter space. In this space, one axis might be intent, another size, another state. The styling system can then generate valid combinations without forcing humans to handcraft all of them.
This is the deeper promise of recipe based styling: it makes styling legible as logic. You can inspect the ingredients, the possible outputs, and the constraints. You can see which values are allowed and which ones are intentionally excluded. Rather than scattering design knowledge across a codebase, you concentrate it into a form that is easier to maintain and reason about.
The payoff is not only cleanliness. It is governance. A recipe can encode design rules as architecture. That means a system can say, implicitly but firmly, “These are the only button variants we support,” or “This spacing scale is valid, and everything else is off limits.” In large codebases, that kind of constraint is not a limitation. It is a relief.
The hidden tradeoff: flexibility versus coherence
At first glance, recipes and CSS functions seem like tools for making things easier. They are. But their real importance lies in how they resolve a classic frontend tension: individual freedom versus system coherence.
Pure CSS freedom is seductive. It lets anyone tweak anything, anywhere, at any time. But that freedom scales poorly. Over time, the system becomes a museum of one-off decisions. Spacing no longer aligns. Buttons drift apart. Similar components differ in tiny ways that users notice even when engineers do not. What began as flexibility turns into entropy.
On the other hand, rigid component systems can become oppressive. If every style decision is hardcoded into a component, small changes require awkward workarounds. Teams may begin to fear refactoring because the system feels too monolithic. The styling layer becomes a fortress instead of a toolkit.
Recipes offer a third path. They allow flexibility inside a governed envelope. The envelope is important. It tells teams, “You may vary these fields, but not those.” That is how real design systems achieve both consistency and adaptability. They are not collections of static templates. They are rule bound generators.
Here is the key insight: the goal is not to eliminate variation. The goal is to make variation explicit. Once variation is explicit, it can be tested, documented, reviewed, and improved. Implicit variation is where systems deteriorate.
A restaurant does not survive because every cook improvises from scratch. It survives because recipes preserve the identity of the menu while still letting a cook respond to real constraints. Frontend systems need the same discipline. When CSS is treated as a recipe, the team can preserve a shared visual language without freezing creativity.
A practical mental model: ingredients, transforms, and guarantees
To make this concrete, it helps to think of recipe based styling as having three layers.
1. Ingredients
These are the design tokens and values that matter: color, spacing, typography, radius, shadow, motion, density. Ingredients are the vocabulary of the system. If your ingredients are vague, your recipes will be vague too.
A strong styling system does not begin with classes. It begins with a stable token set. For example, instead of “blue 500” and “blue 600” being arbitrary visual picks, they become sanctioned ingredients with defined roles: action color, emphasis color, subdued color, focus ring color.
2. Transforms
These are the rules that combine ingredients into component outputs. A transform says that a destructive button uses a certain background and hover treatment, or that a compact variant reduces vertical padding while preserving alignment. This is where CSS becomes functional. Input in, output out.
The value of transforms is that they make design decisions repeatable. If the same logic is needed in ten places, the transform ensures those ten places behave the same way. That reduces not just duplication, but interpretation errors.
3. Guarantees
This is the most overlooked layer. A recipe should not only produce something. It should produce something predictable. If a value is invalid, the system should make that obvious. If a variant does not exist, it should not be silently approximated. If a design rule is broken, it should fail visibly enough to matter.
Guarantees are what turn styling from a bag of utilities into a reliable system. They are the reason recipes are so useful for teams that care about scale. A guarantee is a kind of institutional memory. It says, “We solved this once. You do not need to solve it again in an inconsistent way.”
Good UI systems do not merely generate styles. They generate confidence.
Why this matters beyond styling
The reason recipes are intellectually interesting is that they point to a broader pattern in software design. As systems grow, we increasingly prefer descriptions of generation over manual assembly. This is true in styling, but also in tests, content pipelines, infrastructure, and data transformations.
Whenever a domain becomes repetitive enough, teams begin to encode its logic as a recipe. Not because people dislike craftsmanship, but because craftsmanship without a recipe does not scale. The deeper lesson is that mature systems distinguish between the part that should be improvised and the part that should be standardized.
Styling is one of the clearest places where this distinction matters. Visual consistency is highly visible to users and expensive to fix after the fact. If a product team treats CSS as a scatter of local decisions, they will eventually spend huge energy cleaning up visual debt. If they treat CSS as a recipe system, they invest that energy upfront in structure.
This is also why the idea resonates with archives, documentation, and long lived sites. An archive is not just a collection of pages. It is a commitment to preserving meaning across time. Styling must support that commitment. A system of recipes helps ensure that old and new pages remain visually coherent even as the site evolves. The archive stays readable not because every page is identical, but because the rules for sameness and difference are consciously designed.
Key Takeaways
-
Treat CSS as a system of generation, not just decoration. Ask what inputs your components accept and what outputs those inputs should produce.
-
Define variation explicitly. Identify the small set of dimensions that actually matter, such as size, intent, density, and state.
-
Use constraints to protect consistency. Strong styling systems are not less creative, they are more governable.
-
Separate ingredients from transforms. Tokens define what is available. Recipes define how those values combine into real UI.
-
Design for guarantees, not just appearance. A good system makes valid states easy and invalid states hard.
The deeper lesson: style is a language for making promises
The biggest mistake in frontend thinking is assuming that styling is a finishing touch. In reality, styling is a promise about behavior, identity, and trust. When a button looks the same everywhere it appears, the product feels coherent. When spacing is systematic, content feels intentional. When variants are controlled, users can learn the interface faster.
Recipes make that promise scalable. They turn the ambiguity of CSS into something more like a grammar. A grammar does not write the sentence for you, but it makes certain sentences possible and others impossible. That is exactly what a design system needs. It needs enough freedom to adapt, and enough structure to remain itself.
So the next time styling feels tedious, it may be worth asking a more radical question: are we still treating CSS as a collection of rules, or are we ready to treat it as a method of production? The answer changes everything. Once you see styles as recipes, you stop chasing isolated fixes and start building a language that can scale, survive, and stay beautiful under pressure.
Sources
Hatch New Ideas with Glasp AI 🐣
Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)
Start Hatching 🐣