Core concepts

Responsive design

Layouts adapt with breakpoint variants. JX is mobile-first: start with the small screen, then add what changes from a given width.

Mobile first

A class without a breakpoint applies at every width. A class with md: applies from the md width and up, and wins over the unprefixed one because media rules come later in the stylesheet.

fs:base
.fs\:base {
  font-size: 1rem;
}
md : fs : lg
@media (min-width: 768px) {
  .md\:fs\:lg {
    font-size: 1.125rem;
  }
}
xl : fs : xl
@media (min-width: 1280px) {
  .xl\:fs\:xl {
    font-size: 1.25rem;
  }
}

Breakpoints

Variant Applies from
sm: 640px
md: 768px
lg: 1024px
xl: 1280px
2xl: 1536px

A responsive layout

One column on phones, two on tablets, three on large screens, with more padding as the screen grows:

div(classes: 'grid cols:1 md:cols:2 lg:cols:3 gap:4 p:4 md:p:8', [
  for (final item in items) ProductCard(item),
])

Show or hide parts of the interface the same way:

nav(classes: 'hidden lg:flex gap:6', links),   // wide screens
button(classes: 'lg:hidden', [.text('Menu')]),  // small screens
hidden
.hidden {
  display: none;
}
lg:flex
@media (min-width: 1024px) {
  .lg\:flex {
    display: flex;
  }
}

Fluid values

Arbitrary values accept clamp(), min() and max(), for sizes that grow with the viewport without a breakpoint:

fs : [clamp(2rem,5vw,4rem)]
.fs\:\[clamp\(2rem\,5vw\,4rem\)\] {
  font-size: clamp(2rem,5vw,4rem);
}
w : [min(100%,48rem)]
.w\:\[min\(100\%\,48rem\)\] {
  width: min(100%,48rem);
}

Custom breakpoints

Add or replace breakpoints in jx.yaml. A new key becomes a variant right away, sorted by width with the others:

jx.yaml
theme:
  extend:
    breakpoints:
      3xl: 1920px

3xl:cols:6 then applies from 1920 px. The Breakpoints reference lists the defaults.