Guide
Getting started
Install Porchlight, import only the CSS you need, and set up the cascade layer for host overrides.
On this page
Porchlight is a native CSS framework with zero JavaScript dependencies. It includes tokens, themes, base styles, layout primitives, component contracts, utilities, and progressive enhancements as prebuilt CSS files.
For server templates, HTMX swaps, Alpine state, and optional CSS Modules, see the integration guide.
Install
npm install @cawalch/porchlight
# or
pnpm add @cawalch/porchlight
# or
bun add @cawalch/porchlight
Install into your application; you do not need to clone this repository. The package has no runtime dependencies and provides prebuilt CSS. Interactive contracts such as tabs and comboboxes still need application-owned behavior, keyboard handling, and state updates; CSS does not provide a controller. For working on Porchlight itself, use the repository’s contributor setup.
Full bundle
The package main export is the complete prebuilt stylesheet:
@layer porchlight, app;
@import "@cawalch/porchlight";
@layer app {
/* your product styles here */
}
Use this in a bundler-resolved CSS entry when you want the whole framework. Load that entry once. For plain HTML, use the static-assets instructions below.
Import only what you need
For smaller surfaces, start with core.css and add selected layers or
components.
@layer porchlight, app;
@import "@cawalch/porchlight/core.css";
@import "@cawalch/porchlight/layout.css";
@import "@cawalch/porchlight/components/button.css";
@import "@cawalch/porchlight/components/field.css";
@import "@cawalch/porchlight/components/card.css";
@import "@cawalch/porchlight/utilities.css";
core.css includes layer order, reset, tokens, themes, and base styles.
Component files consume those tokens, so keep core.css first.
Selected CSS imports follow the classes in your markup. A split button always
uses .pl-c-button for both segments, so import button.css before
split-button.css. The static-copy helper includes that required dependency
when you request --components split-button; CSS @import does not.
Other compositions are optional: a menu with a .pl-c-button trigger needs
button.css, a nav flyout needs popover-menu.css, and the inline-loading
busy-button recipe needs both button.css and inline-loading.css.
If you want the whole practical framework without experimental enhancement
syntax, use compat.css. It includes core, layout, all components, and
utilities, but leaves out enhancements.css.
@layer porchlight, app;
@import "@cawalch/porchlight/compat.css";
CLI tools
Porchlight provides a command-line interface (CLI) to scaffold projects, inspect design tokens, and copy static assets:
Scaffold a starter template
Generate an accessible starter HTML page configured with @layer ordering, CDN or local stylesheets, and a responsive layout:
# Scaffold a starter HTML file
npx --no-install porchlight init
# Scaffold with a custom output path, local stylesheet, and title
npx --no-install porchlight init --out src/index.html --local --title "App Dashboard"
Inspect tokens in the terminal
Query and inspect Porchlight design tokens from the terminal:
# Inspect design tokens in the terminal
npx --no-install porchlight tokens
# Filter by token name or group
npx --no-install porchlight tokens radius
npx --no-install porchlight tokens --group Fonts
# Output matching tokens as JSON
npx --no-install porchlight tokens --group Colors --json
Static assets
Server-rendered apps can copy prebuilt files from
node_modules/@cawalch/porchlight/dist/ without asking a bundler to parse
modern CSS. Use the included copy helper for the common paths:
Install the package first, then run its local executable:
npx --no-install porchlight copy --out public/porchlight --compat
<link rel="stylesheet" href="/porchlight/compat.css" />
These URLs assume your server exposes public/ at /; adjust them for your
asset mount or deployment base path.
For a smaller static slice, name the components you use:
npx --no-install porchlight copy --out public/porchlight --components button,field --layout --utilities
<link rel="stylesheet" href="/porchlight/core.css" />
<link rel="stylesheet" href="/porchlight/layout.css" />
<link rel="stylesheet" href="/porchlight/components/button.css" />
<link rel="stylesheet" href="/porchlight/components/field.css" />
<link rel="stylesheet" href="/porchlight/utilities.css" />
<link rel="stylesheet" href="/app.css" />
Then declare the layer order in app CSS:
@layer porchlight, app;
The package also provides dist/porchlight.manifest.json, which lists the
available files, component names, and recommended load order for copy scripts.
Vite
Vite resolves package CSS imports. Import one CSS entry from your app or link it from Vite’s HTML entry; bare package imports are not browser URLs.
@layer porchlight, app;
@import "@cawalch/porchlight/core.css";
@import "@cawalch/porchlight/components/button.css";
@import "@cawalch/porchlight/components/data-table.css";
@import "@cawalch/porchlight/utilities.css";
You can also import CSS from a JS or TS entry:
import "@cawalch/porchlight/core.css";
import "@cawalch/porchlight/components/button.css";
import "./app.css";
For production builds, set a CSS target that matches your supported browsers.
The docs build uses build.cssTarget: "chrome149" to preserve native color
functions. This is a Chromium target, not a cross-browser support guarantee.
The full bundle was also checked with Vite 8.2.1’s default target in a small
light/dark consumer fixture. Vite reports non-fatal Lightning CSS warnings for
newer selectors such as ::scroll-marker and :target-current, but retains
those rules in the emitted CSS. A served full-bundle build rendered the expected
button and card styles in Chromium. Recheck advanced feature behavior in your
target browsers after changing targets or minifiers; see
Vite’s CSS target option.
Bun and parser fallbacks
Bun can install Porchlight and run its copy helper. Using Bun as a package
manager is separate from sending CSS through bun build.
Verified with Bun 1.4.4 and Porchlight 0.15.0:
| Path | Result |
|---|---|
bun add @cawalch/porchlight |
Installs the package and local CLI |
Bundle full.css, porchlight.css, or compat.css |
Builds cleanly (code 0); emits non-fatal warnings for newer at-rules |
Bundle core.css + selected components |
Builds cleanly (code 0) with smallest possible bundle size |
Bleeding-edge Chrome 133+ scroll-state() queries |
Isolated in @cawalch/porchlight/experimental.css |
| Copy prebuilt CSS and serve it directly | Preserves the full CSS without parser transformation |
Do consumers need to exclude
enhancements.csswhen building with Bun?No. Both
porchlight.cssandfull.cssinclude08-enhancements.cssand build cleanly with Bun 1.4.4 (exit code 0). The single grammar construct that previously failed Bun’s CSS parser (scroll-state(...)) was moved into@cawalch/porchlight/experimental.css. Standard08-enhancements.csscontains only safe@supports-gated progressive enhancements (text-box-trim, CSS gap decorations, style container queries,field-sizing: content), which Bun accepts without error. Consumers do not need to exclude enhancements or switch tocompat.cssunless targeting older environments.
For Bun’s CSS bundler, put this in app.css, then run
bun build ./app.css --outdir ./dist:
@layer porchlight, app;
@import "@cawalch/porchlight/full.css";
Load the emitted stylesheet in your page; a CSS build alone does not attach it to the DOM. Basic button/card styles from Bun’s output were checked in Chromium; non-fatal warnings do not establish that every newer CSS feature works identically across all browsers. Check advanced features in your target browsers.
For copying prebuilt assets, run the installed CLI with Bun’s runtime explicitly:
bunx --bun --no-install porchlight copy --out public/porchlight --full
<link rel="stylesheet" href="/porchlight/full.css" />
See Bun’s CSS bundler and bunx runtime selection.
The layer model
Porchlight wraps everything in a single top-level cascade layer:
@layer porchlight. Inside it, sub-layers declare a deterministic order:
@layer porchlight {
@layer reset, tokens, themes, base, layout,
components, utilities, enhancements, print;
}
For normal stylesheet declarations, later layers win: components beat base,
utilities beat components, and app beats Porchlight. !important reverses
layer precedence; do not override accessibility safeguards casually.
Do not pass layer(...) to Porchlight imports. Modules already
self-layer.
Using components
Each component uses the .pl-c-* class prefix. Drop them into your HTML:
<button class="pl-c-button" data-variant="primary">Save</button>
<div class="pl-c-card">
<div class="pl-c-card__header">
<h2 class="pl-c-card__title">Title</h2>
</div>
<div class="pl-c-card__body">Content</div>
</div>
Browse the component reference or the preview gallery to see every component with live examples.
Token metadata
Use the generated token module for editor autocomplete, validation, or build tooling:
import tokenDoc, { tokenGroups } from "@cawalch/porchlight/tokens";
console.log(tokenDoc.tokens["--pl-color-accent"].value);
console.log(tokenGroups.map((group) => group.name));
JSON is also available:
import tokens from "@cawalch/porchlight/tokens.json" with { type: "json" };
Exports reference
| Import path | Contents |
|---|---|
@cawalch/porchlight |
Full prebuilt CSS bundle (minified) |
@cawalch/porchlight/min.css |
Minified full bundle alias |
@cawalch/porchlight/porchlight.css |
Full unminified CSS bundle |
@cawalch/porchlight/full.css |
Canonical full bundle with enhancements |
@cawalch/porchlight/unminified.css |
Full unminified CSS bundle alias |
@cawalch/porchlight/compat.css |
Bundle without the enhancement layer |
@cawalch/porchlight/core.css |
Layer order, reset, tokens, themes, base |
@cawalch/porchlight/layout.css |
Layout primitives |
@cawalch/porchlight/components.css |
All component CSS |
@cawalch/porchlight/components/button.css |
One component CSS file |
@cawalch/porchlight/utilities.css |
Utility classes |
@cawalch/porchlight/enhancements.css |
Progressive enhancement layer |
@cawalch/porchlight/experimental.css |
Bleeding-edge CSS experimental queries |
@cawalch/porchlight/size-budget.json |
Component & bundle size budget data |
@cawalch/porchlight/tokens |
Typed token metadata module |
@cawalch/porchlight/tokens.json |
Token metadata JSON |
@cawalch/porchlight/manifest.json |
Static-copy manifest |
@cawalch/porchlight/src/* |
Raw source escape hatch |
Browser support
Porchlight targets modern browsers and does not polyfill old CSS engines.
The core uses cascade layers, custom properties, :has(), @scope,
color-mix(), and OKLCH. Advanced features are gated where possible.
See the Browser support guide for the full feature matrix.
Next steps
- Theming guide: override tokens and create a brand theme
- Architecture guide: deep dive into the layer model
- Composition recipes: compose dashboards, tables, settings, and dense admin screens
- Preview gallery: see every component live