npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@halftone-ds/tokens

v1.6.0

Published

Design tokens (W3C DTCG) to NativeWind, Tailwind 4 / shadcn, TypeScript, DESIGN.md and Figma, with a WCAG AA contrast gate. The token build behind Halftone.

Readme

@halftone-ds/tokens

The token build behind Halftone. One tokens.json in the W3C design-token format becomes everything an app reads, and every build checks the palette against WCAG AA.

npm install -D @halftone-ds/tokens
npx halftone-tokens init       # set up an existing app, web or Expo (below)
npx halftone-tokens doctor     # check the app's setup for kit components; says how to fix each problem
npx halftone-tokens import ./brand/tokens.json   # a brand's own DTCG tokens into a system file (below)
npx halftone-tokens build      # write every output in tokens/tokens.config.json
npx halftone-tokens check      # write nothing; exit 1 if an output is stale (CI)
npx halftone-tokens build --strict   # fail on contrast instead of warning (or HALFTONE_STRICT=1)
npx halftone-tokens figma      # mirror the tokens into Figma Variables

Starting in an existing app

npx halftone-tokens init [--theme <code|preset|file.halftone.json>] [--css <stylesheet>] [--force]

For any React app on Tailwind 4 and shadcn (Next.js, Vite, React Router…). It writes tokens/tokens.json (Halftone's brand) and a tokens/tokens.config.json, applies --theme if you give one, and builds tokens.css and fonts.css next to the app's main stylesheet (it looks for app/globals.css, src/index.css, src/app.css and a few more, or takes --css). Then it adds @import './fonts.css' at the top of that stylesheet and @import './tokens.css' after Tailwind, and names any :root, .dark, @theme, @layer base or body rules there that would override the kit, without deleting them. It refuses to replace existing tokens without --force.

In an Expo app on NativeWind (expo and nativewind in package.json, or --platform expo) it builds tokens/generated/tokens.css, imported first by global.css (Tailwind's build inlines it, so it reaches native), and tokens/generated/tailwind.preset.js, which it adds to tailwind.config.js next to nativewind/preset (or prints the line, if the config has another shape). lib/theme.ts and lib/fonts.ts land where the app's @/lib points. A theme with its own fonts installs their @expo-google-fonts packages (--no-install prints the command instead). After each npx shadcn add, run npx halftone-tokens build: the registry brings lib/theme.ts and lib/fonts.ts with Halftone's default brand.

Checking an app

npx halftone-tokens doctor [--platform web|expo] [--offline] [--json]

Read-only. It checks what kit components need and prints a fix for each problem (exit 1 if there is one):

  • the tokens are set up and every generated file is up to date (after a shadcn add in an Expo app, lib/theme.ts and lib/fonts.ts are not);
  • the stylesheet imports tokens.css after Tailwind and fonts.css first (web), or global.css imports the tokens first and tailwind.config.js uses the kit's preset (Expo);
  • components.json is on the new-york style, and the @/ aliases resolve in tsconfig.json (and vite.config.ts);
  • no kit file in components/ui has been replaced by shadcn's or react-native-reusables' stock version: it compares each one with the kit's registry (the URL in components.json) and the upstream one, ignoring the imports shadcn rewrites. --offline skips this.

It warns, without failing, about rules in the app's own CSS or Tailwind config that win over the kit's, nothing setting the .dark class, kit links without KitLinkProvider, an Expo app without KitThemeProvider or useFonts(FONT_ASSETS), and a lib/utils.ts with its own cn (clsx + tailwind-merge) next to the cn package that kit and shadcn files import. --json prints { ok, results: [{ level, message, fix }] } for an agent or CI.

Inputs

  • tokens/tokens.json: primitive ramps and scales, and semantic.color.<name> with a { light, dark } value per colour, using the shadcn names (background, primary, primary-foreground, muted, …) plus success, warning and info. semantic.radius.base sets --radius.
  • tokens/tokens.config.json: which targets to write, and where (paths relative to the app root):
{
  "source": "tokens/tokens.json",
  "scan": ["app", "components"],
  "targets": {
    "nativewind3": { "css": "tokens/generated/tokens.css", "partial": true, "preset": "tokens/generated/tailwind.preset.js" },
    "ts-theme": { "out": "lib/theme.ts", "navTheme": "expo-router/react-navigation" },
    "shadcn-web": { "out": "app/tokens.css" },
    "design-md": { "out": "DESIGN.md", "name": "My Kit" }
  }
}

scan (optional) lists source folders for the text-on-tint check below.

Targets

| Target | Writes | |---|---| | nativewind3 | NativeWind 4 / Tailwind 3 CSS variables (HSL, :root + .dark:root) and the Tailwind theme extension (duration-fast, ease-standard… included): css + tailwind (the whole stylesheet and a map to spread), or css + partial: true + preset (variables only, imported first by the app's global.css, and a Tailwind preset) | | shadcn-web | Tailwind 4 / shadcn v4 CSS: oklch variables in :root + .dark, @theme inline, base layer; motion as --duration-*, --ease-* and --spring-* (a linear() easing and its duration), with duration-*, ease-* and spring-* classes | | ts-theme | THEME (hex per scheme), TOKENS (space, radius, type, motion), MOTION (durations, easings and springs, typed for Motion and Reanimated) and an optional React Navigation theme | | registry-theme | the theme as shadcn registry cssVars, native and web | | design-md | a DESIGN.md (spec alpha) | | llms | a tokens section for llms.txt | | figma | the input halftone-tokens figma pushes to Figma Variables (durations included; easings and springs have no variable type) | | fonts | the theme's fonts as loading code: platform: 'expo' (expo-google-fonts), 'next' (next/font) or 'web' (a Google Fonts @import and --kit-font-*, imported first in the app's stylesheet) |

Themes

A theme is a recipe (brand colour, neutral, radius, fonts, icon stroke, depth, density, border, typeset) that theme apply expands into tokens.json, recording it so theme show can tell when tokens were edited by hand.

npx halftone-tokens theme apply <theme> [--dry-run] [--force]   # write it into tokens.json and rebuild
npx halftone-tokens theme show [--check]       # the applied theme, and any hand edits since
npx halftone-tokens theme presets              # the presets and their codes
npx halftone-tokens theme encode <theme>       # the Halftone code for a theme
npx halftone-tokens theme decode <code> [--json]   # what a code holds
npx halftone-tokens theme resolve [--json]     # the code for tokens.json as it is (exit 1 if none or edited)
npx halftone-tokens theme shadcn <theme> [--out file] [--fonts-url url]   # a shadcn registry:theme item

<theme> is a Halftone code (ht1-…, ht2-…, ht3-…), a preset name, a recipe .json, a system .halftone.json (see Systems), or a shadcn/ui preset code (b5owWMfJ8l). A shadcn code becomes the nearest Halftone recipe, and what it approximates or drops (shadcn-only greys, radius steps, fonts outside the list, icon libraries, chart colours, menu options, styles) is listed on stderr. The other way, theme shadcn writes the theme as a registry:theme item for npx shadcn add: colours for light and dark, radius, shadows, and its fonts as registry:font dependencies (hosted at halftonedesignsystem.com/r/font, or --fonts-url).

From code: decodeShadcnPreset, recipeFromShadcn, shadcnTheme and shadcnFont in @halftone-ds/tokens/theme (browser-safe). The preset codec is ported from shadcn/ui (MIT).

Systems

A system (name.halftone.json, what the Halftone Studio saves) is a recipe plus whatever was edited by hand on top of it: a seed per colour role (brand, neutral, danger, success, warning, info) with a 50–950 ramp, steps edited by hand, the role mapping for light and dark, text styles (h1–h4, lead, p, large, small, muted, code, blockquote), any Google Fonts family, corners, shadows, borders, named extras, component edits (Button, Chip, Badge, Input), and the brand (name, logos, icon background).

npx halftone-tokens theme apply ./acme.halftone.json   # writes tokens.json and records the system
npx halftone-tokens theme show                         # the system, its overrides, and any contrast warnings
npx halftone-tokens theme encode ./acme.halftone.json  # its ht- code, when it has no overrides
  • tokens.json records the document under $extensions, without its brand images. A system with overrides has no ht- code: a code only carries a recipe.
  • Generated colours are fixed for contrast as a recipe's are. A colour chosen by hand (a mapped role, an edited step) is never moved: a pairing it fails is a warning.
  • A status ramp from a seed replaces the file's; applying a theme without one puts the curated ramp back.
  • Edited text styles are written as semantic.type.<style>.{size,leading,weight,tracking,font}, corners as semantic.radius.<step> (the build uses them as fixed px), extras under extra.* (exported, not drawn by the kits).
  • Every text style (h1 h2 h3 h4 lead p large small muted code blockquote), edited or not, is built as --type-<style>-{size,leading,weight,tracking} (plus -font on Tailwind 4). nativewind3 adds the text-, leading-, tracking- and font-type-<style> keys; shadcn-web adds type-<style> utilities; ts-theme adds TOKENS.textStyles. With no edits they draw exactly what Tailwind's text-* classes did, with one exception: tracking is em on every platform, so on native it scales with the style's size (NativeWind's own tracking-* are fixed px there: tracking-tight is -0.25px). themeVars carries the styles to live previews (textStyleVars, themeTextStyles).
  • Every theme writes a component layer, semantic.component.<button|chip|badge|input>: a corner, a border width, heights per size step (Badge S/M, the others S/M/L), padding and the icon gap, a text style with its weight and case, an icon size, a shadow and focus ring (Button, Input), Input's placeholder, and each variant's fill, label, border and pressed colours (references to semantic colours). Both kits read it as --button-*, --chip-*, --badge-* and --field-* (bg-button-primary-bg, rounded-chip, h-button-md, gap-button-gap, text-type-button in nativewind3; type-button and the same colours in shadcn-web), so a Button looks the same in both. A system's components sets any of it (roles by name, a Foundations corner or px, COMPONENTS[name].props lists what each has); until it does, every property draws what the kits always drew, and the icon size and shadow (where the kits differed) are one value for both: ICON_DEFAULT, defaultShadow. The build's contrast gate checks every variant's label on its fill and Input's placeholder.
  • Component colours come from the ramps: a default drawn at partial opacity becomes the ramp step nearest to what it drew, and a derived hover/pressed colour is the next step of the fill's ramp away from the page whose label still reads at AA. Only the focus rings' halos are see-through.

From code (@halftone-ds/tokens/system, also in /theme, browser-safe): normalizeSystem / validateSystem, createSystem, migrate(recipe | code, brand) and systemToRecipe, generateSystem(system, tokens) (the same shape as generateTheme, plus warnings), systemRamps, textStyles, systemRadii, systemCode, applySystem, and systemFromTokens / fontFamiliesToCheck (the import, below). The document's shape is described in lib/system/schema.mjs.

Importing a brand's own tokens

npx halftone-tokens import ./brand/tokens.json --name "Acme"   # writes acme.halftone.json
npx halftone-tokens import ./tokens.json --google "Lato" --offline --json   # for an agent; no network

It reads any DTCG tokens.json (hex strings or 2025.10 colour objects, aliases, inherited $type) in the brand's own words, and writes a system:

  • Colour sets: the lightest page is light and the darkest is dark. A third set, or a colour no role takes, is an extra colour. With no dark set, dark is generated.
  • Roles by name (background-secondary → muted, stroke → border, brand → primary when there's no primary), as the brand's exact hex: the fixer never moves them, so a pairing below AA is a warning. A "muted" that reads as text on the page becomes muted-foreground. A see-through colour is mixed onto its page.
  • Ramps: brand from primary, neutral and the statuses from a numbered family that holds their colour, its steps kept.
  • Fonts when the family is on Google Fonts (the CLI asks; --offline skips, --google vouches); others stay out. Corners and shadows by name or by size.
  • Everything else (spacing, a line weight, a grid) goes in the system's tokens section, whole: not drawn by the kits, carried into tokens.json's record. A system with it has no ht- code.

It prints one line per guess. Check them before theme apply.

Guarantees

  • Contrast check. Every X / X-foreground pairing, body and muted text on every surface, each status colour used as text, and each status icon on its own tint is checked against WCAG AA in both themes. A pairing that falls short is named with its ratio, and the generated DESIGN.md lists it. By default that is a warning and the build carries on; with --strict (or HALFTONE_STRICT=1) the build fails and writes nothing. The same goes for a tone's text on a tint the palette can't carry, when the config has scan.
  • APCA, for reading only. apcaContrast(text, background) (from @halftone-ds/tokens/theme or @halftone-ds/tokens/lib/apca) gives the APCA Lc of a pair, and contrastReport(theme.resolved) lists every pairing the gate checks, in both themes, with its WCAG ratio, pass, and Lc. Lc is advisory: WCAG AA stays the gate, and nothing fails on APCA.
  • Colour vision, as a warning. cvdWarnings(theme.resolved) (from @halftone-ds/tokens/theme or @halftone-ds/tokens/lib/cvd) simulates protanopia, deuteranopia and tritanopia (Machado 2009, simulateCvd) and lists the status pairs (success / destructive and the rest) and adjacent chart colours that end up closer than OKLab ΔE 0.05 under any of them, or under normal sight. theme apply prints them. Nothing fails on it: the kit pairs every status with an icon or a label, and the warning says where colour alone stops doing the work.
  • Text on tints. A status colour as text on its own tint (text-success on bg-success/15) loses contrast fast: 4.09:1 with a typical green. The build works out, per colour, the strongest tint that still clears AA in both themes, and writes it into DESIGN.md and the llms section (primary up to /5, …, destructive never). With scan set, build and check also read every class string in those folders and fail on a tone's text over a tint stronger than that, naming the file and line. An element that holds only an icon (3:1) is exempt with a halftone-tokens-ignore tint-text comment. A class string has to contain both classes, so React Native's View > Text nesting is out of its reach; DESIGN.md states the rule for that case.
  • No drift between platforms. Every oklch value must render back to the same 8-bit hex as the source, so the web theme and the native theme are the same colours.
  • Radius scale. rounded-* classes are offsets from radius.lg, so with the default base each class equals its primitive and moving semantic.radius.base shifts the whole scale.

MIT licence.