About this set
A dark segmented control with three options, Monthly, Yearly and Lifetime, where a light pill slides behind the selected option, and a price card underneath that changes with it: 19 dollars a month, 15 dollars a month billed yearly, or 390 dollars once. It is the billing-period switcher found on pricing pages, but the same pattern works for any two to four views that share one card, such as Day, Week and Month on a chart. Each option is a tab and each price card is its own tabpanel, so the content is real markup rather than values copied from data attributes. The script sets aria-selected, the roving tabindex and the hidden panels, and moves the pill by reading the selected tab’s offsetLeft and offsetWidth, with a ResizeObserver keeping it aligned. In the Bootstrap version the options are .nav-pills run by the Tab plugin with the active background made transparent so the sliding pill shows through; the Tailwind version uses aria-selected utilities.
What’s included
- Light pill slides behind the selected option
- Each price card is a real tabpanel
- Designed for dark backgrounds, with a light blue focus ring
- Works for two to four options
- Pill movement disabled under reduced motion
Accessibility
The options are tabs in a tablist labelled Billing period, and each controls a price panel labelled by its tab. Only the selected tab is in the Tab order; Left and Right (or Up and Down) move between tabs and select them, and Home and End jump to the first and last tab. Keyboard focus draws a 2px light blue outline that stands out on the dark surface, and the pill and colour transitions are removed under prefers-reduced-motion.
Customise it
Colours are --pt-bg, --pt-border, --pt-muted, --pt-thumb, --pt-on and --pt-focus on .ptabs in plain CSS and Bootstrap, where the pill padding comes from --bs-nav-link-padding-x and -y. In Tailwind edit the --color-pt-* theme colours and the px-[22px] and py-[9px] utilities.

















