Skip to content

Repository files navigation

Pure CSS Components

Pure CSS Components

Netlify Status license

UI components built with HTML and CSS only. Zero JavaScript, in 2014 and today.

See the components · Why

In 2014, a modal, a carousel or a set of tabs meant a jQuery plugin. This project built them with no JavaScript at all, storing their state in hidden checkboxes, radio buttons and the URL hash. A lot of people shipped them to production.

Twelve years later, the browser does it natively. <details>, <dialog>, invoker commands, the Popover API, anchor positioning and CSS carousels turned those hacks into real, accessible platform features. So the idea is relevant again, and the site now shows both sides.

What's inside

Then and now

Each of the six original components, working as it was written in 2014, next to the way HTML and CSS build it natively today.

Component 2014 Today
Carousel Radio inputs + labels scroll-snap, ::scroll-button(), ::scroll-marker
Collapse Hidden checkbox / radios <details name>, ::details-content
Dropdown Hidden checkbox, :hover Popover API, anchor positioning, interestfor
Modal Hidden checkbox <dialog>, commandfor, @starting-style
Tab Radio inputs Exclusive <details name> laid out as tabs
Tooltip :hover + ::after popover="hint", interestfor, anchor positioning

Born native

Components with no 2014 version. No hidden input could fake them, and until recently each one needed a script.

Some of these features are new. Every exhibit lists where it works today, and browsers without support get a plain version that still works.

Principles

  • Zero JavaScript. Not in the components, not on the site. It works with JavaScript turned off.
  • Honest support. Every native feature shows its real browser support.
  • Progressive enhancement. New features sit behind @supports, so nothing breaks where they are missing.
  • Accessible by default. The native versions use real elements with focus, keyboard and screen reader support built in.

Using the code

Each component shows its HTML and CSS on the site, ready to copy. The 2014 originals are kept for history: if you are building something today, use the native versions.

The original Stylus sources and zip downloads are in the v2.0.0 release.

Running locally

Requires Node.js 22.12+ and pnpm. Built with Astro.

pnpm install
pnpm dev
  • pnpm dev: start the dev server
  • pnpm build: type-check and build to dist
  • pnpm lint: lint scripts and styles

Each component lives in its own folder:

  • src/exhibits/<name>/then.*: the 2014 original
  • src/exhibits/<name>/now.*: the native version
  • src/exhibits/born/<name>/demo.*: born native components

Support

If this project helped you, back then or today, you can sponsor my work on GitHub.

License

MIT License © Felipe Fialho

About

☕ A set of common UI Components using just the power of CSS and without JavaScript.

Topics

Resources

Stars

691 stars

Watchers

23 watching

Forks

Used by

Contributors

Languages