← All elements
<fieldset class="ss"><legend>Size</legend><div class="tk"><input type="radio" name="ss" id="s-xs"><label for="s-xs">XS</label><input type="radio" name="ss" id="s-s"><label for="s-s">S</label><input type="radio" name="ss" id="s-m" checked><label for="s-m">M</label><input type="radio" name="ss" id="s-l"><label for="s-l">L</label><input type="radio" name="ss" id="s-xl"><label for="s-xl">XL</label><i></i></div></fieldset>About this slider
A size selector styled as a slider, where radio stops move a thumb and fill the track up to the choice.
How it works
Five radios sit in a grid under a track. :has() reads which radio is checked and sets a position number, and the filled bar width is that number times the column width. The thumb is a pseudo-element at the end of the fill, so it slides with it.
Ways to customise it
- Change the size labels.
- Change #ea580c for the accent.
- To add stops, change the column count, track width and :has() rules.
Good to know
A fieldset and legend name the group, and arrow keys move between sizes as with any radio set. The selected label also grows, so the choice is not shown by colour alone.
Open an example, copy the HTML and the CSS, and paste them into your page. There is nothing to install and no JavaScript to load.