📐 ZSS – Sass for design systems
ZSS is a Sass framework that helps you build design systems with configurable design scales.
- How to use
- Add-ons and tools
This overview provides an in depth view of all of the available properties/classes in ZSS.
What it does
- Provides a simple base for your typography.
- Provides abstractions of common UI patterns, so you can focus on the specific design details.
- Functional CSS: generates immutable, configurable, and responsive utility classes.
- Provides a flexible and configurable flexbox grid.
- Provide compile time checking of your configuration for design smells.
What it doesn’t do
- No pre-defined colors.
ZSS is built on a few principles.
- Composition over repetition
classattribute is perfect for composing your design with multiple classes. It leads to better re-usability of your design and smaller CSS stylesheets.
- Configurable and optional
In ZSS, generated utility classes have configurable values. Need an extra value, or don’t like the default values? Just override a variable in your project. Don’t need the button abstraction class? Just don’t import it.
All utility classes have responsive equivalents, so you can use different values on different screens.
- Design scales
ZSS uses scales to limit the number of available values for certain properties, like
npm install zss --save
After that, import the files you need into your Sass stylesheet.
@import "../node_modules/zss/src/helpers/responsive"; @import "../node_modules/zss/src/utilities/margin";
zss.scss as a starting point for your project's stylesheet. It imports all files that are available in ZSS.
ZSS uses namespaces, similar to the system CSS Wizardry wrote about.
o-prefix for abstract objects.
u-prefix for utility classes.
ZSS advocates importing sources files in the way ITCSS prescribes, with an inverted specificity.
- Settings and variables
- Mixins and other Sass helpers
- Generic: common resets
- Base: unclassed HTML and page setup
- Abstract objects
- Visual classes
- Utility classes
ZSS uses an
@breakpoint suffix to indicate if a class only works on a certain breakpoint, e.g.
How to use
Configuration and variables
All ZSS variables are defined in variables/_zss-defaults.scss. Override them at will in your project.
@import '../node_modules/zss/src/variables/zss-defaults'; @import 'variables/zss-overrides';
||Limited set of values for opacity utility classes.|
||Limited set of values for border-radius utility classes.|
||Limited set of values for border-width classes.|
||Limited set of values for margin and padding utility classes.|
||Limited set of values for font-size utility classes.|
||Limited set of values for line-height utility classes.|
||Limited set of values for width utility classes.|
||Limited set of values for width utility classes, in percentages.|
||Limited set of values for max-width utility classes.|
||Limited set of values for height utility classes.|
||Limited set of values for height utility classes, in percentages.|
||Sass map with color definitions for text, backgrounds and borders utility classes.|
||Sass map containing the max width of the grid on each breakpoint.|
||The number of columns a grid row can have.|
||The amount of whitespace between grid column.|
||Sass map containing breakpoint names and screen sizes.|
||Sass map containing color definitions for border utility classes.|
||Font size used a base for
||Base line-height applied to the BODY element.|
||The margin between the image and text of media objects.|
ZSS provides compile time checking of the configuration. Import
dev/strict if you want to:
- Check if the design scales are properly ordered.
- Check if there are any so called design smells, like too many font sizes in your scales.
See the documentation for more details.
Helpers are mixins, functions, and similar programmatic constructs in Sass that help with code re-use. ZSS provides these helpers:
- color: function for accessing pre-defined colors.
- grid: mixin for generating grid classes.
- hover: mixin for generating flexible hover effects.
- responsive: mixin for dealing with responsive declarations.
- units: functions for dealing with units and values.
The generic folder contains CSS applied at a global level:
The base folder contains CSS applied to specific elements:
Objects are classes that define the structure of a common UI pattern, like the popular media object. ZSS provides these objects:
- button: a gathering of properties most used in buttons.
- grid: a grid structure to create a layout with rows and columns.
- list-reset: resets ordered and unordered lists.
- media: image next to text.
Utility classes have a single responsibility. In other words, they affect the value of just one single CSS property. (This
construct is also known as functional CSS.) The most common CSS properties are available in ZSS and are listed
in the property index
Add-ons and tools
These tools and add-ons make working with ZSS even easier.
CLI that parses the output of http://www.color-blindness.com/color-name-hue/ for easy converting of a hexadecimal color value to a name that can be used in ZSS to generate class names (e.g.