Skip to content
coatx
Esc
↑↓navigate↵open⌘Jpreview
On this page

Plain HTML

Style native checkbox, details, dialog, and aria-invalid states with zero JavaScript.

coatx CSS matches native pseudo-classes and ARIA attributes, so plain HTML elements pick up component styling with no framework and no JS props.

Native checkbox & radio

The checkbox recipe styles :checked, :indeterminate, and :disabled natively:

<link rel="stylesheet" href="coatx/styles.css" />
<!-- When combining with Tailwind or your own stylesheet, the coatx <link> goes first. -->

<label>
  <input type="checkbox" class="..." />
  Accept the terms
</label>
import { checkbox } from "coatx/checkbox";

// Spread once at render time; the browser handles state changes.
input.className = checkbox().class;

Checking, unchecking, or disabling the input updates the visuals automatically — no re-render needed.

Native disclosure with details

Accordion and collapsible styles respond to the [open] attribute, so <details> works out of the box:

<details>
  <summary>Shipping options</summary>
  <p>Free standard shipping over $50.</p>
</details>

Spread accordionItem() / collapsible() onto the <details> element and the open-state styles follow the native toggle.

Native dialog

Dialog content styles respond to [open], matching the native <dialog> element:

<dialog id="confirm">
  <h2>Discard changes?</h2>
  <form method="dialog">
    <button value="cancel">Cancel</button>
    <button value="confirm">Discard</button>
  </form>
</dialog>

<script>
  document.getElementById("confirm").showModal();
</script>

Invalid fields with aria-invalid

Inputs, textareas, selects, and checkboxes style :user-invalid and [aria-invalid="true"]:

<label for="email">Email</label>
<input id="email" type="email" required aria-invalid="true" />

Mark the field aria-invalid="true" from server-rendered validation errors (or let the browser apply :user-invalid after interaction) and the error ring appears — no JS state required.

See Headless UI & state for the full list of selectors coatx matches.

Was this page helpful?