zss
v3.0.0
Published
Sass for design systems
Downloads
120
Maintainers
Readme
📐 ZSS – Sass for design systems
ZSS is a Sass framework that helps you build design systems with configurable design scales.
Documentation
This overview provides an in depth view of all of the available properties/classes in ZSS.
Background
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.
- Unlike Bootstrap, ZSS does not contain pre-made components or JavaScript.
Principles
ZSS is built on a few principles.
- Composition over repetition
Theclass
attribute 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. - Responsiveness
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, likecolor
andmargin
.
Setup
Install:
npm install zss --save
After that, import the files you need into your Sass stylesheet.
@import "../node_modules/zss/src/utilities/background-color";
ℹ️ Please note that some utility classes make use of the responsive helper mixins. To make sure ZSS compiles correctly import these before you import the utility classes:
@import "../node_modules/zss/src/helpers/responsive";
@import "../node_modules/zss/src/utilities/margin";
ℹ️ You can use the accompanying file zss.scss
as a starting point for your project's stylesheet. It imports all files that are available in ZSS.
Structure
Class names
ZSS uses namespaces, similar to the system CSS Wizardry wrote about.
o-
prefix for abstract objects.u-
prefix for utility classes.
Source order
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
- Components
- Scopes
- Theming
- Visual classes
- Utility classes
Responsive
ZSS uses an @breakpoint
suffix to indicate if a class only works on a certain breakpoint, e.g. u-black@md
.
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';
Design scales
Variable | Explanation
------------ | ----------
$zss--opacity-scale
| Limited set of values for opacity utility classes.
$zss--border-radius-scale
| Limited set of values for border-radius utility classes.
$zss--border-width-scale
| Limited set of values for border-width classes.
$zss--spacing-scale
| Limited set of values for margin and padding utility classes.
$zss--type-scale
| Limited set of values for font-size utility classes.
$zss--line-height-scale
| Limited set of values for line-height utility classes.
$zss--width--scale
| Limited set of values for width utility classes.
$zss--width--percentage-scale
| Limited set of values for width utility classes, in percentages.
$zss--max-width--scale
| Limited set of values for max-width utility classes.
$zss--height--scale
| Limited set of values for height utility classes.
$zss--height--percentage-scale
| Limited set of values for height utility classes, in percentages.
Other variables
Variable | Explanation
------------ | ----------
$zss--colors
| Sass map with color definitions for text, backgrounds and borders utility classes.
$zss--grid-max-widths
| Sass map containing the max width of the grid on each breakpoint.
$zss--grid-columns
| The number of columns a grid row can have.
$zss--grid-gutter
| The amount of whitespace between grid column.
$zss--breakpoints
| Sass map containing breakpoint names and screen sizes.
$zss--border-colors
| Sass map containing color definitions for border utility classes.
$zss--base-font-size
| Font size used a base for rem
values.
$zss--base-line-height
| Base line-height applied to the BODY element.
$zss--media-margin
| The margin between the image and text of media objects.
Development checks
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
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.
Generic
The generic folder contains CSS applied at a global level:
Base
The base folder contains CSS applied to specific elements:
Abstract objects
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
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.
Third party
- color-name
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.u-yellow--tangerine
).
Maintainer
- Annemieke van der Hoek (@avanderhoek) – Zicht
- Jurg Roessen (@Hangloozz) – Zicht