Build beautiful interfaces.The Dart way.
A complete utility-first styling ecosystem for Jaspr. Write expressive classes, build accessible components, and ship faster, powered entirely by Dart.
Classes like md:hover:bg:blue
compile to a stylesheet that holds only what you use. No Node.js.
dart pub add jx_cli
- Dart 3.10.7 or newer
- Jaspr 0.22 and 0.23
- MIT licensed
1div(classes: 'flex ai:center gap:4 p:5 md:p:6 br:xl bg:white sh:lg', [
2 JxAvatar(name: 'Ada Lovelace'),
3 div([
4 p(classes: 'fw:semibold c:gray-900', [.text('Ada Lovelace')]),
5 p(classes: 'fs:sm c:gray-500', [.text('Analyst')]),
6 ]),
7 span(classes: 'ml:auto px:2 br:full fs:xs c:teal-700 bg:teal-100', [
8 .text('Online'),
9 ]),
10])
Ada Lovelace
Analyst
Anatomy of a class
md
:
hover
:
bg
:
blue
!
Variants
md: hover:Breakpoints and states, stackable. Pseudo-elements always go at the end of the selector.
Utility
bgThe property, abbreviated: bg, p, fs, cols, ring…
Value
blueA theme token, a keyword or an arbitrary value in brackets.
Important
!Optional: adds !important to the declaration.
CSS produced by the engine
@media (min-width: 768px) {
.md\:hover\:bg\:blue\!:hover {
background-color: #3b82f6 !important;
}
}
- utility rules
- 113
Counted from the rule registry and the component catalog of jx_cli 0.0.5.
Three parts, one package
jx_cli brings the classes, the tools that compile them and the components built with them. Use the classes alone, or the components on top.
JX CSS
Utility classes with a readable syntax: variants, utility, value, importance. 113 rules in 15 families, on a theme you extend.
div(classes: 'flex gap:4 p:6 md:p:8')
Class syntax
JX Engine and CLI
The compiler, a watch mode, a build_runner builder and a Tailwind migration. Only the classes found in your sources reach the stylesheet.
dart run jx_cli:jx build -w
Command line
JX Components
33 accessible components: buttons, fields, dialogs, drawers, accordions, data tables. Styled with JX, themed by your tokens.
JxButton(onClick: save, [.text('Save')])
Browse the components
A readable, predictable syntax
Variants, utility, value and importance: every class reads from left to right. The CSS below is compiled by the engine when this page is rendered.
Learn the syntaxp:4
.p\:4 {
padding: 1rem;
}
md
:
cols
:
3
@media (min-width: 768px) {
.md\:cols\:3 {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
hover
:
bg
:
blue-700
.hover\:bg\:blue-700:hover {
background-color: #1d4ed8;
}
w
:
[calc(100%_-_2rem)]
.w\:\[calc\(100\%_-_2rem\)\] {
width: calc(100% - 2rem);
}
focus-visible
:
ring
:
2
.focus-visible\:ring\:2:focus-visible {
box-shadow: 0 0 0 2px var(--jx-ring-color, currentColor);
}
Built into your Jaspr workflow
The stylesheet rebuilds inside jaspr serve, the components are ready to use, and jx migrate brings your Tailwind classes along.
See everything newAutomatic builds
The JX builder runs inside build_runner: no second terminal, no watch command.
Components
Buttons, fields, modals, data tables and more, accessible and styled with JX.
Coming from Tailwind
jx migrate rewrites your classes and reports every approximation.
Gradients
grad:to-br from:brand via:ident to:variant
Frosted glass
bblur:md bg:[rgba(255,255,255,0.08)]
Animations
anim:spin motion-reduce:anim:none
Groups
group-hover:tx:2 group-hover:c:ident
Components in action
A settings screen built only with JX Components and a few layout classes. Nothing below is a picture: the fields, the switches and the accordion work.
Try them in the playgroundProfile
Shown to your teammates.
Saved
Your notification settings are online.Who can see my profile?
How do I delete my account?
The engine runs in your browser
The same engine as the CLI, compiled to JavaScript by Jaspr. Pick an example or type classes: the preview and the CSS update on every keystroke.
Open the full playground.px\:6 {
padding-left: 1.5rem;
padding-right: 1.5rem;
}
.py\:3 {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
}
.br\:lg {
border-radius: 0.5rem;
}
.bg\:teal {
background-color: #14b8a6;
}
.c\:white {
color: #ffffff;
}
.fw\:semibold {
font-weight: 600;
}
.hover\:bg\:teal-700:hover {
background-color: #0f766e;
}
.focus-visible\:ring\:2:focus-visible {
box-shadow: 0 0 0 2px var(--jx-ring-color, currentColor);
}
Rendered in an isolated frame with the default theme: hover:, focus: and breakpoint variants apply at the chosen width.
One theme, your tokens
Colors, spacing, typography and breakpoints are tokens. Extend them in jx.yaml without redefining anything, or replace a whole category.
Open the Theme Studio# jx.yaml
content:
- lib
extensions: [dart]
output: web/jx.css
minify: false
reset: true
dark_mode: media
theme:
extend:
colors:
brand: '#2DD4BF'
breakpoints:
3xl: 1920px
Default palette
-
gray -
red -
orange -
yellow -
green -
teal -
blue -
indigo -
purple -
pink
Get started in three steps
Add the CLI, generate the configuration, start the build. The stylesheet only contains the classes found in your sources.
Read the installation guide-
1
Add the dependency
dart pub add jx_cli -
2
Create the configuration
dart run jx_cli:jx init -
3
Build in watch mode
dart run jx_cli:jx build -w
What changes in your workflow
Styling stays in your components and in Dart. Here is what JX takes off your plate.
| Without JX | With ZASPR Kit | |
|---|---|---|
| Toolchain | A separate toolchain to install and keep up to date next to the Dart SDK. | One dev dependency: dart pub add jx_cli. The compiler is Dart. |
| Stylesheet size | Hand-written or framework CSS tends to grow with every page. | Only the classes found in your sources are compiled. |
| Typos | A misspelled class silently does nothing. | The build warns about unknown classes and suggests the closest one. |
| Rebuilds | A second terminal running a watcher. | jx build -w, or the builder inside jaspr serve. |
| Components | Build and style each control, then add the ARIA wiring. | Accessible components, styled with the same classes and theme. |
| Migration | Rewrite every class by hand. | jx migrate converts Tailwind classes and reports approximations. |
Open source, built in the open
ZASPR Kit is MIT licensed. Questions, issues, ideas and pull requests are welcome, and the roadmap says what is planned and not available yet.
On the roadmap
Planned, not available yet. Follow or discuss them on GitHub.
-
Date pickerPlanned, Forms
A calendar grid with full keyboard support: needs its own client component.
-
Command palettePlanned, Overlays
Search across actions, on top of the combobox and the modal.
-
Popover menuPlanned, Overlays
The dropdown on the Popover API, once CSS anchor positioning is in every browser.
-
Custom listboxPlanned, Forms
A combobox with a styled list and active-option keyboard handling.