liveBook · Manning

Pattern library

As explained in CSS in Depth, Second Edition

A pattern library is a separate collection of documentation pages that showcases reusable interface patterns and their implementation.

A pattern library is a separate set of HTML pages that inventories and showcases reusable CSS modules. It is a development tool, not part of the site or application. When a stylesheet has many modules, the library helps you find an existing pattern before writing more CSS. section 9.4 section 9.0

Use the library as part of a CSS-first workflow:

  • Start with a sketch or mockup. Look for existing modules, assembling the page from outer layout and containers inward. section 9.4.1
  • If a needed module or variant is missing, set the page aside. Build and document the pattern in the library, check how it looks and behaves, then use it on the page. section 9.4.1

Choosing a list style

Suppose several pages need styled lists. Reusing a few documented list modules avoids creating a different list style for every page. If none fits, develop the new style separately before adding it to a page. section 9.4.1

The library can be hand-built HTML pages, or it can use a tool such as Storybook when the application uses a supported JavaScript framework. Choose an approach that fits the team’s technology; the important part is an accessible inventory of available modules. section 9.4

Treat incompatible changes deliberately. One option is to update every affected page’s HTML. Another is to mark the old module as deprecated in the library and introduce a replacement, allowing both to work during migration. CSS versions can communicate whether a release contains fixes, compatible additions or deprecations, or removal of deprecated modules. section 9.4.2

How CSS in Depth, Second Edition covers it

How deep it goes
Gives a CSS-first workflow and a deprecation strategy, but leaves the library’s implementation dependent on the team’s technology.
Examples
Uses repeated list styling to illustrate reuse and suggests Storybook or hand-built HTML pages for the inventory.
What it assumes
Assumes familiarity with HTML pages, stylesheets, and CSS modules; does not teach their construction from zero.
What you can do after
Practice/perform CSS-first page assembly by reusing documented modules and developing missing ones in isolation.
How it connects
Connects CSS modules and variants with CSS-first development, page assembly, deprecation, and Semantic Versioning.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.