# Folder Tabs

> File-folder style tabs where the selected tab merges into its panel, switched with radio buttons.

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

## HTML

```html
<div class="folder-tabs">
  <div class="folder-tabs-list" role="radiogroup" aria-label="Documents">
    <label><input type="radio" name="folder-tabs" checked>Notes</label>
    <label><input type="radio" name="folder-tabs">Files</label>
    <label><input type="radio" name="folder-tabs">Links</label>
  </div>
  <div class="folder-tabs-panels">
    <div>3 notes from this week.</div>
    <div>12 files, 48 MB in total.</div>
    <div>5 saved links.</div>
  </div>
</div>
```

## CSS

```css
.folder-tabs {
  width: 250px;
  font: 14px/1.5 system-ui, sans-serif;
}

.folder-tabs-list {
  display: flex;
  gap: 4px;
  padding-left: 8px;
}

.folder-tabs-list label {
  padding: 8px 16px 10px;
  border-radius: 12px 12px 0 0;
  background: #c7d2fe;
  color: #4338ca;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.folder-tabs-list label:hover {
  background: #a5b4fc;
}

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

/* Selected tab takes the panel color, so they read as one shape */
.folder-tabs-list label:has(input:checked) {
  background: #ffffff;
  color: #1e1b4b;
}

.folder-tabs-list label:has(input:focus-visible) {
  outline: 2px solid #4338ca;
  outline-offset: -4px;
}

.folder-tabs-panels {
  min-height: 70px;
  padding: 16px;
  border-radius: 12px;
  background: #ffffff;
  color: #334155;
  box-shadow: 0 10px 24px -12px #312e8159;
}

.folder-tabs-panels > div {
  display: none;
}

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

## Notes

- This CSS Folder Tabs is 60 lines of pure CSS (1.2 KB) with no JavaScript and no dependencies. It uses transitions, box shadows, Flexbox and the :has() selector.
- 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.
