@tramo-digital/styles
PostCSS style library with dynamic design-token integration. Framework-agnostic,
modular, and built on the Tramo token system.
Key features
- Design-token integration — built on the
tui-tokens hierarchy
(Reference → Semantic → Appearance → Breakpoint → Dynamic States)
- PostCSS powered — imports, nesting, mixins, and custom media queries
- Light / dark mode — automatic theme switching via CSS classes and
data-* attributes
- Responsive — mobile-first breakpoints at 384 px, 768 px, and 1024 px
- Modular — import only the layers you need
- Framework-agnostic — works with React, Vue, Astro, or vanilla HTML
- Zero runtime — pure CSS, no JavaScript required
Installation
npm install @tramo-digital/styles
# or
pnpm add @tramo-digital/styles
Quick start
Import the compiled library
/* Full compiled CSS (tokens + base + layout + components + utilities + themes) */
@import '@tramo-digital/styles';
Import only tokens
/* Design tokens only — no base or component styles */
@import '@tramo-digital/styles/tokens';
Minified build
@import '@tramo-digital/styles/css/min';
Fonts (opt-in)
Self-hosted faces for the families the typography tokens reference: Figtree (body, links,
buttons), SUSE Mono (labels) and Fraunces (headings/display/quotes). They aren't bundled in main.css,
so import them once at the app root:
import "@tramo-digital/styles/fonts.css";
Featured brand faces (Azul Display and Jicara Display, for brands whose products carry a Nicaraguan identity)
have their own stylesheet, @tramo-digital/styles/featured-fonts.css. Their licenses forbid
redistribution, so it only resolves inside this workspace: the npm package leaves
src/fonts/featured/ and dist/fonts/featured/ out.
Vanilla HTML
<link rel="stylesheet" href="node_modules/@tramo-digital/styles/dist/main.css">
Module exports
The exports map in package.json exposes the following paths:
| Export path |
Description |
@tramo-digital/styles |
Full compiled CSS |
@tramo-digital/styles/main.css |
Same as above (explicit) |
@tramo-digital/styles/main.min.css |
Minified compiled CSS |
@tramo-digital/styles/css |
Alias for full compiled CSS |
@tramo-digital/styles/css/min |
Alias for minified CSS |
@tramo-digital/styles/css/min.css |
Alias for minified CSS |
@tramo-digital/styles/css/index.css |
Alias for full compiled CSS |
@tramo-digital/styles/tokens |
Design tokens only |
@tramo-digital/styles/tokens/main.css |
Same as above (explicit) |
@tramo-digital/styles/tokens/* |
Individual token group files |
@tramo-digital/styles/fonts.css |
Self-hosted token fonts (opt-in) |
@tramo-digital/styles/featured-fonts.css |
Featured brand fonts (workspace only, not published) |
@tramo-digital/styles/ui/* |
Component CSS Modules (source) |
Design-token system
Tokens are generated from Tokens Studio and Figma, then output as CSS custom
properties in src/tui-tokens/. The token hierarchy has the following groups:
| Group |
Example variable |
reference |
--global-spacing-16, --global-border-radius-8 |
semantic |
--semantic-background-color-primary |
primitive |
--primitive-* |
pattern |
--pattern-* |
composition |
--composition-* |
appearance-buttons |
--appearance-buttons-primary-* |
appearance-icons |
--appearance-icons-button-* |
breakpoint |
--breakpoint-grid-gutter, --breakpoint-spacing-* |
color-palette |
Light and dark palette sets |
color-source |
--color-swatch-brand-01 |
custom-color |
Named brand and neutral colors |
dynamic-states |
--states-interactive-button-primary-fill-hover |
focus-state |
Focus ring active / inactive |
opacity |
--opacity-0 through --opacity-100 |
status |
Error, information, success, warning |
Using tokens
/* Reference tokens */
.element {
padding: var(--global-spacing-16);
border-radius: var(--global-border-radius-8);
color: var(--color-swatch-brand-01);
}
/* Semantic tokens */
.card {
background: var(--semantic-background-color-primary);
color: var(--semantic-typography-color-text-body);
border: 1px solid var(--semantic-border-color-primary);
}
/* Interactive-state tokens */
.button {
background: var(--states-interactive-button-primary-fill);
}
.button:hover {
background: var(--states-interactive-button-primary-fill-hover);
}
Responsive breakpoints
Three breakpoints are defined as custom media queries in main.css:
| Token |
Min-width |
Typical device |
--sm |
384 px |
Mobile |
--md |
768 px |
Tablet |
--lg |
1024 px |
Desktop |
Range-based queries are also available:
@media (--mobile-only) { /* max-width: 719px */ }
@media (--tablet-only) { /* 768px – 1439px */ }
@media (--desktop-only) { /* 1024px+ */ }
Each breakpoint has a matching class (.tui-sm, .tui-md, .tui-lg) that
injects breakpoint-specific tokens (grid gutter, spacing, typography sizes).
Type scale
Display, heading and quote sizes are fluid: each is a clamp() from its smallest
size at a 360px viewport to its largest at 1440px, multiplied by
--global-font-scale-typography-reference. Body, link, label and button text keep
one size everywhere, with line heights that land on whole pixels. Sizes are in
rem and letter-spacing in em, so text follows the user's font size and the
tracking scales with each size.
| Role |
Sizes (px, 360px → 1440px) |
| Display |
sm 48→96 · md 56→112 · lg 64→128 |
| Heading |
3xs 14→16 · 2xs 20→24 · xs 24→32 · sm 28→48 · md 32→64 · lg 40→80 |
| Quote |
sm 18→20 · md 24→36 · lg 36→64 |
| Body |
xs 12 · sm 14 · md 16 · lg 18 (line heights 18 / 22 / 24 / 28) |
| Link |
sm 14 · md 16 · lg 18 (same line heights as body) |
| Label (mono, uppercase) |
sm 12 · md 14 · lg 16 |
| Button label (uppercase) |
sm 12 · md 14 · lg 16 |
The fluid middle term (--*-font-size-*-fluid-typography-reference) is generated:
after changing a mobile / desktop size in
libs/core/src/designtokens/tui/tokens/base-tokens/reference/typography.json, run
node tools/scripts/fluid-type/build.mjs and then pnpm tokens:transform.
Themes
Light / dark mode
<!-- Light theme (default) -->
<body class="light">…</body>
<!-- Dark theme -->
<body class="dark">…</body>
<!-- Auto — follows system preference -->
<body class="auto" data-theme="auto">…</body>
Overlay tokens
Veils over imagery (scrims, frosted glass) use the overlay tokens, which follow
the colour palette (data-tui-color-palette="light" | "dark"):
| Token |
Light |
Dark |
--overlay-semantic-color |
white |
black |
--overlay-semantic-scrim-opacity |
0.5 |
0.45 |
--overlay-semantic-backdrop-blur-soft |
8px |
8px |
--overlay-semantic-backdrop-blur-strong |
24px |
24px |
Pair them with --text-body-semantic-color for the copy on top, so text and
veil always contrast:
.hero-veil {
background: color-mix(in srgb, var(--overlay-semantic-color)
calc(var(--overlay-semantic-scrim-opacity) * 100%), transparent);
backdrop-filter: blur(var(--overlay-semantic-backdrop-blur-strong));
}
The themes layer also includes:
- Reduced motion — respects
prefers-reduced-motion
- High contrast — widens focus outlines when
prefers-contrast: high
Layer architecture
The compiled CSS uses Cascade Layers so specificity is predictable across
frameworks:
@layer tokens → Design tokens (tui-tokens)
@layer base → Resets, typography, foundational utilities
@layer layout → Grid, containers, flexbox helpers
@layer components → Buttons, forms, cards
@layer utilities → Single-purpose helpers
@layer themes → Light / dark, accessibility adjustments
Import order is declared in src/main.css — don't reorder.
Source structure
src/
├── main.css # Entry point (import order + custom media)
├── tui-tokens/ # Auto-generated design tokens
│ ├── main.css # Token barrel import
│ ├── reference/ # Global reference tokens
│ ├── semantic/ # Contextual tokens
│ ├── primitive/ # Primitive-level tokens
│ ├── pattern/ # Pattern-level tokens
│ ├── composition/ # Composition-level tokens
│ ├── appearance-buttons/ # Button appearance tokens
│ ├── appearance-icons/ # Icon appearance tokens
│ ├── breakpoint/ # Responsive breakpoint tokens (sm/md/lg)
│ ├── color-palette/ # Light and dark palettes
│ ├── color-source/ # Brand color swatches
│ ├── custom-color/ # Named brand and neutral colors
│ ├── dynamic-states/ # Active, default, disabled, hover
│ ├── focus-state/ # Focus ring states
│ ├── opacity/ # Opacity scale (0–100)
│ └── status/ # Error, info, success, warning
├── abstracts/
│ ├── mixins.css # PostCSS mixins
│ └── smart-media-queries.css # Breakpoint helpers
├── base/
│ ├── reset.css # CSS reset
│ ├── typography.css # Type scale
│ ├── colors.css # Color utilities
│ └── utilities.css # Base-level helpers
├── layout/
│ ├── grid.css # 12-column grid
│ ├── containers.css # Max-width containers
│ └── flexbox.css # Flex utilities
├── components/
│ ├── buttons.css # Button styles
│ ├── forms.css # Form styles
│ └── cards.css # Card styles
├── utilities/
│ ├── spacing.css # Padding / margin utilities
│ ├── sizing.css # Width / height utilities
│ ├── borders.css # Border utilities
│ ├── buttons.css # Button utility helpers
│ ├── display.css # Display utilities
│ └── text.css # Text utilities
├── themes/
│ ├── light.css # Light overrides
│ ├── dark.css # Dark overrides
│ └── utilities.css # Theme utility classes
├── pages/ # Page-level styles
└── vendors/ # Third-party CSS
PostCSS configuration
The library's own postcss.config.js uses these plugins:
export default {
plugins: {
'postcss-import': {},
'postcss-mixins': {},
'postcss-nested': {},
'postcss-custom-media': {},
'postcss-custom-properties': { preserve: true },
'autoprefixer': { flexbox: 'no-2009', grid: 'autoplace' },
// cssnano in production only
}
}
If you consume the source CSS (instead of the compiled dist), make sure your
project's PostCSS config includes the same plugins.
Requirements
- Node.js >= 18.0.0
- pnpm >= 10.0.0
- PostCSS >= 8.4.0 (only if consuming source CSS)
Updating tokens
Pull and transform the latest tokens from Figma / Tokens Studio:
# Full pull + transform
pnpm tokens:update
# Transform locally (skip Figma pull)
pnpm tokens:transform
After updating tokens, rebuild the library:
pnpm nx build @tramo-digital/styles
Build
# Build the compiled CSS
pnpm nx build @tramo-digital/styles
Related packages
- @tramo-digital/react-ui — React component library
- @tramo-digital/vue-ui — Vue component library
- @tramo-digital/core — source scaffolds
- @tramo-digital/types — shared TypeScript definitions
License
MIT © carlosp0veda