r/webdev • • 20d ago

Showoff Saturday modest-ui: classless CSS that styles plain HTML

I’ve been building websites for over a decade, and have always tried to do things as vanilla as possible (where applicable).

More recently whilst building components and looking at the libraries out there, I realised that browser technology and CSS has grown to a point where it can do the majority of things we need, without JS (like dialog, detail, and popover tags)

So I started working on modest-ui as a CSS base for all my personal and side projects, and as it’s gotten more stable I’ve recently bumped it to v2.

It’s themeable with CSS vars, can be used as an unobtrusive base layer to built on top of, and can either be used classless (with mdst-ui set on the body) or you can pick and choose classes as needed.

Anyway, it’s open source (MIT), no JS (except for some examples on the site), and currently sits at about 10 kb (gzipped).

https://github.com/thisismodest/modest-ui
https://modest-ui.com

Edit: I forgot to mention it’s ~10kb when gzipped

103 Upvotes

32 comments sorted by

View all comments

1

u/patryk_builds 20d ago

This fits how i build things: server-rendered templates, htmx for the interactive bits, as little js as i can get away with. i use tailwind for that today, so i haven't tried modest-ui yet, but a few things i'd look at first.

  • Forms. that's where classless css usually runs out. do invalid fields, disabled buttons and error messages look right with just native attributes like :user-invalid, or do i need classes there?
  • Content swapped in after load. with htmx i replace chunks of the page with html from the server, so everything has to style correctly without any init step. no js means that should just work, which is a real advantage over component libraries
  • Dialog and popover: do you style the backdrop and the open/close transitions too? that's the part i always end up hand-writing.

10 kB is a good number. curious if it would stay there, or if v3 is where the "just one more component" pressure starts

1

u/_squirts 20d ago

Good points, I’ll run through off the top of my head for each one, and as for the component creep, that’s something I’ll keep an eye out for. I kind of feel like (and hoping) this’ll be mostly “complete” at some point once it covers the majority of the commonly used tags, but also i might just be naive there.

Anyway, for forms, disabled and invalid states work off native attributes (:user-invalid or aria-invalid), but error text under a field isn't styled red, so that'll need a line of css.

Swapped content should work out of the box as it's pure css with no init, and stateful bits read data-state so the server can render it.

Dialog gets a styled backdrop but no open/close transition (the drawer has one, so maybe for consistency I should match those, but if you use it you can copy it for now), and popover needs the .mdst-popover class with no animation.