Skip to content
Product block

Mail Folders Sidebar

Compose button, folders whose unread counts are spoken, colour labels that never rely on colour alone, and a storage meter with a text warning.

199 lineslucide-react
  • sidebar
  • mail
  • folders
  • labels
  • unread

What's included

  • components/sidebar-mail-folders.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add sidebar-mail-folders

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/sidebar-mail-folders.tsx
'use client'

/**
 * <SidebarMailFolders> — a mail-style sidebar: Compose, system folders with
 * unread counts, coloured labels and a storage meter.
 *
 *  - An unread count is content, not decoration. The visible "12" gets an
 *    `sr-only` " unread" beside it so a screen reader hears "Inbox, 12
 *    unread" and not "Inbox, 12". Each link is `relative` because `sr-only`
 *    is absolutely positioned.
 *  - Label colours are never the only signal: every label has its name beside
 *    its dot, and the dot is `aria-hidden`. A colour-only key fails anyone who
 *    cannot tell rose from amber.
 *  - Counts collapse to "99+" past two digits so a busy inbox cannot push the
 *    label out of the row; the real number stays in the accessible name.
 *  - The storage bar is a labelled `role="progressbar"`, and turns to the
 *    destructive colour above 90% with text saying so — a red bar alone is
 *    another colour-only cue.
 */

import * as React from 'react'
import { PenSquare, Inbox, Star, Send, FileText, ShieldAlert, Trash2 } from 'lucide-react'

export interface MailFolder {
  id: string
  label: string
  icon: React.ReactNode
  unread?: number
}

export interface MailLabel {
  id: string
  label: string
  dot: string
}

export interface SidebarMailFoldersProps {
  folders?: MailFolder[]
  labels?: MailLabel[]
  defaultFolderId?: string
  /** Storage used, 0-100. */
  storage?: number
  onCompose?: () => void
  children?: React.ReactNode
  className?: string
}

const icon = 'h-4 w-4 shrink-0'

const DEFAULT_FOLDERS: MailFolder[] = [
  { id: 'inbox', label: 'Inbox', icon: <Inbox aria-hidden className={icon} />, unread: 12 },
  { id: 'starred', label: 'Starred', icon: <Star aria-hidden className={icon} /> },
  { id: 'sent', label: 'Sent', icon: <Send aria-hidden className={`${icon} rtl:-scale-x-100`} /> },
  { id: 'drafts', label: 'Drafts', icon: <FileText aria-hidden className={icon} />, unread: 2 },
  { id: 'spam', label: 'Spam', icon: <ShieldAlert aria-hidden className={icon} />, unread: 134 },
  { id: 'trash', label: 'Trash', icon: <Trash2 aria-hidden className={icon} /> },
]

const DEFAULT_LABELS: MailLabel[] = [
  { id: 'work', label: 'Work', dot: 'bg-sky-500' },
  { id: 'receipts', label: 'Receipts', dot: 'bg-amber-500' },
  { id: 'family', label: 'Family', dot: 'bg-emerald-500' },
]

const shortCount = (n: number) => (n > 99 ? '99+' : String(n))

