stnd.build

Custom SCSS Intention Recipe

Architectural blueprint for crafting bespoke typographic intentions and design tokens using SCSS, OKLCH ladders, and 1rlh rhythmic harmonics.

In Standard, styling is neither an endless utility class salad nor an unconstrained pile of ad-hoc CSS overrides. The design system is organized around Intentions: high-level typographic and optical paradigms that define line measure, spacing harmonics, baseline rhythm, and visual atmosphere for a specific reading context.

The framework ships with seven foundational intentions (prose, inky, technical, poster, editor, canvas, and compact). This recipe demonstrates how a Craftsman creates a custom Intention module — introducing bespoke aesthetic personality while strictly honoring Standard’s mathematical laws, zero-hardcoded-color ratchet, and vertical baseline rhythm.


The Invariants of an Intention

Before writing a single line of SCSS, every custom intention must satisfy three invariant rules:

  1. Zero Hardcoded Colors: Colors must consume @stnd/styles OKLCH semantic tokens (var(--color-background), var(--color-surface), var(--color-accent), var(--color-border)). No raw #hex, rgb(), or unvetted color literals.
  2. 1rlh Rhythmic Harmonics: Vertical margins, padding, and gaps must align with the baseline grid using 1rlh (root line-height) harmonics (0.5rlh, 1rlh, 1.5rlh, 2rlh).
  3. Fluid Typography Scale: Font sizes must derive from the harmonic type ladder (var(--step--1) through var(--step-5)).

File Structure

Following Law 4 (Vertical-Slice Modules), create a dedicated intention slice in modules/intention-editorial/:

my-app/
  modules/
    intention-editorial/
      index.module.js            # Registers the intention stylesheet and client hooks
      styles.scss                # Pure SCSS defining the intention rules
      EditorialHero.astro        # Optional companion layout component
      README.md                  # Documentation and visual specimens

Architectural Breakdown

1. Authoring the Intention (styles.scss)

The intention defines how typography, lead paragraphs, headings, blockquotes, and tables behave when wrapped in .intention-editorial or set on a page:

@use "@stnd/styles/tokens" as *;

/* ==========================================================================
   Editorial Intention: Broadside Newspaper & Literary Publication
   ========================================================================== */

.intention-editorial,
[data-intention="editorial"] {
  /* Optical Measure & Reading Constraints */
  --reading-width: 44rem;
  --editorial-lead-size: var(--step-2);
  --rhythm-gap: 1.5rlh;

  inline-size: 100%;
  max-inline-size: var(--reading-width);
  margin-inline: auto;
  line-height: var(--line-height-prose, 1.6);
  color: var(--color-foreground);

  /* Drop Caps & Lead Paragraphs */
  p.lead {
    font-size: var(--editorial-lead-size);
    line-height: calc(1rlh * 1.5);
    margin-block-end: 1rlh;
    font-weight: 300;
    color: var(--color-foreground-muted);
  }

  p.lead::first-letter {
    float: inline-start;
    font-size: var(--step-5);
    line-height: 1rlh;
    padding-inline-end: 0.5rlh;
    padding-block-start: 0.25rlh;
    font-family: var(--font-header, serif);
    font-weight: 900;
    color: var(--color-accent);
  }

  /* Headings: Tight leading, harmonic vertical rhythm */
  h1, h2, h3, h4 {
    font-family: var(--font-header, serif);
    font-weight: 700;
    text-wrap: balance;
    color: var(--color-foreground);
    margin-block-start: 2rlh;
    margin-block-end: 0.5rlh;
  }

  h1 {
    font-size: var(--step-4);
    line-height: calc(1rlh * 2);
    letter-spacing: -0.03em;
  }

  h2 {
    font-size: var(--step-3);
    line-height: calc(1rlh * 1.5);
    border-block-end: 1px solid var(--color-border-subtle);
    padding-block-end: 0.5rlh;
  }

  /* Pull Quotes with Optical Margins */
  blockquote.pull-quote {
    margin-block: 2rlh;
    padding-inline: 1.5rlh;
    border-inline-start: 2px solid var(--color-accent);
    font-style: italic;
    font-size: var(--step-1);
    line-height: calc(1rlh * 1.5);
    background: var(--color-surface);
    border-radius: var(--radius-sm, 4px);
  }

  /* Micro-Captions aligned with the 1rlh grid */
  figcaption {
    font-size: var(--step--1);
    line-height: 1rlh;
    margin-block-start: 0.5rlh;
    color: var(--color-foreground-subtle);
    font-family: var(--font-mono, monospace);
  }
}

2. Module Manifest (index.module.js)

Export the module so Standard automatically injects its stylesheet into the build pipeline without modifying root configurations:

export default {
  id: "intention-editorial",
  name: "Editorial Intention",
  role: "feature",
  styles: ["./styles.scss"],
  intents: ["editorial"],
};

3. Usage in Astro Views or Markdown Frontmatter

Any page or article can adopt the editorial intention immediately:

In Markdown Frontmatter:

---
title: The Lost Architecture of Printing
theme: atelier
intention: editorial
publish: true
---

<p class="lead">Early printers recognized that whitespace is not empty space; it is the physical gravity holding the text together.</p>

Standard builds upon centuries of typographic tradition...

In an Astro View:

---
import StandardLayout from "@stnd/layout";
---

<StandardLayout title="Broadside Story">
  <main class="intention-editorial py-2">
    <p class="lead">Every layout should feel like a physical publication.</p>
    <p>Body text flows strictly on the baseline rhythm...</p>
  </main>
</StandardLayout>

Verifying Conformance

Standard protects against aesthetic drift and hardcoded values with automated ratchets. Run these tests in your terminal:

# Verify zero color literals were added
pnpm lint:colors --ratchet

# Verify semantic HTML and markup conformance
pnpm lint:markup --ratchet

# Run full project checks
pnpm check

When all three checks succeed, your custom intention is production-ready and fully aligned with the Standard design ecosystem.