Browse documentation

Reference / Variants & accessibility

Form states

Match the browser’s checked, required, valid, invalid, readonly, and enabled or disabled states.

Working example

Enter 100 or clear the field to see the dashed border. Native min, max, and required constraints determine when invalid matches.

HTML
<label class="block">Edition number (1 to 99)
  <input type="number" min="1" max="99" required value="12"
    class="mt-1 block w-28 border-2 p-2 valid:border-solid invalid:border-dashed">
</label>

Class reference

ClassCSS declarations
checked:accent-blackaccent-color: #000;
required:border-l-2border-left-width: 2px;
invalid:border-dashedborder-style: dashed;
valid:border-solidborder-style: solid;
disabled:opacity-50opacity: 0.5;
read-only:bg-neutral-100background-color: oklch(0.95 0 0);
placeholder-shown:italicfont-style: italic;
View full generated CSS
Compiled CSS
.checked\:accent-black:checked {
  accent-color: #000;
}
.required\:border-l-2:required {
  border-left-width: 2px;
}
.valid\:border-solid:valid {
  border-style: solid;
}
.invalid\:border-dashed:invalid {
  border-style: dashed;
}
.placeholder-shown\:italic:placeholder-shown {
  font-style: italic;
}
.read-only\:bg-neutral-100:read-only {
  background-color: oklch(0.95 0 0);
}
.disabled\:opacity-50:disabled {
  opacity: 0.5;
}