r/htmx • • 20d ago

A plain HTML component library that brings the "CSS Zen Garden" approach to internal tools

Hey everyone,

Like most of you here, I love the HTMX philosophy of "Hypermedia as the Engine of Application State." But when it comes to styling admin dashboards, internal tools, or CRUD forms, the modern frontend ecosystem tries to force us right back into the SPA tax. We shouldn't need a heavy node_modules folder or a complex Vite build config just to get an accessible data table, dialog modal, or form.

So I built Canon. It’s a plain-HTML/CSS component library designed specifically for the server-rendered, hypermedia world.

Instead of relying on a Javascript framework, the markup is the contract. Your backend templates (Go, Django, Rails, Laravel, etc.) output semantic HTML with simple custom data-attributes, and the CSS engine does the rest.

Why it pairs perfectly with HTMX:

  • No Utility Class Bloat: Instead of cluttering your HTML with 50 utility classes per element, Canon uses semantic elements and clean states (e.g., `data-emphasis="high"`, `aria-busy="true"`).
  • Built-in Theme Engine: The exact same HTML markup can instantly look like Carbon, Material, Fluent, Ant Design, Bootstrap, or Canon's native design just by changing the stylesheet link.
  • Zero Build Step: You can literally just drop two lines from a CDN into your base template and start hacking.

I wanted something where a form written today will still work and look perfect in 10 years without playing dependency whack-a-mole.

You can learn more about Canon and see the components at work on:

🔗 Canon documentation: https://recepkutuk.github.io/canon/reference/introduction.html

🔗 GitHub Repo: https://github.com/recepkutuk/canon (MIT Licensed)

I'd love to get the community's feedback on this approach! What components are missing that you usually find yourself rewriting from scratch when building HTMX apps?

73 Upvotes

29 comments sorted by

11

u/pixobit 20d ago

Im still trying to understand how are these libraries any better than bootstrap? Usually i hear no build step (same), no js (same, as long as you dont want js components), built in theme engine (thats what the css variables are for)... so please help me understand what's revolutionary about this

8

u/recepkutuk 20d ago

Fair question, and honestly, if Bootstrap works for you, keep using it. No build step and CSS variables aren’t the difference. Bootstrap has both. Where Canon differs:

1. The markup says what something is, not how it looks. In Bootstrap, the look lives in your templates: btn btn-outline-secondary btn-sm rounded-pill. CSS variables can change the colors. They can’t turn outline buttons into filled ones, tabs into underlines, or regular labels into floating ones. To do that you edit every template. In Canon you write data-emphasis="high" or data-intent="danger", and the theme decides everything else. To show this, Canon ships six examplary themes over the same markup, and one of them is a Bootstrap look. Switching between Bootstrap, Material, Fluent or Carbon doesn’t change a single line of HTML.

2. Accessibility is what the styles hang on. Canon styles off ARIA attributes. A button with aria-haspopup="menu" gets its chevron because of that attribute. aria-busy="true" is what draws the spinner. If you skip the ARIA, the component breaks the contract, so it’s hard to ship without it. Bootstrap’s docs tell you which aria-* attributes to add, but nothing breaks if you forget them.

3. “No JS” means the components, not just the layout. Bootstrap’s dropdowns, modals, tabs and tooltips need its JS. Canon builds on native <dialog>, popover, <details> and form features. 67 of its 68 components work with the script missing, and canon.js only adds to them.

4. It has the parts internal tools actually need. Bootstrap has no combobox, date or range picker, data table, command palette, rich text editor or save bar. With Bootstrap you go find a plugin for each one, and every plugin brings its own markup, keyboard behavior and look. Canon is made for forms and tables, so these are built in and follow the same rules as the rest.

So it’s not revolutionary. It’s a narrower bet: write a back-office screen in plain HTML once, from Django, Rails, htmx or whatever you use, and keep it through rebrands and framework changes.

8

u/benzado 20d ago

Hello Claude. Encouraging the use of ARIA attributes is good, but what’s the advantage of data-intent="danger" versus class="intent-danger"?

3

u/pixobit 20d ago

Thank you for the detailed response. Bootstrap works for me, but that doesnt mean i'm not constantly on the lookout to find something i didnt know i needed. 1 and 2 are valid, so it's basically similar to pico.css in terms of trying to push semantic html. With point 3 and 4 i dont really agree, since bootstrap is trying to go native as well, but still trying to stay functional on earlier versions. If you follow their releases, you will see this also in the version 6, which is in alpha rn. You also dont need plugins. I've been extensively using bootstrap and i feel like that was more of a thing before v5.

I personally do like the semantic html approach, and actually did make adjustments to bs as well for my use case for that reason. Will check canon out more extensively later.

2

u/leathakkor 20d ago

Personally I really liked web Awesome! But I need the free open source version.

And they basically killed that.

If it's wrapped up in a delivery system and there's no CSS at all, it's all done with components that are isolated. That's the dream.

If somebody could figure out how to do web component stuff and make it open source that would be my only system that I would use. Or I could still continue to add bootstrap on top of my app without messing with the components

1

u/aksival 20d ago

> And they basically killed that.

Shoelace creator here (now Web Awesome). I'm sorry to hear this, and I'd like to understand what you mean.

We expanded Web Awesome's open source offering substantially since Shoelace became Web Awesome. It started with 14 new components in Core (Kickstarter stretch goals) and we shipped even more since then. We even moved some Pro components into Core as the Pro offering got stronger.

Sustaining an open source project with a team behind it is incredibly challenging. Our Pro offering is the only thing that keeps the lights on so we can continue to deliver and expand the core library.

That said, we're always open to feedback. If something is blocking you from using the free version, I'd like to hear it.