export function SidebarMailFolders({
  folders = DEFAULT_FOLDERS,
  labels = DEFAULT_LABELS,
  defaultFolderId = 'inbox',
  storage = 64,
  onCompose,
  children,
  className = '',
}: SidebarMailFoldersProps) {
  const uid = React.useId()
  const [activeId, setActiveId] = React.useState(defaultFolderId)
  const nearlyFull = storage > 90

  const row = (active: boolean) =>
    `relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${
      active ? 'bg-primary/10 text-primary' : 'text-muted-foreground hover:bg-muted hover:text-foreground'
    }`

  return (
    <div
      className={`flex h-[32rem] overflow-hidden rounded-2xl border border-border/60 bg-background ${className}`}
    >
      <aside
        aria-label="Mailboxes"
        className="flex w-[240px] shrink-0 flex-col border-e border-border/60 bg-card/40"
      >
        <div className="p-3">
          <button
            type="button"
            onClick={onCompose}
            className="flex w-full items-center justify-center gap-2 rounded-xl bg-primary px-3 py-2.5 text-sm font-semibold text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-card"
          >
            <PenSquare aria-hidden className="h-4 w-4" />
            Compose
          </button>
        </div>

        <nav aria-label="Folders" className="flex-1 space-y-4 overflow-y-auto px-2 pb-3">
          <ul className="space-y-0.5">
            {folders.map((f) => {
              const active = f.id === activeId
              return (
                <li key={f.id}>
                  <a
                    href="#"
                    aria-current={active ? 'page' : undefined}
                    onClick={(e) => {
                      e.preventDefault()
                      setActiveId(f.id)
                    }}
                    className={row(active)}
                  >
                    {f.icon}
                    <span className="flex-1 truncate">{f.label}</span>
                    {f.unread ? (
                      <span
                        className={`text-xs tabular-nums ${active ? 'font-semibold' : 'text-muted-foreground'}`}
                      >
                        {shortCount(f.unread)}
                        <span className="sr-only"> unread{f.unread > 99 ? `, ${f.unread} in total` : ''}</span>
                      </span>
                    ) : null}
                  </a>
                </li>
              )
            })}
          </ul>

          <div>
            <h2
              id={`${uid}-labels`}
              className="px-3 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground"
            >
              Labels
            </h2>
            <ul aria-labelledby={`${uid}-labels`} className="space-y-0.5">
              {labels.map((l) => {
                const active = l.id === activeId
                return (
                  <li key={l.id}>
                    <a
                      href="#"
                      aria-current={active ? 'page' : undefined}
                      onClick={(e) => {
                        e.preventDefault()
                        setActiveId(l.id)
                      }}
                      className={row(active)}
                    >
                      <span aria-hidden className="flex h-4 w-4 shrink-0 items-center justify-center">
                        <span className={`h-2.5 w-2.5 rounded-full border border-transparent ${l.dot}`} />
                      </span>
                      <span className="flex-1 truncate">{l.label}</span>
                    </a>
                  </li>
                )
              })}
            </ul>
          </div>
        </nav>

        <div className="border-t border-border/60 p-4">
          <p id={`${uid}-storage`} className="text-xs text-muted-foreground">
            {nearlyFull ? 'Storage almost full: ' : ''}
            {storage}% of 15 GB used
          </p>
          <div
            role="progressbar"
            aria-labelledby={`${uid}-storage`}
            aria-valuemin={0}
            aria-valuemax={100}
            aria-valuenow={storage}
            className="mt-2 h-1.5 overflow-hidden rounded-full border border-transparent bg-border"
          >
            <div
              className={`h-full rounded-full border border-transparent ${nearlyFull ? 'bg-destructive' : 'bg-primary'}`}
              style={{ width: `${storage}%` }}
            />
          </div>
        </div>
      </aside>

      <main className="hidden min-w-0 flex-1 p-6 sm:block">
        {children ?? (
          <div className="flex h-full min-w-0 items-center justify-center break-words rounded-xl border border-dashed border-border/60 text-sm text-muted-foreground">
            Your page content goes here
          </div>
        )}
      </main>
    </div>
  )
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Install: npm i lucide-react
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/sidebar-mail-folders.tsx and import it where you need the section:

import { SidebarMailFolders } from '@/components/sidebar-mail-folders'

Customize

2 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
foldersMailFolder[]DEFAULT_FOLDERS
labelsMailLabel[]DEFAULT_LABELS
defaultFolderIdstring'inbox'
storageStorage used, 0-100.number64
onCompose() => void—
childrenReact.ReactNode—
classNamestring''

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

sidebar-mail-folders.html
<!--
  Mail Folders Sidebar — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<div class="flex h-[32rem] overflow-hidden rounded-2xl border border-border/60 bg-background ">
  <aside aria-label="Mailboxes" class="flex w-[240px] shrink-0 flex-col border-e border-border/60 bg-card/40">
    <div class="p-3">
      <button type="button" class="flex w-full items-center justify-center gap-2 rounded-xl bg-primary px-3 py-2.5 text-sm font-semibold text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-card"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square-pen h-4 w-4" aria-hidden="true"><path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"></path></svg>Compose</button>
    </div>
    <nav aria-label="Folders" class="flex-1 space-y-4 overflow-y-auto px-2 pb-3">
      <ul class="space-y-0.5">
        <li>
          <a href="#" aria-current="page" class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary bg-primary/10 text-primary">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-inbox h-4 w-4 shrink-0" aria-hidden="true">
              <polyline points="22 12 16 12 14 15 10 15 8 12 2 12"></polyline>
              <path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"></path>
            </svg>
            <span class="flex-1 truncate">Inbox</span>
            <span class="text-xs tabular-nums font-semibold">12<span class="sr-only"> unread</span></span>
          </a>
        </li>
        <li>
          <a href="#" class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary text-muted-foreground hover:bg-muted hover:text-foreground">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-star h-4 w-4 shrink-0" aria-hidden="true">
              <path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"></path>
            </svg>
            <span class="flex-1 truncate">Starred</span>
          </a>
        </li>
        <li>
          <a href="#" class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary text-muted-foreground hover:bg-muted hover:text-foreground">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-send h-4 w-4 shrink-0 rtl:-scale-x-100" aria-hidden="true">
              <path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"></path>
              <path d="m21.854 2.147-10.94 10.939"></path>
            </svg>
            <span class="flex-1 truncate">Sent</span>
          </a>
        </li>
        <li>
          <a href="#" class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary text-muted-foreground hover:bg-muted hover:text-foreground">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-file-text h-4 w-4 shrink-0" aria-hidden="true">
              <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"></path>
              <path d="M14 2v4a2 2 0 0 0 2 2h4"></path>
              <path d="M10 9H8"></path>
              <path d="M16 13H8"></path>
              <path d="M16 17H8"></path>
            </svg>
            <span class="flex-1 truncate">Drafts</span>
            <span class="text-xs tabular-nums text-muted-foreground">2<span class="sr-only"> unread</span></span>
          </a>
        </li>
        <li>
          <a href="#" class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary text-muted-foreground hover:bg-muted hover:text-foreground">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-shield-alert h-4 w-4 shrink-0" aria-hidden="true">
              <path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"></path>
              <path d="M12 8v4"></path>
              <path d="M12 16h.01"></path>
            </svg>
            <span class="flex-1 truncate">Spam</span>
            <span class="text-xs tabular-nums text-muted-foreground">99+<span class="sr-only"> unread, 134 in total</span></span>
          </a>
        </li>
        <li>
          <a href="#" class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary text-muted-foreground hover:bg-muted hover:text-foreground">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash2 lucide-trash-2 h-4 w-4 shrink-0" aria-hidden="true">
              <path d="M3 6h18"></path>
              <path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path>
              <path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path>
              <line x1="10" x2="10" y1="11" y2="17"></line>
              <line x1="14" x2="14" y1="11" y2="17"></line>
            </svg>
            <span class="flex-1 truncate">Trash</span>
          </a>
        </li>
      </ul>
      <div>
        <h2 id="_R_0_-labels" class="px-3 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">Labels</h2>
        <ul aria-labelledby="_R_0_-labels" class="space-y-0.5">
          <li>
            <a href="#" class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary text-muted-foreground hover:bg-muted hover:text-foreground">
              <span aria-hidden="true" class="flex h-4 w-4 shrink-0 items-center justify-center">
                <span class="h-2.5 w-2.5 rounded-full border border-transparent bg-sky-500"></span>
              </span>
              <span class="flex-1 truncate">Work</span>
            </a>
          </li>
          <li>
            <a href="#" class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary text-muted-foreground hover:bg-muted hover:text-foreground">
              <span aria-hidden="true" class="flex h-4 w-4 shrink-0 items-center justify-center">
                <span class="h-2.5 w-2.5 rounded-full border border-transparent bg-amber-500"></span>
              </span>
              <span class="flex-1 truncate">Receipts</span>
            </a>
          </li>
          <li>
            <a href="#" class="relative flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary text-muted-foreground hover:bg-muted hover:text-foreground">
              <span aria-hidden="true" class="flex h-4 w-4 shrink-0 items-center justify-center">
                <span class="h-2.5 w-2.5 rounded-full border border-transparent bg-emerald-500"></span>
              </span>
              <span class="flex-1 truncate">Family</span>
            </a>
          </li>
        </ul>
      </div>
    </nav>
    <div class="border-t border-border/60 p-4">
      <p id="_R_0_-storage" class="text-xs text-muted-foreground">64% of 15 GB used</p>
      <div role="progressbar" aria-labelledby="_R_0_-storage" aria-valuemin="0" aria-valuemax="100" aria-valuenow="64" class="mt-2 h-1.5 overflow-hidden rounded-full border border-transparent bg-border">
        <div class="h-full rounded-full border border-transparent bg-primary" style="width:64%"></div>
      </div>
    </div>
  </aside>
  <main class="hidden min-w-0 flex-1 p-6 sm:block">
    <div class="flex h-full min-w-0 items-center justify-center break-words rounded-xl border border-dashed border-border/60 text-sm text-muted-foreground">Your page content goes here</div>
  </main>
</div>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

10 more blocks in Sidebars

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Sidebars

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Sidebars blocks

View category
Open the full page for this block

Docs Sidebar With Filter

Version picker, a labelled filter that announces its match count, and sections that vanish rather than leave a heading over an empty list.

Sidebars208 lines1 dep

Chat History Sidebar

Conversations grouped by recency with a per-row pin toggle that announces itself, and a hover control that stays reachable by keyboard and on touch.

Sidebars170 lines1 dep
Open the full page for this block

File Explorer Tree Sidebar

A real ARIA tree with roving focus, arrow-key expand and collapse, type-ahead and one tab stop, drawn flat so a screen reader is told the structure.

Sidebars260 lines1 dep