Browse documentation

Reference / Variants & accessibility

ARIA and data attributes

Match the value of an ARIA state or the presence and value of a data attribute. Useful for components whose state is already present in the markup.

Working example

Use a bracket expression for attributes with named values such as aria-current="page". A class changes styling only, so keep the actual attribute in sync with component state.

HTML
<p data-status="proof" class="inline-flex items-center gap-2 border px-3 py-1 data-[status=proof]:border-dashed">
  <span aria-hidden="true" class="size-2 rounded-full border border-current"></span> Awaiting proof
</p>

Class reference

ClassCSS declarations
aria-busy:opacity-50opacity: 0.5;
aria-[current=page]:font-boldfont-weight: 700;
aria-selected:underlinetext-decoration-line: underline;
aria-expanded:font-boldfont-weight: 700;
data-ready:border-blackborder-color: #000;
data-[status=proof]:border-dashedborder-style: dashed;
View full generated CSS
Compiled CSS
.data-\[status\=proof\]\:border-dashed[data-status="proof"] {
  border-style: dashed;
}
.data-ready\:border-black[data-ready] {
  border-color: #000;
}
.aria-\[current\=page\]\:font-bold[aria-current="page"] {
  font-weight: 700;
}
.aria-busy\:opacity-50[aria-busy="true"] {
  opacity: 0.5;
}
.aria-expanded\:font-bold[aria-expanded="true"] {
  font-weight: 700;
}
.aria-selected\:underline[aria-selected="true"] {
  text-decoration-line: underline;
}