Theme Configuration: The settings below define your JSON theme. Once configured in uxdsl.theme.json, the mixin above applies these responsive rules automatically.
UXDSL bridges the gap between design tokens and CSS generation, allowing for a truly semantic and adaptable design system that scales with your application.
UXDSL provides a type-safe, token-aware styling experience that integrates seamlessly with modern frameworks.
Figure 1: Token dependency graph
const answer = 42;const theme = { colors: { primary: 'blue' } };UXDSL decouples visual style from HTML tags. While you can write standard HTML, the real power comes from the @ds-typo mixin.
This allows you to apply the visual properties of a "Heading 1" to any element, while maintaining semantic correctness.
Because these mixins are backed by CSS variables, changing the theme instantly updates every instance of that typography style across your entire application—spacing, weight, size, and line-height included.
| Group | Tokens | Best for |
|---|---|---|
| Headings | h1–h6 | Titles, hierarchy, section structure |
| Reading | body, p | Long-form content and UI copy |
| Utility | span, small, caption | Labels, meta, secondary text |
| Code | code, pre | Inline code and blocks |
“Knockout” here means: a typography system that is role-driven, fluid, density-aware, auditable, and easy to evolve without regressions.
| Gap | Why it matters | What to build |
|---|---|---|
| Missing role abstraction | Tokens tied to tags can’t express intent like “label”, “kicker”, “eyebrow”, “metric”. | Add a role layer (e.g. typo_roles) and map roles → details, then apply via @ds-typo(role). |
| No fluid / optical scaling | Breakpoint steps can feel jumpy; headings may look oversized/undersized between breakpoints. | Support fluid values (e.g. clamp-based) or a computed scale per viewport, plus optional optical adjustments. |
| Typography not density-aware | Dense UI needs different sizes/line-heights than roomy layouts, even with the same theme. | Allow density to select a typography preset (or apply density multipliers to size/line). |
| Demo lacks introspection tools | Hard to debug “what resolved where” and why a token looks the way it does. | Add an inspector: resolved values per breakpoint + inherited-from + final CSS vars. |
| Defaults could be stronger | Most users copy defaults; weak defaults lead to inconsistent apps. | Ship stronger built-in scales + role presets + accessibility-first recommendations. |
You can override the default type scale by adding a typography_details section to your uxdsl.theme.json file.
This allows you to fine-tune sizes, weights, and line-heights for every semantic tag.
The fontSize and lineHeight properties support UXDSL's responsive syntax, allowing you to define scaling from mobile to desktop in a single line.
UXDSL supports responsive values using the xs() sm() md() lg() xl() syntax.
When a value is missing at a breakpoint, it inherits from the nearest lower breakpoint that defines it.
| Breakpoint | Value |
|---|---|
| XS | 2rem |
| SM | 2rem (inherits from XS) |
| MD | 2.5rem |
| LG | 2.5rem (inherits from MD) |
| XL | 2.5rem (inherits from MD) |
| Rule | What it means |
|---|---|
| Inherit down | Missing breakpoint values inherit from the nearest lower breakpoint that is defined. |
| Prefer explicit | If a breakpoint is present (e.g. lg(...)), it wins for that breakpoint and above until overridden. |
| Same syntax everywhere | Any string-based typography field can use xs()/md()/… syntax. |
In practice, UXDSL's responsive syntax is most commonly used for fontSize and lineHeight, but the theme schema accepts responsive strings for any string-based typography field.
The demo above is theme-aware and breakpoint-aware: edit typography_details, switch themes, and the rendered samples update immediately.
For a quick sanity check, you can also inspect the generated CSS variables (e.g. --h1-size, --body-line) in DevTools.
| Token | XS | SM | MD | LG | XL |
|---|---|---|---|---|---|
| H1 | 2rem | 2rem | 2.5rem | 3.125rem | 3.875rem |
| H2 | 1.5rem | 2rem | 2rem | 2.5rem | 3.125rem |
| Body | 1rem | 1rem | 1rem | 1rem | 1rem |
| Caption | 0.75rem | 0.75rem | 0.75rem | 0.75rem | 0.75rem |
Typography is configured under typography_details in the theme JSON. Each tag/role supports a set of optional fields.
| Property | Type | Responsive syntax | Typical |
|---|---|---|---|
fontSize | string | ✅ | xs(space(5)) md(space(6)) |
lineHeight | string | ✅ | xs(1.6) md(1.7) |
fontWeight | string | ✅ | "400", "600", "700" |
fontFamily | string | ✅ | "Inter", var(--font-ui) |
letterSpacing | string | ✅ | "-0.02em" |
textTransform | string | ✅ | none, uppercase, lowercase, capitalize |
textDecoration | string | ✅ | none, underline, line-through, overline |
fontStyle | string | ✅ | normal, italic, oblique |
marginBlockStart | string | ✅ | density(2) or 0.5rem |
marginBlockEnd | string | ✅ | density(2) or 0.5rem |
UXDSL makes it easy to keep typography readable across breakpoints by centralizing size and line-height in theme tokens.
| Text role | XS | MD–LG |
|---|---|---|
| Body | 1rem | 1.0625–1.125rem |
| Small | 0.875rem | 0.875–0.9375rem |
| Caption | 0.75rem | 0.75–0.8125rem |
| Role family | Guidance |
|---|---|
| Body / paragraphs | 1.4–1.7 |
| Headings (H1–H3) | 1.1–1.3 |
| Small / caption | 1.3–1.6 |
For normal text, aim for WCAG AA contrast of at least 4.5:1. For large text (e.g. headings ≥ 1.5rem regular weight), 3:1 is often acceptable. This repo includes a palette contrast audit you can run to catch regressions.
| Pattern | Token | Notes |
|---|---|---|
| Card title | h5 | Compact hierarchy for dense UI |
| Form label | caption | Often paired with transform + spacing |
| Hero heading | h1 | Usually needs responsive line-height |
| Metadata | small | Good with reduced emphasis |
UXDSL compiles typography to plain CSS variables and simple selectors. This keeps runtime overhead low and makes the system easy to inspect.
These presets demonstrate how the responsive syntax can express common patterns. Use them as a starting point and tune for your product.