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
Awaiting proof
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.
<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
| Class | CSS declarations |
|---|---|
aria-busy:opacity-50 | opacity: 0.5; |
aria-[current=page]:font-bold | font-weight: 700; |
aria-selected:underline | text-decoration-line: underline; |
aria-expanded:font-bold | font-weight: 700; |
data-ready:border-black | border-color: #000; |
data-[status=proof]:border-dashed | border-style: dashed; |
View full generated 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;
}