Align

No dependencies
Code format

Install with shadcn

Needs a free account token. Get a token

npx shadcn@latest add @movin/radio-align

About this component

Text alignment buttons above a paragraph of placeholder lines. Choosing left, centre or right slides every line across to its new edge one after another; justify stretches all but the last line to the full width. Pure CSS: each line knows its own width, and one --k (0, 0.5, 1) says how far across it goes.

Triggers

  • Click
  • State change
  • Delay stagger

Techniques

  • CSS variables
  • Transition delay stagger
  • Transform only

Difficulty

Intermediate

Accessibility

Keyboard and screen readers

Real native radios (visually hidden: absolute, 1x1, opacity 0) inside <label>s in a role="radiogroup" with an aria-label, so arrow keys, focus and screen readers work. Each radio is labelled (Align left, Align centre, Align right, Justify); the icons are aria-hidden.

Reduced motion

The changes are instant.

Use it in anything you build, commercial and client work included. Licence

More radios

See all
DaylightGet code
DeliveryGet code
DialGet code
DieGet code