Oscar Ruiz
Case study

Stylhero

An accessible design system for React, Next.js and React Native, published on npm. One tokens file drives the web components, the mobile theme and the Tailwind setup, and the build refuses to ship colors that fail contrast.

Role
Solo: design, development, testing and releases
Timeline
October 2026 — Present
Live
raiburn.github.io
Code
GitHub
The Stylhero live demo: a customer dashboard built only from Stylhero components

The problem

BuildMyRig, its mobile app and this portfolio all needed the same things: buttons, inputs, dialogs, toasts, a color palette that works in dark mode. Each one was styling them from scratch, and they drifted apart.

Material UI covers the components, but brings its own look and a runtime styling layer (sx props, styled() and theme objects). I wanted plain CSS that works with or without Tailwind, components that can render on the server, and one source of truth for both web and mobile.

One tokens file, checked at build time

Every color (light and dark), font, type size, spacing step, radius and shadow lives in a single tokens.json. A build script generates everything else from it:

Accessibility the build enforces

Contrast isn't left to review. The token build checks 18 foreground and background pairs in both themes: text must reach 4.5:1, and the borders that identify a control (text inputs, selects, slider tracks) must reach 3:1. If a color change breaks either rule, the build stops and names the pair, so it can't reach a release.

Behavior is tested in a real browser. The playground renders every component on one page, and 110 Puppeteer checks drive it in headless Chrome: keyboard navigation in menus, tabs, the tree view and the date pickers, focus returning to the control that opened a menu or picker, combobox filtering, DataGrid sorting, search and selection, chart tooltips and table views, and no horizontal scroll at phone width. GitHub Actions runs them on every pull request against both React 18 and React 19, along with axe on every component in light and dark mode and on all 93 docs pages.

Layouts use logical CSS properties, so the components mirror for right-to-left languages like Arabic and Hebrew, arrows and sliding motion included.

The React Native package builds the same rules in: every pressable is at least 44×44pt, text follows the user's font size setting, motion is skipped under Reduce Motion, and controls tell screen readers their role, state and position ("tab, 2 of 4"). A date picker reads every day with its full date, and a slider can be changed by swiping up and down. It has 161 tests of its own, including one that renders every docs example.

Stylhero form controls, date picker and charts in dark mode
Dark mode follows the OS. Every chart has a table view, and the colors were checked for color-blind separation.

Built for Next.js

The package ships one file per component, and only the interactive ones are marked "use client". Text, cards, badges, tables and the rest render as React Server Components and send no JavaScript to the browser.

Overlays use the browser's native dialog and details elements where the browser already does the work, and floating-ui for menus, popovers and tooltips. With Next.js's optimizePackageImports setting, this portfolio's home page went from 158 kB to 113 kB of first-load JavaScript.

Using it in a real app found the gaps

The demo page passed every check. Moving BuildMyRig's web and mobile apps onto it showed what the demo didn't:

Shipping it like a real package

Every change carries a changeset that becomes its changelog entry. Merging a version bump to main makes GitHub Actions run the typecheck, build and tests, publish to npm, tag the release and write the GitHub release notes.

Packages are published with npm provenance through trusted publishing: npm verifies that each release was built from this repository by its workflow, and no npm token is stored anywhere. The live demo and docs are rebuilt and redeployed whenever a component changes.

Pull requests also screenshot every component's live example in light and dark and compare it with main pixel by pixel, and check a bundle-size budget, so a visual change or a heavier import has to be on purpose.

What I'd do differently

Both packages have a docs page per component, generated from their TypeScript types, but the React Native pages show examples as code, since the components render natively. A live phone preview on each page (Expo Snack or react-native-web) would make them as easy to try as the web ones.

Screenshot comparison and axe only run on the web package. The native tests check roles, labels and states, but not how VoiceOver and TalkBack actually read them, which needs regular passes on real phones.