CSS Vertical Tabs

Tabs stacked down the left with their panel on the right, switched with radio buttons and :has().

  • tabs
  • settings
  • radio
  • has
  • side tabs
  • no javascript
HTML
<div class="vtabs">
  <div class="vtabs-list" role="radiogroup" aria-label="Settings">
    <label><input type="radio" name="vtabs" checked>Profile</label>
    <label><input type="radio" name="vtabs">Security</label>
    <label><input type="radio" name="vtabs">Billing</label>
  </div>
  <div class="vtabs-panels">
    <div>Name, photo and a short bio.</div>
    <div>Password and two-factor login.</div>
    <div>Plan, invoices and saved cards.</div>
  </div>
</div>
CSS
.vtabs {
  display: grid;
  grid-template-columns: auto 1fr;
  width: 260px;
  overflow: hidden;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 0 0 1px #e2e8f0;
  font: 14px/1.5 system-ui, sans-serif;
}

.vtabs-list {
  display: grid;
  align-content: start;
  padding: 8px 0;
  border-right: 1px solid #e2e8f0;
  background: #f8fafc;
}

.vtabs-list label {
  padding: 9px 16px;
  border-left: 3px solid transparent;
  color: #64748b;
  font-weight: 600;
  cursor: pointer;
}

.vtabs-list input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.vtabs-list label:hover {
  color: #0f172a;
}

.vtabs-list label:has(input:checked) {
  border-left-color: #0d9488;
  background: #ffffff;
  color: #0f766e;
}

.vtabs-list label:has(input:focus-visible) {
  outline: 2px solid #0d9488;
  outline-offset: -2px;
}

.vtabs-panels > div {
  display: none;
  padding: 16px;
  color: #334155;
}

.vtabs:has(label:nth-child(1) input:checked) .vtabs-panels > :nth-child(1),
.vtabs:has(label:nth-child(2) input:checked) .vtabs-panels > :nth-child(2),
.vtabs:has(label:nth-child(3) input:checked) .vtabs-panels > :nth-child(3) {
  display: block;
}

About this CSS Vertical Tabs

This CSS Vertical Tabs is 59 lines of pure CSS (1.1 KB) with no JavaScript and no dependencies. It uses box shadows, CSS Grid, the :has() selector and the :checked state (no JavaScript). It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #ffffff
  • #e2e8f0
  • #f8fafc
  • #64748b
  • #0f172a
  • #0d9488
  • #0f766e
  • #334155

How to use this vertical tabs

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .vtabs class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback