32 CSS Tab Designs07 / 32

Pure CSSMIT licensed

Bento Grid

Three-column bento grid where the tabs themselves are the cards. The active card lifts, gains a colored top stripe, and the panel becomes the fourth bento cell underneath. Pure CSS.

Published

Live Demo
Try it

The code

<div class="tt27">
  <div class="tt27grid">
    <input type="radio" name="tt27" id="tt27-r1" checked />
    <label class="tt27card" for="tt27-r1">
      <span class="tt27ttl">Stats</span>
      <span class="tt27sub">Real-time data</span>
    </label>
    <input type="radio" name="tt27" id="tt27-r2" />
    <label class="tt27card" for="tt27-r2">
      <span class="tt27ttl">Inbox</span>
      <span class="tt27sub">12 new</span>
    </label>
    <input type="radio" name="tt27" id="tt27-r3" />
    <label class="tt27card" for="tt27-r3">
      <span class="tt27ttl">Tasks</span>
      <span class="tt27sub">3 pending</span>
    </label>
  </div>
  <div class="tt27p">Stats — daily and weekly metrics summary.</div>
  <div class="tt27p">Inbox — unread messages from your team.</div>
  <div class="tt27p">Tasks — items due in the next 7 days.</div>
</div>
.tt27 {
  background: #0a0a0e;
  padding: 18px 16px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  min-height: 100vh;
  box-sizing: border-box;
  width: 100%;
}

.tt27grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  min-width: 0;
}

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

.tt27card {
  position: relative;
  padding: 18px 14px 14px;
  background: #18181f;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.25s, background 0.25s, border-color 0.25s, box-shadow 0.3s;
  min-width: 0;
}

.tt27card:hover {
  background: #1f1f28;
  border-color: rgba(255, 255, 255, 0.14);
}

