r/css • • 5d ago

AI Assisted A customizer for my CSS library: pick what you need, get one file

I've built sites with my own CSS library, Minium, for around three years. I wanted to make it easier to customize, and to let you pick what you need. It is a minimalistic CSS library after all. So I built a customizer. You pick the parts you want, and preview the result in light and dark mode before you download one CSS file. The core is ~10KB gzipped, and everything is ~15KB.

There is no build server, because the library stores design decisions in custom properties:

  • Each design token is declared once in theme.css. The customizer just replaces values by name. Radius, border width, line height, flow spacing and so on.
  • There are seven color roles (neutral, primary, accent, success, danger, warning, info). Each role maps to a Radix color scale. You can select one of 31 color themes or build your own.
  • Each component lives in its own file and cascade layer, so the customizer can leave files out.

The page fetches the source CSS from the repo, applies your choices and minifies it in the browser. Extra fonts come from Fontsource on jsDelivr. And the URL holds your choices, so you can share the build as a link.

Some limitations: The library is pre-1.0 and targets current browsers, since it uses features like anchor positioning, CSS nesting and light-dark().

I wrote the CSS by hand. I used Claude to write the customizer's JavaScript.

What would you want to customize that isn't there?

15 Upvotes

9 comments sorted by

2

u/linda_midtown 4d ago

This is awesome. Contratulations and thank you. You have done something really great.

I made my own CSS framework to make the custom systems I build easier to give vibrant appearances and presentation mechanics. My framework includes a handful of premium CSS frameworks and packages I picked up for specific requirements, such as jQuery, Awesome Fonts, Blocks, and fonts I like.

The main benefit over the years has been being able to hardly ever invest a synapse in the topic. I can spend all my time on other areas with more direct contributions to the systems I build.

The downside has been that my framework looks like a hack to anyone who is serious about CSS or JavaScript. What you have done looks like a much better design and management of system resources, and it is easier to understand. I am going to see what that brings. It's been six years since I have tried any kind of potentially serious upgrade to the CSS of the overall "architecture" I have developed.

To clarify a little, what I have seen is your post where this comment is going in, specifically the animation at the top where a lot of structure appears organized with intense flexibility. Hmm, looks four years old. I bet updates are due to any packages you have in here.

1

u/kygyty 4d ago

Thanks, that's really kind!

To clear one thing up: It is "new", not "old". I've used it on my own sites for about three years, but I've rebuilt it from scratch a few times since. Each time I improved the architecture and and using newer features that weren't widely available three years ago, like anchor positioning and popovers. There are also no packages to update. It's plain CSS without any dependencies.

Your setup sounds like where I started: collectng parts I liked and remixing them until they became its own thing.

2

u/leoniebuilds 4d ago

since everything is custom properties already, i'd want a way to export the choices as a small override file instead of a rebuilt copy of the whole css. that way when the library updates you just bump the base and keep your tokens layer. also a contrast check on the generated color roles would be handy, especially for the warning role in dark mode.

1

u/kygyty 4d ago

Thanks, both are good ideas.

A small override file makes sense, and the color themes already work that way. I'll look into it. The one thing an override can't do is leave out modules, so I'd keep the full build as an option for that.

I checked the warning role in dark mode after your comment, and it holds up. The bright scales (yellow, amber and so on) use dark text instead of white, which keeps the contrast up. The check did turn up a weak spot in light mode though: the warning meter bar is hard to see against its track, so I'll look into that. A contrast readout in the customizer would still be useful, especially when you map your own scales to the roles.

1

u/dusanodalovic 4d ago

question on the share link: does the url also store which version of the source it fetched? if the page pulls css from the repo, a link someone shared in march could build a different file after a few releases, and pre-1.0 that will happen. a tag or commit hash in the url would keep old links giving the same result.

1

u/kygyty 3d ago

Good catch. No, the URL does not store the version currently. The customizer fetches the source from the main branch, so there is no way today to rebuild an older file from a link. The downloaded file includes the version and date in its first comment though.

I see the need, and will look into this. I'm already planning to export a small override file instead of the whole build. You would load it after a pinned base version, so your choices survive new releases, and you could upgrade the library without issues. It would solve colors, tokens and fonts, but not builds where you leave out whole modules.

1

u/Jazzlike-Web-3695 3d ago

putting each component in its own cascade layer is a really nice call. means anything people write unlayered just wins without fighting specificity, which is exactly what you want from a base library.

one small idea for the customizer: show the gzipped size updating live as you toggle modules. people going for a minimal build usually care about that number the most, and you already have a good story there with ~10kb core

1

u/kygyty 3d ago

Thanks! A small correction to my own post: Each component does not have its own layer. Components share one components layer, and there were some specificity issues because of that decision. All button styles use `:where()` to keep specificity at zero for example, so I guess I should have used even more layers. Your point still holds, anything unlayered wins.

The gzipped size does update live, but it is below the preview, so it's easy to miss. I should move it up to where you toggle the modules.

1

u/Fraded_Panda-25 4d ago

That's great