- CSS 79.4%
- JavaScript 20.6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Extracts the interface language of [w] Drive into a standalone, framework-free
stylesheet: app shells, controls, file tables, overlays, and Docs/Sheets/Slides/
Mail/Calendar patterns. Palette seeds live in w-ui.config.json and generate
light/dark tokens plus alternate preset palettes with one build command.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
|
||
| assets | ||
| dist | ||
| examples | ||
| palettes | ||
| scripts | ||
| src | ||
| .gitignore | ||
| package.json | ||
| README.md | ||
| w-ui.config.json | ||
w·ui
A GSuite-style CSS baseline extracted from [w] Drive. It gives new internal apps the same interface language — soft blue-grey canvas, white workspace panels, pill controls, 60px top bar, file tables, editor toolbars — without a framework, a CSS build step at runtime, or a component library to learn.
- One stylesheet.
dist/w-ui.cssis the whole baseline. Works with Flask, Django, Rails, Next, Vite, Rails, plain HTML — anything that can load CSS. - Config-driven palette. Edit
w-ui.config.jsonand run one command. Every surface, border, hover and focus tint is derived from a handful of seed colours. - GSuite patterns included. Drive shell, Docs editor, Sheets grid, Slides stage, Mail three-pane and Calendar week view.
- Optional runtime.
dist/w-ui.js(about 4 kB) adds persisted light/dark/auto, palette switching and runtime token overrides. The CSS works without it.
Quick start
Copy dist/ into your app's static files and link one stylesheet:
<link rel="stylesheet" href="/static/w-ui.css">
<body class="app">
<header class="app-bar">
<a class="brand" href="/">
<span class="brand-mark brand-mark--sm">w</span>
<span class="brand-word">Drive</span>
</a>
<div class="app-bar-actions">
<button class="btn btn-primary">New</button>
</div>
</header>
<div class="app-shell">
<aside class="sidebar">
<nav class="nav">
<a class="nav-item is-active" href="/">My Drive</a>
</nav>
</aside>
<main class="app-main">
<div class="page-head">
<div>
<p class="eyebrow">Personal workspace</p>
<h1>My Drive</h1>
</div>
</div>
</main>
</div>
</body>
Icons come from the bundled Phosphor sprite:
<svg class="icon" aria-hidden="true">
<use href="/static/icons/icons.svg#folder-simple"></use>
</svg>
Run the example screens locally:
npm run demo # http://127.0.0.1:5173/examples/
Palette configuration
All colours live in w-ui.config.json. The required seeds are the same for light and dark:
| Key | Used for |
|---|---|
bg |
App canvas behind panels |
surface |
Cards, panels, dialogs, input backgrounds |
surfaceAlt |
Tonal controls, table headers, selected chips |
border |
Hairlines and input borders |
text |
Primary text |
muted |
Secondary text, labels, icons |
accent |
Primary actions, active navigation, focus rings |
onAccent |
Text/icons on the accent colour |
accentSoft |
Selected rows, active nav background, tints |
danger / onDanger |
Destructive actions and errors |
success / warning |
Status badges and notices |
shadow |
Floating panel shadow |
Then rebuild:
npm run build
This regenerates:
dist/w-ui-theme.css variables for both themes
dist/w-ui.css theme + all components (drop-in file)
dist/palettes/<preset>.css optional alternate palettes
dist/w-ui.js runtime helper
dist/icons/ Phosphor sprite + licence
npm run check rebuilds in memory and exits non-zero if dist/ is stale — useful in CI.
Derived tokens such as --w-accent-hover, --w-danger-soft, --w-border-strong, --w-hover and --w-shadow-sm are computed with color-mix() from the seeds, so you normally only need to change the table above. Shape, typography and layout are configurable too:
{
"font": { "sans": "Inter, system-ui, sans-serif", "size": "14px" },
"shape": { "radiusSm": "8px", "radius": "12px", "radiusLg": "16px", "radiusPill": "999px" },
"layout": { "topbar": "60px", "sidebar": "200px", "rail": "72px", "content": "1250px" }
}
Preset palettes
palettes/ contains three ready-made alternatives: forest (green), plum (purple) and mono (neutral graphite). Each is built to its own scoped CSS file:
<link rel="stylesheet" href="/static/w-ui.css">
<link rel="stylesheet" href="/static/palettes/forest.css">
<html data-palette="forest">
Or switch at runtime:
WUI.palette.set('forest'); // persists in localStorage
WUI.palette.set(null); // back to the default palette
To add a preset, copy any file in palettes/, change the colours, and run npm run build.
Using a separate palette per app
Keep the library pristine and build an app-specific theme from its own config:
node scripts/build.mjs --config apps/docs/config.json
The output still lands in dist/, so a small wrapper script or a copied install per app works well. If you only need one or two overrides, skip the build and set the tokens at runtime instead:
WUI.tokens.set({
accent: '#1f7a4d',
accentSoft: '#d8f0e1',
onAccent: '#ffffff'
});
Light, dark and auto
The theme follows the operating system by default. Override it on the root element:
<html data-theme="light"> <!-- force light -->
<html data-theme="dark"> <!-- force dark -->
<html data-theme="auto"> <!-- follow the OS -->
Avoid a flash of the wrong theme by applying the saved choice before first paint:
<script>
try {
var theme = localStorage.getItem('w-ui-theme');
if (theme === 'light' || theme === 'dark') document.documentElement.dataset.theme = theme;
} catch (e) {}
</script>
With dist/w-ui.js loaded, any element with data-theme-toggle becomes a working toggle, and an icon pair with data-theme-icon="moon" / "sun" swaps automatically:
<button class="btn btn-ghost btn-icon theme-toggle" data-theme-toggle aria-label="Toggle dark mode">
<svg class="icon" data-theme-icon="moon"><use href="/static/icons/icons.svg#moon"></use></svg>
<svg class="icon" data-theme-icon="sun"><use href="/static/icons/icons.svg#sun"></use></svg>
</button>
Runtime API:
WUI.theme.get(); // 'auto' | 'light' | 'dark'
WUI.theme.resolved(); // 'light' | 'dark'
WUI.theme.set('dark');
WUI.theme.toggle();
WUI.theme.set and WUI.palette.set dispatch w-ui:theme / w-ui:palette events on <html> if your app needs to react (charts, iframes, map tiles).
Class reference
Layout
| Class | Purpose |
|---|---|
.app |
Full-height flex column: bar + shell |
.app-bar |
60px top bar; .app-bar-actions right-aligns controls |
.brand, .brand-mark, .brand-mark--sm, .brand-word |
Product mark and wordmark |
.app-shell |
Sidebar + main grid. Add --rail for icon rail, --full for no sidebar |
.sidebar, .rail, .sidebar-footer, .storage |
Navigation column and storage meter |
.app-main |
White workspace surface. --plain transparent, --flush no padding |
.content |
Max-width content column (1250px by default) |
.page-head, .page-actions, .eyebrow |
Page title row |
.toolbar, .toolbar--bar |
Secondary action bar |
.split, .split--wide, .three-pane, .pane |
Column layouts |
.new-button |
Elevated sidebar "New" button |
Controls
| Class | Purpose |
|---|---|
.btn |
Default tonal button, radius 16px |
.btn-primary, .btn-tonal, .btn-outline, .btn-ghost, .btn-danger, .btn-danger-ghost, .btn-elevated |
Variants |
.btn-sm, .btn-lg, .btn-block, .btn-icon, .btn-round |
Sizes and shapes |
.field, .field-label, .field-hint, .field-error |
Label + hint wrapper |
.input, .select, .textarea, .input--sm, .input--lg |
Form controls |
.search |
Pill search field with focus ring |
.check, .switch, .segmented |
Selection controls |
.input-group |
Input plus adjacent button |
Surfaces and status
.card / .panel, .card--flat, .card-head, .card-title, .card-sub, .card-grid, .badge (+ --accent, --success, --warning, --danger), .chip, .avatar (+ --sm, --lg, --neutral), .progress (+ --lg), .notice (+ --error, --success, --warning, --accent), .empty, .empty-title, .divider.
Navigation
.nav, .nav-item (.is-active or aria-current="page"), .nav-count, .nav-label, .tabs, .tab, .breadcrumbs, .crumb-current, .dropdown (native <details>), .menu (+ --left, --up), .menu-item, .menu-item--danger, .menu-sep, .menu-head, .menu-label.
Data
.table-wrap, .table, .table--fixed, .cell-check, .cell-actions, .sort, .file-name, .file-icon (+ --doc, --sheet, --slide, --pdf, --image), .file-open, .star, .selection-bar, .status, .status--bar, .tile-grid, .tile, .tile-top, .tile-name, .tile-preview, .tile-meta.
Overlays
.dialog (+ --wide), .dialog-head, .dialog-body, .dialog-actions (+ --split), .drawer, .toast-region, .toast, .context-menu. Dialogs use the native <dialog> element and showModal().
App patterns
| Class | Screen |
|---|---|
.editor, .editor-bar, .editor-toolbar, .tool-group, .tool, .editor-canvas, .docs-page |
Docs |
.sheet-app, .sheet-toolbar, .formula-bar, .sheet-wrap, .sheet, .sheet-tabs, .sheet-tab |
Sheets |
.slides-app, .slides-layout, .filmstrip, .slide-thumb, .slides-stage, .slide, .inspector |
Slides |
.mail-app, .mail-nav, .mail-list, .mail-row, .mail-reader, .mail-body, .mail-reply |
|
.calendar-app, .cal-toolbar, .cal-head, .cal-body, .cal-time, .cal-col, .cal-slot, .cal-event |
Calendar |
Utilities
.row, .row--wrap, .stack, .between, .center, .end, .grow, .push, .grid-auto, .full, .muted, .small, .tiny, .strong, .truncate, .sr-only, .hidden, .surface, .muted-surface, .scroll-x, .mt-2, .mt-4, .mb-2, .mb-4.
Example screens
npm run demo serves:
| File | Shows |
|---|---|
examples/index.html |
Gallery, palette controls, component starter, dialog |
examples/drive.html |
File table, selection bar, sidebar, tiles, new-folder dialog |
examples/docs.html |
Formatting toolbar and page canvas |
examples/sheets.html |
Formula bar, sticky cell grid, sheet tabs |
examples/slides.html |
Filmstrip, 16:9 slide, inspector |
examples/mail.html |
Three-pane inbox and reply composer |
examples/calendar.html |
Week grid with today marker and event tints |
The fixed bar at the top of the examples is demo chrome (theme + palette switching); it is not part of the library.
Icons
dist/icons/icons.svg is a sprite of Phosphor Icons (MIT, see dist/icons/icons-LICENSE.txt). The app baseline depends on the sprite being served from the same origin. For a single-file build, inline the sprite into the page instead of linking it — external <use href="…"> does not work from file://.
Adding an icon: append a <symbol id="name" viewBox="0 0 256 256" fill="currentColor">…</symbol> inside the sprite and run npm run build to copy it into dist/.
Repository layout
w-ui.config.json palette, typography, shape and layout seeds
palettes/ alternate palette presets
src/ editable CSS (numbered load order) and w-ui.js
scripts/build.mjs generates theme CSS + bundles dist/
scripts/serve.mjs zero-dependency static server for examples
dist/ generated — do not edit by hand
examples/ copyable screens for the six GSuite-style apps
Requirements: Node 18+ to rebuild or run the demo. Consuming apps need only the files in dist/.
Browser support
Current evergreen browsers. The baseline uses CSS custom properties, color-mix(), native <dialog> and :focus-visible. There is no IE11 fallback and no RTL pass yet.