Getting started

Introduction

ZASPR Kit is a utility-first CSS framework written entirely in Dart. It reads your components, finds the classes you use and generates the matching stylesheet.

How it works

Instead of writing selectors and CSS rules, you compose styles directly in your components with small classes: p:4 for padding, bg:blue for a background, md:cols:3 for three columns from tablet width up.

The CLI walks through your Dart files, extracts those classes and writes a stylesheet that contains only what is actually used. No JavaScript is needed at runtime and no Node.js tool is involved in the toolchain.

A first example

lib/components/profile_card.dart
div(classes: 'flex ai:center gap:3 p:4 br:lg bg:white sh:md', [
  img(src: 'avatar.png', classes: 'w:12 h:12 br:full'),
  div([
    p(classes: 'fw:semibold c:gray-900', [.text('Ada Lovelace')]),
    p(classes: 'fs:sm c:gray-500', [.text('Engineer')]),
  ]),
])

Each class maps to one or more CSS declarations:

flex
.flex {
  display: flex;
}
ai:center
.ai\:center {
  align-items: center;
}
gap:3
.gap\:3 {
  gap: 0.75rem;
}
br:lg
.br\:lg {
  border-radius: 0.5rem;
}
sh:md
.sh\:md {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

Why JX

  • Pure Dart: the classes, the compiler and the components are one package, jx_cli. No Node.js, no Tailwind binary to download.
  • Built for Jaspr: classes live in the classes attribute of your components, with no CSS file to maintain.
  • A clean syntax, [variants:]utility[:value][!], that reads unambiguously and rejects invalid classes.
  • Safe arbitrary values: anything that could inject CSS is refused before reaching the stylesheet.
  • A token-based theme: colors, spacing and breakpoints are configured in jx.yaml.
  • A minimal, mobile-first sorted stylesheet that only grows with what you use.
  • An engine usable as a library: this site compiles its examples at render time.

Version 0.0.5

ZASPR Kit is at version 0.0.5: the syntax and the utility catalog may still change before 1.0.

Next steps

  • Install the CLI in your project: see Installation.
  • Learn the class syntax and the variants.
  • Browse the reference of the 113 available rules.