r/webdev • • 1d ago

Showoff Saturday [Showoff Saturday] VinUI: an open-source component library where 8 visual styles share the same markup

Post image

I've been working on VinUI, an MIT-licensed component library for plain HTML, React, Vue and Svelte.

The main idea is that each of the eight styles (Precision, Tactile, Clay, Tonal, Editorial, Terminal, Paper, Bento) is only a set of CSS variables, so markup and props never change between looks. Instead of a runtime package, a CLI copies plain source files into your project:

npx /ui init
npx /ui add <component>
npx u/vinish/ui diff   # see upstream changes since you copied
  • 63 components, 13 page blocks and 16 plain-SVG charts
  • WCAG 2.2 AA checked in every style, light and dark
  • Works next to Tailwind or your own CSS

Repo: https://github.com/devvinish/vin-ui
Docs and live style switcher: https://vinish.dev/ui

Feedback welcome, especially on the theming approach and the copy-in model.

0 Upvotes

7 comments sorted by

3

u/leticia304 1d ago

The copy-in model gives teams ownership, but updates get tricky once a component is customized. Does `ui diff` show upstream changes alongside local divergence, or just compare with the copied baseline?

1

u/vinishkapoor 1d ago

Right now it's a plain two-way diff: your current file vs. the latest upstream version. There's no stored baseline yet, so your edits and upstream changes appear in the same diff. Two things soften that. Nothing gets overwritten without asking, file by file. And most of the visual layer lives in the style CSS rather than the copied components, so style updates don't touch your customized markup. Proper baseline tracking is a fair gap, though. I'm planning to store the original copy at add time so diff can show "your changes" and "upstream changes" separately, and add can do a three-way merge. Thanks for pushing on it.

2

u/poojadeliverwebsite 1d ago

Styles as nothing but CSS variables, with the markup never changing, is a really nice constraint. Curious how far it holds for the looks that differ most, like Clay or Paper where the shadow and border recipe is very different. Is that still all variables, or do some components read a style attribute? Also glad to see the diff command, that's the part most copy-into-your-repo libraries skip.

1

u/vinishkapoor 1d ago

Mostly variables, but not purely. Every style sets the same 30 tokens (colours, radii, fonts and the shadow recipes), and that's where Clay's raised look mostly comes from. Each style also ships a small set of CSS rules scoped to [data-vin-style="…"] for things a token can't express: Paper's handwritten titles, Terminal's dashed cards, Bento's pill buttons. Precision needs 4 of those rules; Terminal needs the most, at 74. The markup and component code never change, and no component reads the style attribute in JS. It's selectors only, so switching styles is just changing one attribute on <html>. Thanks on the diff command! Right now it compares your copy against the latest upstream; separating your edits from upstream changes is next on the list.

2

u/Snowkate8 23h ago

The live style switcher makes the idea much easier to judge than screenshots. I'd be curious to see focus and disabled states in each style too, since that's where the shared visual system has to hold up beyond the happy path.

1

u/vinishkapoor 23h ago

Thanks! Focus and disabled are exactly where it's easiest to break. Every style is already tested on a long form with errors, disabled fields and keyboard focus, and focus rings have to hit 3:1 contrast in all 8 styles, light and dark. You can see the focus side today: press Tab through the live demo. Disabled states aren't shown there yet, so I'll add a states view to the switcher (focused, disabled, error) in the next build.

2

u/Snowkate8 20h ago

Do the focus ring checks include the selectable accent colours too? The accent picker could change the contrast, so I wondered if those combinations are covered as well.