UX-DSL
XS0px

Breakpoints

Define responsive thresholds once. Keep layout and Density aligned with your theme.

One set of thresholds for responsive decisions.

Breakpoints name the viewport widths where responsive rules begin to apply. The theme JSON defines the thresholds, components use those names for layout changes, and Density uses them to make Spacing responsive. Prefer Density for component spacing; use explicit breakpoint values for layout behavior and deliberate local exceptions.

A name such as md identifies a configured threshold. It does not detect a tablet, orientation or input device. These examples use viewport width, not container width.

1. Define breakpoints in your theme JSON

This excerpt uses the shared engine defaults. Your theme can configure different values:

{
  "breakpoints": {
    "xs": 0,
    "sm": 480,
    "md": 768,
    "lg": 1024,
    "xl": 1280
  }
}
Default minimum viewport widths
NameMinimum width
xs0px
sm480px
md768px
lg1024px
xl1280px

Keep xs at zero for these examples and use ordered, distinct thresholds. Feed the configured map into your build/runtime integration so the generated CSS and active theme use the same definitions.

2. Declare what changes at a threshold

UXDSL you write

.layout {
  display: flex;
  flex-direction: xs(column) md(row);
}

Equivalent plain CSS

.layout {
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  .layout { flex-direction: row; }
}

With these defaults, the layout is a column below 768px and a row at that width and above. The threshold is inclusive. This is a discrete change, not a fluid interpolation.

A declared value continues to apply until a later applicable rule overrides it. At lg, this example still uses md(row) because no lg() override was declared. The active viewport breakpoint and the rule supplying a property’s value are not necessarily the same.

How this example keeps its most recent applicable value
Viewport widthflex-directionSupplying rule
Below 768pxcolumnxs(column)
From 768px up to, but not including, 1280pxrowmd(row) remains active through lg
1280px and aboverowmd(row) remains active unless a later rule overrides it

3. Let Density manage shared responsive spacing

{
  "densities": {
    "4": "xs(space(4)) md(space(5)) xl(space(6))"
  }
}

This additional theme excerpt assumes spacing entries 4, 5 and 6 exist.

.layout {
  display: flex;
  flex-direction: xs(column) md(row);
  padding: density(4);
}

The component defines its layout transition; Density defines its spacing progression. Changing md changes when both rules apply after the configuration is compiled or applied. Changing only a Density mapping changes spacing without moving the layout threshold.

Do not repeat a Density progression locally merely because it produces the same result today. Use space() for intentional stable spacing, explicit responsive values for deliberate local exceptions, and standard CSS when finer control is needed.

Explore the current viewport

The playground below reports the actual browser viewport and edits its breakpoint configuration. Moving a threshold does not resize the browser. Move md across the current viewport width to inspect the transition. Editor constraints keep thresholds ordered; browser overrides may persist. These edits do not write your source JSON file.

Interactive Playground

xs≥ 0px
sm≥ 480px
md≥ 768px
lg≥ 1024px
xl≥ 1280px

Adjust Breakpoints

xs
px
sm
px
md
px
lg
px
xl
px
Window Width0px
Active TokenXS

Resize your browser window to see the active token change in real-time.

Live layout example

The cards below switch from column to row at md. This excerpt matches their responsive declarations. Their spacing is a deliberate local progression for this demonstration; prefer Density for shared component spacing.

#DemoBreakpointsCards {
  display: flex;
  flex-direction: xs(column) md(row);
  gap: xs(space(2)) md(space(4));
  padding: xs(space(3)) md(space(6));
}
Fluid Layout
Layouts that flow naturally across device sizes.
Adaptive
Styles that change based on the viewport width.
Modular
Component-based design for maximum reusability.

Runtime configuration

In a browser integration with UXDSL-generated styles loaded, the runtime exposes breakpoint updates:

import { breakpoints } from 'postcss-uxdsl/ds-runtime'

const current = breakpoints.get()
breakpoints.update('md', 800)

const unsubscribe = breakpoints.subscribe((event) => {
  if (event.type === 'breakpoint') {
    console.log(breakpoints.get())
  }
})

// Call during cleanup when the subscriber is no longer needed.
unsubscribe()

The subscription reports configuration updates; it is not a viewport-resize subscription. A runtime change does not edit the JSON file. Verify the resulting media rules in your integration, especially when stylesheets or overrides are loaded separately.

AI implementation guide

How an AI agent should use Breakpoints

Breakpoints name the viewport widths where responsive rules begin to apply. The theme JSON defines the thresholds, components use those names for layout changes, and Density uses them to make Spacing responsive. Prefer Density for component spacing; use explicit breakpoint values for layout behavior and deliberate local exceptions.

Responsibility: preserve the shared responsive thresholds. Decide whether the request changes a component’s behavior, a Density mapping, or a system-wide threshold before editing configuration.

  • Read the actual theme’s breakpoints. Do not import values from another framework or infer device types from breakpoint names.
  • Use configured breakpoint names for explicit responsive layout changes. Define a base value when needed, and remember that the most recent applicable rule remains active until a rule at another configured breakpoint overrides it.
  • Prefer existing Density tokens for component spacing. Read their mappings before changing a breakpoint they depend on.
  • Change a shared threshold only when all affected responsive rules should move. For a local change, adjust the component’s responsive declarations using existing breakpoint names, or choose a deliberate local exception.
  • Do not replace Density with local breakpoint values just because their current computed values match. Preserve the intended system dependency.
  • Define required new thresholds through supported configuration before using them, and check support in the runtime and editor integrations. Do not assume all tools accept arbitrary names.
  • Keep source configuration aligned with compiler/runtime inputs. A browser-only override or manually edited generated CSS is not an update to the theme JSON.
  • Verify just below, at and just above affected thresholds, using valid nonnegative widths. Check intermediate inheritance, layout overflow, dependent Density rules and other shared consumers.

Decision rule: Change the component to change local behavior. Change a breakpoint to intentionally move a shared threshold. Change Density to adjust shared responsive spacing.

Configuration and usage example

{
  "breakpoints": {
    "xs": 0,
    "sm": 480,
    "md": 768,
    "lg": 1024,
    "xl": 1280
  }
}
.layout {
  display: flex;
  flex-direction: xs(column) md(row);
}
How this example keeps its most recent applicable value
Viewport widthflex-directionSupplying rule
Below 768pxcolumnxs(column)
From 768px up to, but not including, 1280pxrowmd(row) remains active through lg
1280px and aboverowmd(row) remains active unless a later rule overrides it

Agent reasoning example

Move the shared md transition to 800px across the application.
  1. Inspect the active configuration and confirm 800px fits between the intended neighboring thresholds.
  2. Find component rules and Density mappings referencing md. Confirm the request includes these consumers.
  3. Update breakpoints.md in the source JSON and apply it through the project’s build or runtime integration.
  4. Verify the column layout at 799px and row layout at 800px and 801px. Check Density transitions and consumers without an explicit md() rule.
  5. Check a later breakpoint to confirm the row value persists unless another declaration overrides it.

Breakpoints define when. Components and Density define what changes.