.tt27ttl {
  font: 700 13px/1 ui-sans-serif, system-ui;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tt27sub {
  font: 11px/1 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tt27grid input:checked + .tt27card {
  background: #1c1c26;
  border-color: #7c6cff;
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(124, 108, 255, 0.25);
}

.tt27grid input:focus-visible + .tt27card {
  outline: 2px dashed #7c6cff;
  outline-offset: 3px;
}

.tt27p {
  display: none;
  margin-top: 12px;
  padding: 14px 16px;
  background: #18181f;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  font: 12px/1.55 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.7);
}

.tt27:has(#tt27-r1:checked) .tt27p:nth-of-type(1),
.tt27:has(#tt27-r2:checked) .tt27p:nth-of-type(2),
.tt27:has(#tt27-r3:checked) .tt27p:nth-of-type(3) {
  display: block;
}
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
Here's a working CSS Tab Design from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Bento Grid
Source: https://codefronts.com/navigation/css-tabs/bento-grid/

Three-column bento grid where the tabs themselves are the cards. The active card lifts, gains a colored top stripe, and the panel becomes the fourth bento cell underneath. Pure CSS.
## HTML
```html
<div class="tt27">
  <div class="tt27grid">
    <input type="radio" name="tt27" id="tt27-r1" checked />
    <label class="tt27card" for="tt27-r1">
      <span class="tt27ttl">Stats</span>
      <span class="tt27sub">Real-time data</span>
    </label>
    <input type="radio" name="tt27" id="tt27-r2" />
    <label class="tt27card" for="tt27-r2">
      <span class="tt27ttl">Inbox</span>
      <span class="tt27sub">12 new</span>
    </label>
    <input type="radio" name="tt27" id="tt27-r3" />
    <label class="tt27card" for="tt27-r3">
      <span class="tt27ttl">Tasks</span>
      <span class="tt27sub">3 pending</span>
    </label>
  </div>
  <div class="tt27p">Stats — daily and weekly metrics summary.</div>
  <div class="tt27p">Inbox — unread messages from your team.</div>
  <div class="tt27p">Tasks — items due in the next 7 days.</div>
</div>
```
## CSS
```css
.tt27 {
  background: #0a0a0e;
  padding: 18px 16px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  min-height: 100vh;
  box-sizing: border-box;
  width: 100%;
}

.tt27grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  min-width: 0;
}

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

.tt27card {
  position: relative;
  padding: 18px 14px 14px;
  background: #18181f;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.25s, background 0.25s, border-color 0.25s, box-shadow 0.3s;
  min-width: 0;
}

.tt27card:hover {
  background: #1f1f28;
  border-color: rgba(255, 255, 255, 0.14);
}

.tt27ttl {
  font: 700 13px/1 ui-sans-serif, system-ui;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tt27sub {
  font: 11px/1 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tt27grid input:checked + .tt27card {
  background: #1c1c26;
  border-color: #7c6cff;
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(124, 108, 255, 0.25);
}

.tt27grid input:focus-visible + .tt27card {
  outline: 2px dashed #7c6cff;
  outline-offset: 3px;
}

.tt27p {
  display: none;
  margin-top: 12px;
  padding: 14px 16px;
  background: #18181f;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  font: 12px/1.55 ui-sans-serif, system-ui;
  color: rgba(255, 255, 255, 0.7);
}

.tt27:has(#tt27-r1:checked) .tt27p:nth-of-type(1),
.tt27:has(#tt27-r2:checked) .tt27p:nth-of-type(2),
.tt27:has(#tt27-r3:checked) .tt27p:nth-of-type(3) {
  display: block;
}
```

How this works

The .tt27 demo treats each tab as a bento tile in a three-column grid, the register Apple keynotes and Notion cover pages made shorthand for structured density. .tt27grid uses display: grid with grid-template-columns: repeat(3, 1fr) and a 10px gap; the radio inputs are visually removed with position: absolute; opacity: 0 but stay focusable, and clicks flow through the paired label elements. Each .tt27card holds a .tt27ttl heading and a .tt27sub caption, so the tab itself communicates content before the panel opens.

Activation is pure CSS driven by the sibling combinator .tt27grid input:checked + .tt27card: the checked card gains a #7c6cff violet border, shifts up 2px via transform: translateY(-2px), and casts an 0 8px 18px rgba(124, 108, 255, 0.25) tinted shadow. All four properties share the same transition track (transform, background, border-color, box-shadow) so the lift lands as one coordinated motion instead of a stagger. Hover brightens the card background from #18181f to #1f1f28 without touching the transform, keeping hover and active clearly distinct.

The associated panel is the fourth bento cell: three .tt27p divs are laid out below the grid, hidden by default, and revealed with .tt27:has(#tt27-r1:checked) .tt27p:nth-of-type(1). The :has() parent selector lets the whole thing stay hand-coded, framework-agnostic, and copy-paste ready with no dependencies or JavaScript. Focus visibility rides on input:focus-visible + .tt27card, drawing a dashed 2px violet outline with a 3px offset so keyboard users see the same accent as the checked state. The scoped .tt27 namespace means it drops into any page without leaking styles.

Make it yours

  • Change the grid from three columns to four or six by editing grid-template-columns: repeat(3, 1fr); the panel :has() selectors need one entry per tab, so extend the checked-input list to match.
  • Swap the accent #7c6cff everywhere it appears (border, shadow, focus outline) for your brand hue; the shadow uses the same color at 0.25 alpha so tinted glow reads as intentional rather than muddy.
  • Add an icon row above each .tt27ttl for the full Apple bento register; the flex column with 4px gap already handles vertical rhythm, so an inline svg above the title inherits spacing.
  • Retune the lift by editing translateY(-2px) and the shadow y-offset together; a 4px lift with an 0 12px 24px shadow reads as heavier, useful for larger tiles above 200px tall.
  • Convert the dark palette to light by swapping #0a0a0e, #18181f, and rgba(255,255,255,0.07) for #f8fafc, #fff, and rgba(0,0,0,0.08); the accent shadow tint remains readable on both backgrounds.

Gotchas — read before shipping

  • The :has() selector needs Safari 15.4, Chrome 105, and Firefox 121; on older browsers the panels stay hidden. Add a @supports not (selector(:has(*))) block that shows all panels stacked, or gate the whole demo behind feature detection.
  • Radio inputs with the shared name="tt27" mean multiple instances on one page will interfere; if you drop two bento tab groups on the same route, give each its own name or the second group hijacks the first's selection.
  • For a real WAI-ARIA tabs pattern the radio-input trick is wrong: tabs should be buttons with role="tab" inside a role="tablist", and panels need role="tabpanel" and aria-labelledby. Ship the radio version as a filter chip group, or rewrite the semantics before calling it accessible tabs.
  • The transform: translateY(-2px) on the active card creates a stacking context; if you later add absolutely positioned badges inside the tile they'll be trapped by the transform, so budget for position: absolute children to sit within card bounds.
  • The label text uses white-space: nowrap with text-overflow: ellipsis, so long titles silently truncate on narrow viewports; test with your real product strings, and consider a wrapping variant below the 480px breakpoint.
  • SSR the checked state deliberately: which radio has the checked attribute at render time is what shows on first paint, so if your framework hydrates a different value you'll get a mismatch warning and a flash of the wrong panel.

Browser support

ChromeSafariFirefoxEdge
105+15.4+121+105+

The :has() parent selector is the gating feature; it landed everywhere by January 2024. Grid, sibling combinators, and focus-visible have been baseline for years, so the rest of the demo is safe deep into legacy support.

Techniques used in this demo

Search CodeFronts

Loading…