Developers
Getting started
Download DESIGN.mdStingray is plain CSS, JavaScript and HTML, with no framework or build step.
Files
| File | Contains | Raw | Gzipped |
|---|---|---|---|
tokens/tokens.css | All tokens as custom properties: light, dark, density. | ||
css/icons.css | The MingCute subset as mask images. | ||
css/stingray.css | Components, type, layout helpers, print. | ||
js/stingray.js | Keyboard models, charts, toasts, theme and density. | ||
fonts/*.woff2 | Atkinson Hyperlegible Next, regular and semibold, latin and latin-ext. Latin-ext loads only when needed. | ||
tokens/_tokens.scss | The tokens for Sass. | ||
tokens/tokens.json | The token source, for tooling. |
Sizes measured by the build on 28 Sep 2026. Copy these files into your project; there is no package yet.
DESIGN.md for AI assistants
Give this file to AI assistants that write Stingray UI. It lists every class, token, attribute and icon, the fixed rules, and how to record a departure.
| Tool | Put it at |
|---|---|
| Claude Code | CLAUDE.md in the project root |
| Codex, Cursor, Zed and other agent tools | AGENTS.md in the project root |
| GitHub Copilot | .github/copilot-instructions.md |
| A chat assistant | Attach DESIGN.md |
If the file already exists, add "Follow DESIGN.md for all UI" to it and keep DESIGN.md beside it.
Minimal page
Put class="sg" on <body>, not <html>. Load the script in the head.
Guidelines
Use
- The documented markup: a class per part, a modifier per variant (
sg-button,sg-button--primary,sg-table__sort). - Semantic or spacing tokens in your CSS:
var(--sg-color-text-secondary). data-sg-*attributes for behavior, andStingray.init(root)for markup added later. It is safe to run twice.langon the page, for sorting and number formatting.- Decorative icons. Icon-only controls need
aria-labeland a tooltip (Iconography).
Avoid
- Hex values or primitive color tokens.
!importantor deep selectors on components. Add a token instead.
Theme and density
Set data-theme and data-density on any element; both nest. Without data-theme, the system preference applies.
Content Security Policy
Stingray needs no inline scripts, inline handlers or remote requests. It runs under this policy:
Icons need data: in img-src. Set dynamic values with el.style.setProperty('--sg-meter-value', '72%'), not a style attribute. Demos on this site use inline scripts and styles; do not copy them.
JavaScript API
| Call | Does |
|---|---|
Stingray.init(root = document) | Wires tabs, grids, filters, menus, comboboxes, date ranges, uploads, chips, trees and palettes inside root. Runs on load; call again after inserting markup. |
Stingray.toast({ title, message, status, action, timeout }) | Shows a toast. Returns { dismiss }. Info and success dismiss after 8 seconds; warning and error stay. An action with undo: true also answers Ctrl+Z. |
Stingray.chart(el, spec) | Renders an SVG chart with legend, readout and table view. Returns { update, loading, setTexture, destroy }. |
Stingray.spark(el, values) | Draws a sparkline with no axes. |
Stingray.theme, Stingray.density | get(), set(value), and for theme effective(). |
Stingray.haptics | get(), set(on), tap(). On by default; the choice is saved. Products put it in their settings. |
Stingray.busy(button, work, { busy, done }) | Blocks the button until work settles, then shows the done label for 600ms. Resolves with the result. |
Stingray.stagger(list) | Brings in a list's first ten rows, 30ms apart. First load only. |
Stingray.announce(message) | Sends a message to the polite live region. |
Attributes
| Attribute | On |
|---|---|
data-sg-grid | A table: makes it a keyboard grid. |
data-selectable | The grid: enables row selection. |
data-sg-row, data-sg-select-all | Checkboxes that drive selection. |
data-sg-filter="#id" | An input that filters that table. |
data-sg-count-for, data-sg-selection-for | Elements that show counts, with a data-template. |
data-sg-tabs | The container of a tab list and its panels. |
data-sg-dialog-open="#id", data-sg-dialog-close | Buttons that open and close a dialog or a drawer. |
data-sg-dismissible | A dialog that closes on an outside click. |
data-sg-tip="text", data-sg-tip-key | Any element that needs a tooltip, and its shortcut. |
data-sg-changed | A cell whose value just changed: tinted for a moment. |
data-sg-combobox | A combobox. |
data-sg-date-range, data-sg-range | A date range and its preset buttons. |
data-sg-upload, data-max-size | A file upload and its size limit in bytes. |
data-sg-bulk-for="#id", data-sg-clear-selection="#id" | The bulk action bar of a grid, and its clear button. |
data-sg-chips="#id", data-sg-chips-clear | Filter chips, where focus goes after the last, and Clear all. |
data-sg-tree | A tree view. |
data-sg-palette | A command palette dialog; Ctrl+K opens it. |
Events
| Event | Detail |
|---|---|
sg:selectionchange | { count } |
sg:activate | { row }: Enter on a grid row. |
sg:sort | { column, direction } |
sg:filter | { visible, total } |
sg:menuselect | { item } |
sg:change | { value, label, option }: a combobox pick. |
sg:rangechange | { from, to } |
sg:fileschange | { files }: the files kept. |
sg:chipremove, sg:chipsclear | { value, label }, none |
sg:treeselect, sg:treetoggle | { item, label }, { item, open } |
sg:command | { option, value, label }: a palette pick. |
sg:themechange, sg:densitychange | { theme }, { density } |
Examples
Field with an error
Grid selection
Toast with Undo
Chart refresh
SCSS
Frameworks
In React, Vue or Angular, render the documented markup and call Stingray.init(container) after rendering. Do not reimplement the keyboard models; they expect the documented DOM.
Browser support
Chrome and Edge 120 or later, Firefox 121 or later, Safari 17 or later.
| Feature | Use for | Fallback |
|---|---|---|
| Popover API | Menus. | A toggle with outside-click and Escape handling. |
<dialog>, :focus-visible, mask, :is() | Dialogs, focus, icons, selectors. | None; baseline. |
:has() | Selected segment, disabled choice row. | None; baseline. |
| Logical properties | Spacing and sizing. Layouts and arrow icons mirror under dir="rtl". | None; baseline. |
Token build
Edit tokens/tokens.json and run the build. It regenerates the CSS, SCSS and site data, and fails with a list if a rule breaks.
Requires Node 18 or later (tested on 24) and nothing else. See Token architecture for the gates.