Style loading states, transitions, and errors with CSS.

State Attributes

html★ sets data attributes that you can target with CSS:

Loading Indicators

Simple Opacity

Spinner

Parent Awareness with :has()

View Transitions

Basic Setup

Slide Transition

Different Transitions for Different Elements

Error Styling

SSE Connection States

Button States

Complete Example

Tip: Keep transitions short (100-200ms) for a snappy feel. Longer animations can make the UI feel sluggish.