Tabs built entirely with HTML and CSS: hidden radio inputs, their labels and the :checked selector switch the panels, and a pill indicator slides to the active tab. No JavaScript is involved, which makes it a good fit for product details, settings pages, static sites and email-safe prototypes.
How it works
The root div.rtb-tabs starts with four input.rtb-input radios that share one name. They come before the .rtb-bar and .rtb-panels, so the general sibling selector ~ can reach both. Each label.rtb-tab is tied to its radio with for, so clicking a label checks the radio. The radios are visually hidden with opacity: 0 but stay in the tab order.
The numbered modifier classes do the matching: .rtb-input--2:checked ~ .rtb-panels .rtb-panel--2 shows the second panel, and every other .rtb-panel stays at display: none. The same pattern sets --rtb-index on .rtb-bar, and .rtb-indicator moves with translateX(calc(var(--rtb-index) * 100%)), so the accent pill glides under the checked label. Because the selectors use classes rather than IDs, you can repeat the component on one page; only the name, id and for values must be unique per instance. Panels fade in with a short keyframe animation.
The demo panels show the kinds of content tabs usually hold: stat tiles (.rtb-stats), a check list (.rtb-checks), a definition list (.rtb-specs) and numbered steps (.rtb-steps).
Customization
--rtb-accentand--rtb-on-accenton.rtb-tabs: the indicator color and the text color on top of it; the accent is reused for stats, checks and step numbers.--rtb-bgand--rtb-surface: card background and tab bar background.--rtb-count: the number of tabs. To add a fifth tab, set it to5, addrtb-input--5,rtb-tab--5andrtb-panel--5, and copy the--5lines in the:checked,--rtb-indexand:focus-visiblerules.- Add
checkedto a different radio to open another tab on load. --rtb-speed: duration of the indicator slide and the panel fade.min-heighton.rtb-panels: keeps the card height steady when panels have different lengths; lower it or remove it for content-sized panels.
Use cases
- Documentation pages: readers switch between sections with tabs that need no scripts
- Pricing and feature comparisons: a sliding pill indicator highlights the active tab
- Static sites: panels fade in using only radio inputs and the :checked selector
- Lightweight pages: accessible tabs work where JavaScript is disabled or restricted
Accessibility
Because the controls are real radio buttons, screen readers announce them as a group of options ("Overview, radio button, 1 of 4") inside the labelled role="group", and the native keyboard model applies: Tab moves into the group and the arrow keys switch tabs. A white ring is drawn around the label of a focused radio with :focus-visible. Each panel is a section with aria-labelledby pointing to its label, and hidden panels use display: none, so they are skipped by assistive technology. Icons are aria-hidden. With prefers-reduced-motion: reduce the slide and fade are turned off.
Usage notes
This is not the ARIA tabs pattern (role="tablist"), which needs JavaScript for focus management; radio semantics are the honest choice for a CSS-only version.