Mastors Core
The enterprise-grade SCSS foundational architecture powering the entire Mastors CDN ecosystem. Design tokens, CSS variables, responsive engine, theming, and utility generators — all in one zero-side-effect package.
Design Token System
50+ brand + neutral + semantic colors, shadows, radius, z-index, opacity, motion tokens.
CSS Variable Engine
Every token auto-synced to --mastors-* custom properties for runtime theming.
Theme Engine
Light, dark & custom themes with data-theme switching. OS preference aware.
Responsive Engine
7 breakpoints. up(), down(), between(), only() mixins. Mobile-first by default.
Utility Generators
Scoped utility classes for colors, shadows, spacing, sizing, display, borders & more.
Accessibility System
Focus visible, sr-only, skip links, reduced motion support. WCAG-aligned defaults.
Helper Mixins
Glassmorphism, neumorphism, skeleton loading, truncate, hover-lift, smooth transitions.
Modern Sass Only
Dart Sass @use / @forward exclusively. No deprecated @import. Fully tree-shakeable.
Installation
Install via npm or yarn
Add Mastors Core as a dependency to your project.
npm install @mastors/core
# or
yarn add @mastors/core
Use the prebuilt CSS (CDN / direct)
Drop the compiled CSS into your HTML for zero-config usage.
<link rel="stylesheet" href="dist/mastors-core.css" />
Import the SCSS API (functions + mixins only)
Use in your SCSS files for a zero-CSS-output API entry point.
// Zero CSS output — only functions, mixins, tokens
@use '@mastorscdn/core' as mc;
Quick Start
@use '@mastorscdn/core' as mc;
.my-card {
background-color: mc.color('surface');
border-radius: mc.radius('lg');
box-shadow: mc.shadow('md');
color: mc.semantic('text-primary');
padding: mc.rem(24);
@include mc.up('md') {
padding: mc.rem(32);
}
}
// Glassmorphism card
.glass-card {
@include mc.glassmorphism(20px, rgba(255,255,255,0.12), rgba(255,255,255,0.2));
}
// Hover lift
.interactive-card {
@include mc.hover-lift;
}
as mc to avoid name collisions in large projects.
With feature flags:
@use '@mastorscdn/core' with (
$enable-dark-theme: true,
$enable-utilities: true,
$enable-accessibility: true,
$mastors-prefix: 'mc'
);
Architecture
Mastors Core follows a strict module hierarchy with clear separation of concerns.
_index.scss is the zero-CSS API entry; mastors-core.scss is the compile entry that outputs the full CSS bundle.
mastors-core.scss ← Compile entry (full CSS output)
│
├── config/ Feature flags, prefix, debug ($enable-*)
├── tokens/ Token maps (colors, shadows, radius, z, opacity, bp, motion, borders)
│
├── functions/ Token accessor functions + math helpers
│ ├── color($key) shadow($key) radius($key) z($key)
│ ├── duration($k) easing($k) breakpoint($k) container($k)
│ └── rem($px) em($px) fluid($min,$max)
│
├── mixins/ Responsive engine + helper mixins + CSS var generator
│ ├── up() down() between() only()
│ └── glassmorphism() neumorphism() hover-lift() skeleton-loading()…
│
├── themes/ Light + dark + custom theme CSS var output
├── base/ CSS reset + motion defaults
├── accessibility/ sr-only, skip-links, focus-visible
├── helpers/ .mastors-container, state classes
├── generators/ Utility class output (colors, shadows, radius, display…)
└── utilities/ Spacing, sizing, border utilities
_index.scss emits zero CSS. It is the pure SCSS API (functions, mixins, tokens). Only mastors-core.scss compiles actual CSS output.
Design Tokens
All design decisions are encoded as SCSS maps and automatically synced to CSS custom properties via the CSS variable engine. Never use magic numbers — always reference a token.
| Token Group | SCSS Variable | CSS Custom Props | Count |
|---|---|---|---|
| Colors (brand + neutral) | $mastors-colors | --mastors-color-* | 40+ |
| Semantic Colors | $mastors-semantic | --mastors-text-* --mastors-bg-* | 16 |
| Shadows | $mastors-shadows | --mastors-shadow-* | 15 |
| Border Radius | $mastors-radius | --mastors-radius-* | 9 |
| Z-Index | $mastors-z-index | --mastors-z-* | 10+ |
| Opacity | $mastors-opacity | --mastors-opacity-* | 16 |
| Breakpoints | $mastors-breakpoints | — | 7 |
| Durations | $mastors-durations | --mastors-duration-* | 7 |
| Easings | $mastors-easings | --mastors-easing-* | 9 |
| Transitions | $mastors-transitions | --mastors-transition-* | 7 |
Colors
Accessed via mc.color($key) in SCSS or var(--mastors-color-*) in CSS.
Brand Colors
Status Colors
Neutral Scale
@use '@mastorscdn/core' as mc;
.element {
color: mc.color('primary'); // #2563eb
background: mc.color('neutral-100'); // #f3f4f6
border-color: mc.color('danger'); // #dc2626
// Semantic
color: mc.semantic('text-muted'); // #6b7280
background: mc.semantic('bg-body'); // #ffffff
}
Color Utility Classes
Shadows
// SCSS token function
.card { box-shadow: mc.shadow('md'); }
.btn { box-shadow: mc.shadow('primary'); }
// CSS custom property
.card { box-shadow: var(--mastors-shadow-lg); }
// Utility class
<div class="shadow-xl">
Border Radius
0
2px
4px
8px
12px
16px
24px
32px
9999px
border-radius: mc.radius('lg'); // 12px
border-radius: mc.radius('full'); // 9999px (pill)
border-radius: mc.radius('xl'); // 16px
Directional classes also available:
Motion Tokens
| Key | Duration | SCSS Access |
|---|---|---|
instant | 0ms | mc.duration('instant') |
fast | 100ms | mc.duration('fast') |
normal | 200ms | mc.duration('normal') |
moderate | 300ms | mc.duration('moderate') |
slow | 500ms | mc.duration('slow') |
slower | 700ms | mc.duration('slower') |
slowest | 1000ms | mc.duration('slowest') |
| Easing Key | Curve |
|---|---|
ease-in-out | cubic-bezier(0.4, 0, 0.2, 1) — default smooth |
spring | cubic-bezier(0.34, 1.56, 0.64, 1) — overshoot spring |
bounce | cubic-bezier(0.68, -0.55, 0.265, 1.55) — bouncy |
smooth | cubic-bezier(0.23, 1, 0.32, 1) — expo out |
sharp | cubic-bezier(0.4, 0, 0.6, 1) — material sharp |
transition: mc.transition('colors'); // color + bg + border transitions
transition: mc.transition('all'); // all 200ms ease-in-out
transition-duration: mc.duration('moderate'); // 300ms
transition-timing-function: mc.easing('spring');
Z-Index & Opacity
Z-Index Scale
| Key | Value |
|---|---|
dropdown | 100 |
sticky | 200 |
fixed | 300 |
modal-backdrop | 400 |
modal | 500 |
popover | 600 |
tooltip | 700 |
toast | 800 |
Opacity Scale
| Class | Value |
|---|---|
.opacity-0 | 0 |
.opacity-5 | 0.05 |
.opacity-10 | 0.1 |
.opacity-25 | 0.25 |
.opacity-50 | 0.5 |
.opacity-75 | 0.75 |
.opacity-90 | 0.9 |
.opacity-100 | 1 |
z-index: mc.z('modal'); // 500
z-index: mc.z('tooltip'); // 700
z-index: mc.layer('dialog'); // layer map accessor
Token Functions
@use '@mastorscdn/core' as mc;. Every function accepts a string key and an optional fallback.
@use '@mastorscdn/core' as mc;
// ── Colors ───────────────────────────────────────────────────
color: mc.color('primary'); // #2563eb
color: mc.color('neutral-700'); // #374151
color: mc.semantic('text-muted'); // #6b7280
// ── Shadows ──────────────────────────────────────────────────
box-shadow: mc.shadow('lg'); // multi-layer shadow
box-shadow: mc.shadow('primary'); // brand colored shadow
// ── Radius ───────────────────────────────────────────────────
border-radius: mc.radius('xl'); // 16px
border-radius: mc.radius('full'); // 9999px
// ── Z-Index ──────────────────────────────────────────────────
z-index: mc.z('modal'); // 500
z-index: mc.layer('dialog'); // layer map
// ── Opacity ──────────────────────────────────────────────────
opacity: mc.opacity('50'); // 0.5
// ── Motion ───────────────────────────────────────────────────
transition-duration: mc.duration('normal'); // 200ms
transition-timing-function: mc.easing('spring');
transition: mc.transition('colors');
// ── Breakpoints ──────────────────────────────────────────────
$bp: mc.breakpoint('md'); // 768px
max-width: mc.container('xl'); // 1140px
// ── Math Helpers ─────────────────────────────────────────────
font-size: mc.rem(18); // 1.125rem
font-size: mc.em(14); // 0.875em
font-size: mc.fluid(16px, 24px); // clamp() fluid scale
$raw: mc.strip-unit(16px); // 16
$pct: mc.percent(3, 12); // 25%
Helper Mixins
hover: hover.Glassmorphism Demo
Glassmorphism Card
Generated with @include mc.glassmorphism(20px). Uses backdrop-filter blur with semi-transparent border.
@use '@mastorscdn/core' as mc;
.glass-card {
@include mc.glassmorphism(
$blur: 20px,
$bg: rgba(255, 255, 255, 0.12),
$border: rgba(255, 255, 255, 0.20)
);
border-radius: mc.radius('xl');
padding: mc.rem(24);
}
.soft-button {
@include mc.neumorphism(#e0e5ec);
border-radius: mc.radius('md');
}
.card {
@include mc.hover-lift($y: -6px);
}
.excerpt {
@include mc.line-clamp(3);
}
More Mixin Demos
Line 2 — custom scrollbar
Line 3
Line 4
Line 5
Line 6
Line 7 — end of content
Responsive Mixins
Breakpoint Scale
@use '@mastorscdn/core' as mc;
.element {
font-size: 1rem; // mobile base
// up($bp) — min-width, mobile first
@include mc.up('md') { font-size: 1.25rem; } // ≥ 768px
@include mc.up('xl') { font-size: 1.5rem; } // ≥ 1200px
// down($bp) — max-width
@include mc.down('lg') { display: none; } // < 992px
// between($lower, $upper) — range
@include mc.between('sm', 'xl') { padding: 2rem; } // 576px–1199px
// only($bp) — single breakpoint slot
@include mc.only('md') { padding: 1.5rem; } // 768px–991px
// Media helpers
@include mc.hover { color: red; } // (hover:hover) and (pointer:fine)
@include mc.prefers-dark { color: white; } // OS dark mode
@include mc.prefers-reduced-motion { animation: none; }
@include mc.print { display: none; }
@include mc.portrait { padding-top: 2rem; }
@include mc.landscape { padding-top: 1rem; }
}
down($bp) uses $value - 0.02px to prevent overlap with up($bp) at the same breakpoint.
You can also pass raw pixel values:
@include mc.up(900px) { ... }
@include mc.down(1100px) { ... }
Utilities
All utility classes are generated from token maps and are guarded by $enable-utilities (default: true). All use !important.
Spacing
Full margin and padding utility system on a rem-based scale (0–96). Pattern: .{m|p}{direction?}-{key}
| Prefix | Property | Example |
|---|---|---|
.m-* | margin (all) | .m-4 → margin: 1rem |
.mt-* | margin-top | .mt-8 → margin-top: 2rem |
.mr-* | margin-right | .mr-auto → margin-right: auto |
.mb-* | margin-bottom | .mb-6 → margin-bottom: 1.5rem |
.ml-* | margin-left | |
.mx-* | margin horizontal | .mx-auto → center block |
.my-* | margin vertical | |
.p-* | padding (all) | .p-4 → padding: 1rem |
.px-* | padding horizontal | .px-6 → 1.5rem L/R |
.py-* | padding vertical | .py-3 → 0.75rem T/B |
Common scale values:
Sizing
Display & Layout
| Category | Classes |
|---|---|
| Display | .d-none .d-block .d-inline .d-inline-block .d-contents .d-table |
| Visibility | .visible .invisible |
| Overflow | .overflow-hidden .overflow-auto .overflow-scroll .overflow-x-hidden .overflow-y-auto |
| Position | .position-static .position-relative .position-absolute .position-fixed .position-sticky |
| Inset | .top-0 .right-0 .bottom-0 .left-0 .inset-0 |
| Cursor | .cursor-pointer .cursor-default .cursor-not-allowed .cursor-grab .cursor-wait |
| Object Fit | .object-cover .object-contain .object-fill .object-scale-down |
| Aspect Ratio | .aspect-square .aspect-video .aspect-cinema .aspect-portrait .aspect-landscape |
| Pointer Events | .pointer-events-none .pointer-events-auto |
| User Select | .select-none .select-text .select-all .select-auto |
Borders
Theme System
Mastors Core ships with a three-tier theme architecture: light (default on :root), dark (via data-theme="dark" or OS preference), and custom themes per brand/product.
Light Theme
data-theme="light" · Applied to :root by default
Dark Theme
data-theme="dark" · Or OS prefers-color-scheme
<!-- Light (default) -->
<html data-theme="light">
<!-- Dark -->
<html data-theme="dark">
<!-- Custom brand theme -->
<html data-theme="enterprise">
class MastorsTheme {
static set(theme) {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('mastors-theme', theme);
}
static get() {
return localStorage.getItem('mastors-theme')
|| (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
}
static init() { this.set(this.get()); }
static toggle() {
const current = document.documentElement.getAttribute('data-theme');
this.set(current === 'dark' ? 'light' : 'dark');
}
}
MastorsTheme.init();
@use '@mastorscdn/core/themes/custom' with (
$theme-name: 'enterprise',
$custom-tokens: (
'--mastors-color-primary': #0f4c75,
'--mastors-color-secondary': #1b4332,
'--mastors-bg-body': #1b262c,
'--mastors-bg-subtle': #16213e,
'--mastors-text-primary': #e2e8f0,
'--mastors-surface': #16213e,
)
);
var(--mastors-*)) for themeable properties like colors and backgrounds. SCSS functions lock values at compile time and won't respond to runtime theme switching.
CSS Variable Reference
/* ── Semantic (theme-aware) ────────────────────────── */
var(--mastors-text-primary)
var(--mastors-text-secondary)
var(--mastors-text-muted)
var(--mastors-text-disabled)
var(--mastors-text-inverse)
var(--mastors-bg-body)
var(--mastors-bg-subtle)
var(--mastors-bg-muted)
var(--mastors-surface)
var(--mastors-border-default)
var(--mastors-border-strong)
var(--mastors-border-focus)
/* ── Brand Colors ──────────────────────────────────── */
var(--mastors-color-primary)
var(--mastors-color-secondary)
var(--mastors-color-accent)
var(--mastors-color-success)
var(--mastors-color-warning)
var(--mastors-color-danger)
var(--mastors-color-info)
/* ── Shadows ───────────────────────────────────────── */
var(--mastors-shadow-sm)
var(--mastors-shadow-md)
var(--mastors-shadow-lg)
var(--mastors-shadow-xl)
var(--mastors-shadow-primary)
/* ── Radius ────────────────────────────────────────── */
var(--mastors-radius-sm) /* 4px */
var(--mastors-radius-md) /* 8px */
var(--mastors-radius-lg) /* 12px */
var(--mastors-radius-xl) /* 16px */
var(--mastors-radius-full) /* 9999px */
/* ── Motion ────────────────────────────────────────── */
var(--mastors-duration-fast)
var(--mastors-duration-normal)
var(--mastors-easing-ease-in-out)
var(--mastors-easing-spring)
/* ── Z-Index ───────────────────────────────────────── */
var(--mastors-z-dropdown) /* 100 */
var(--mastors-z-modal) /* 500 */
var(--mastors-z-tooltip) /* 700 */
var(--mastors-z-toast) /* 800 */
Accessibility
<!-- Skip to content link -->
<a href="#main" class="mastors-skip-link">Skip to content</a>
<!-- Screen reader only (visually hidden) -->
<span class="mastors-sr-only">Loading...</span>
<!-- Skeleton loading placeholder -->
<div class="mastors-skeleton w-full h-4 rounded-md"></div>
<div class="mastors-skeleton w-1-2 h-4 rounded-md mt-2"></div>
prefers-reduced-motion globally via the base reset. All animations are disabled for users who prefer reduced motion.
States & Animations
| Class | Effect | Use Case |
|---|---|---|
.mastors-hover-lift | translateY(-4px) + shadow on hover | Cards, tiles |
.mastors-hover-scale | scale(1.02) on hover | Buttons, thumbnails |
.mastors-hover-opacity | opacity 0.8 on hover | Links, icons |
.mastors-interactive | Cursor, opacity, press scale, disabled state | General interactive elements |
.mastors-skeleton | Animated shimmer gradient | Loading placeholders |
.mastors-pulse | Opacity 1↔0.5 loop | Status indicators |
.mastors-spin | 360° rotation loop (1s) | Loading spinners |
.mastors-ping | Scale + fade out loop | Notification badges |
.mastors-bounce | Bounce up/down loop | Scroll hints, icons |
Container
<!-- Responsive container (auto max-width by breakpoint) -->
<div class="mastors-container">
Content auto-clamps at 540 / 720 / 960 / 1140 / 1320 / 1520px
</div>
<!-- Full-width fluid container with consistent padding -->
<div class="mastors-container-fluid">
Always 100% width with padding-left/right: 1rem
</div>
| Breakpoint | Container Max-Width |
|---|---|
| sm (576px+) | 540px |
| md (768px+) | 720px |
| lg (992px+) | 960px |
| xl (1200px+) | 1140px |
| 2xl (1400px+) | 1320px |
| 3xl (1600px+) | 1520px |
Build Commands
| Command | Description |
|---|---|
npm run sass:build | Expanded CSS with source maps |
npm run sass:min | Minified CSS, no source maps |
npm run sass:watch | Watch mode for development |
npm run sass:all | Both expanded + minified |
npm run build | Full Vite build |
npm run build:all | Sass + Vite build combined |
npm run clean | Clear dist/ folder |
vite.config.js. Only Dart Sass 1.70+ is supported. Legacy node-sass is not compatible.
Mastors Ecosystem
Mastors Core is the dependency base for all Mastors CDN libraries. Each library uses @use '@mastorscdn/core' as mc to access tokens, functions, and mixins.
| Library | Role | Depends on Core |
|---|---|---|
@mastors/core | Foundation — tokens, theming, utilities, reset | — |
@mastors/flexer | Flexbox utility system | ✅ Yes |
@mastors/gridder | CSS Grid layout system | ✅ Yes |
@mastors/fluider | Fluid typography & responsive fonts | ✅ Yes |
// In mastors-flexer/_index.scss
@use '@mastorscdn/core' as mc;
.mastors-flex-container {
@include mc.up('md') { display: flex; }
}
.mastors-flex-gap {
gap: mc.rem(16);
}
Best Practices
@use, never @importDart Sass modern modules only. @import is deprecated and breaks tree-shaking.
Write
mc.color('primary') not #2563eb. Tokens are refactorable; magic numbers aren't.Colors and backgrounds should use
var(--mastors-*) so they respond to dark/custom themes at runtime.Start with mobile base styles, layer up with
@include mc.up('md'). Avoid down() as primary breakpoints.Add
data-theme="dark" to HTML and verify. If it looks broken, you have hard-coded color values.var(--mastors-color-danger) not var(--mastors-color-red-600) for semantically meaningful choices.Use
as mc, as flex, as grid to prevent name conflicts in large projects.