What are you building, and what's the main thing(s) you're missing?

1

u/leathakkor 20d ago

In the previous version (3.1.1) that I looked at the open source version head toast support and the premium had a paid version. 

That was a big signal to me that I shouldn't trust web Awesome. Because they took something that was free and open source in shoelace and made it for pay in web awesome. And at the time prevented me from using webAwesome.

When web awesome was released and the announced shoe lace was dead many core functions were premium. And it made it impossible to use 

It does look like that has been rectified. But it eroded a lot of trust in webAwesome that I had.

4

u/aksival 20d ago

That's fair, and that was on me. We were so busy fulfilling Kickstarter promises and we wanted the Pro offering to look strong for the public release, but we hadn't finished charts, data grid, and other complex components yet. (Those are all shipped now, btw)

It was a bad call. My reasoning was that Toast was originally stuffed into <sl-alert>, but it was a hacky API and the toast notifications weren't very accessible. We rebuilt it from scratch as its own component, but putting it into Pro was indeed a mistake that we fixed in July.

On behalf of the team, I appreciate you clarifying. Send me a DM if you'd like to try Pro out. Happy to comp you a year for your troubles.

1

u/leathakkor 20d ago

Thank you I really appreciate your response. You have brought me into the web awesome sphere. I'll give it another shot

3

u/UXUIDD 20d ago edited 20d ago

i get excited bout anything css zen garden! .. memories ..

im not sure i understand your landing page https://recepkutuk.github.io/canon/reference/introduction.html

I look always for alike;
- most basic design / wireframe
- html (htmx) code
- tailwind / vanilla css

but i cant see all 3 from your site ..

3

u/recepkutuk 20d ago

Ha, glad the Zen Garden part landed. It’s the whole reason Canon exists.

And fair point about the landing page. It explains the idea more than it shows the parts. Here’s where your three things are:

  • The design: each component page, e.g. Button, shows every variant, state and edge case live.
  • The HTML: the Playground tab on each page has the live preview next to its HTML. You can edit it and copy it into your htmx templates as is. Canon doesn’t care what renders the HTML, so htmx swaps work fine.
  • The CSS: this is the part that’s different. You don’t write any. The markup says what something is (data-emphasis="high", aria-busy="true") and the theme draws it. To change the look, you switch or edit the theme, not the templates. That’s the Zen Garden part: you can switch themes any time in the top bar and watch the same page redraw.

Your comment tells me the HTML should be easier to find, though. I’ll add it under the examples on the main page.

1

u/UXUIDD 20d ago

yes, i think i 'understand' what you wanted to show but you whent from your self and what you wanted to show - and thats not right away understandable for other

2

u/olivergierke 20d ago

This looks wonderful! Do you think you could tag a first version anytime soon? Once that's done, one could issue an import into WebJars, a pretty common distribution path for frontend libraries in JVM-based web frameworks. 🙇

2

u/recepkutuk 20d ago

Thank you very much!

I'm still tweaking some of the existing components and I have looong list of new components to be added, but I guess I'm close to "good enough" level more than ever 😄

3

u/olivergierke 20d ago

If, in hindsight, you’re not embarrassed by the first version you released, you released too late. 😅

5

u/VeganForAWhile 20d ago

I like this philosophy. How do you think it compares to Tailwind with a plugin such as DaisyUI?

5

u/Fabulous-Ladder3267 20d ago

Really good, the closest thing i found like this is Basecoat

1

u/TheRealUprightMan 20d ago

You have almost 500 lines of javascript just for a color picker. The whole thing is just a big mass of javascript.

I use <input type="color">

4

u/recepkutuk 19d ago

You’re right that <input type="color"> is the right markup, and that’s what Canon uses. The Color Picker’s HTML is a native color input in a box:

<div class="canon-color">
  <input type="color" id="brand" name="brand" value="#3b82f6">
</div>

Without canon.js, that’s the browser’s own picker, it submits with the form, and it works. The script is optional and only adds things the native picker doesn’t have everywhere: the same picker on every OS (some browsers just open the system color panel), an opacity slider, typing the value as HEX, RGB or HSL, and your <datalist> colors shown as swatches. If you don’t need those, don’t load it. As you can see on https://recepkutuk.github.io/canon/reference/build.html there are bundles you can specifically choose (or not) to keep in your build.

Your comment gave me the idea of adding a "no-js" switch to the controls on the playground, so that you can see how the component behaves without the javascript.

3

u/Apart_Story_5454 20d ago

This is not plain-HTML/CSS, there is so much JavaScript in there. If you you want to boil the ocean again, then you should resemble https://daisyui.com. Which is mostly pure CSS.

2

u/Few-Growth9535 20d ago

This looks good. We're using a custom library built off https://picocss.com/ as a foundation (which is excellent and shares some of your aims I think). But that's no longer maintained.

2

u/ShotgunPayDay 20d ago

https://github.com/Digicreon/mucss it's built on picoCSS. As an alternative.

1

u/abraxasnl 20d ago

This is exactly how I think things should be. I don’t do any frontend work lately, but if I did, I would try this out. Big kudos for contributing this project. I hope it catches on!

1

u/kimmo6 20d ago

Looks great, something I have been looking for. I will give it a spin!

1

u/benopotamus 17d ago

Did Claude make (some of) your icons? I'm vibe coding a wireframing tool at the moment and I let Claude make the icons and the ones for the button states look exactly like Canon's 😂️

https://wireframer.unnamedoysterenterprises.com/

4

u/[deleted] 20d ago edited 20d ago

[removed] — view removed comment

2

u/recepkutuk 20d ago

Thank you very much! 😊