# Vertical Tabs

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

- Category: [CSS Navigation](https://copy-css.com/category/navigation)
- Tags: tabs, settings, radio, has, side tabs, no javascript
- Live preview: https://copy-css.com/snippets/vertical-tabs
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```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

```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;
}
```

## Notes

- 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).
- the :has() selector: Chrome 105+, Safari 15.4+, Firefox 121+.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
