Skip to content
Product block

Floating Inset Sidebar

A floating card on a tinted canvas beside an inset content surface, with a labelled usage meter and an upgrade card that is one skippable Tab stop.

137 lineslucide-react
  • sidebar
  • floating
  • inset
  • card
  • upgrade

What's included

  • components/sidebar-floating-inset.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add sidebar-floating-inset

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

Your page content goes here

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

Source

components/sidebar-floating-inset.tsx
'use client'

/**
 * <SidebarFloatingInset> — the "inset" sidebar: a floating card on a tinted
 * canvas, with the page content sitting in a second rounded surface beside it
 * rather than butting against a hairline.
 *
 *  - Both surfaces are cards on a `bg-muted` canvas, so the gap between them
 *    is the separator. No border-e to flip in RTL; the layout mirrors from
 *    flex order alone.
 *  - The usage meter is a real `role="progressbar"` with a value and a name.
 *    A bare coloured bar is invisible to a screen reader, and a number in the
 *    caption alone is not a progressbar.
 *  - The promo card is a labelled region with one button, not a link farm, so
 *    it can be skipped past in a single Tab stop when the user does not want it.
 */

import * as React from 'react'
import { LayoutGrid, Layers, MessageSquare, Bookmark, Sparkles } from 'lucide-react'

export interface FloatingItem {
  id: string
  label: string
  icon: React.ReactNode
}

export interface SidebarFloatingInsetProps {
  items?: FloatingItem[]
  defaultActiveId?: string
  /** Percent of the plan used, 0-100. */
  used?: number
  children?: React.ReactNode
  className?: string
}

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

const DEFAULT_ITEMS: FloatingItem[] = [
  { id: 'board', label: 'Board', icon: <LayoutGrid aria-hidden className={icon} /> },
  { id: 'layers', label: 'Layers', icon: <Layers aria-hidden className={icon} /> },
  { id: 'comments', label: 'Comments', icon: <MessageSquare aria-hidden className={icon} /> },
  { id: 'saved', label: 'Saved', icon: <Bookmark aria-hidden className={icon} /> },
]

export function SidebarFloatingInset({
  items = DEFAULT_ITEMS,
  defaultActiveId = 'board',
  used = 72,
  children,
  className = '',
}: SidebarFloatingInsetProps) {
  const uid = React.useId()
  const [activeId, setActiveId] = React.useState(defaultActiveId)
  const meterLabel = `${uid}-meter`

  return (
    <div className={`flex h-[32rem] gap-2 overflow-hidden rounded-2xl bg-muted/60 p-2 ${className}`}>
      <aside
        aria-label="Application"
        className="flex w-[240px] shrink-0 flex-col rounded-2xl border border-border/60 bg-card p-3 shadow-sm"
      >
        <div className="flex items-center gap-2 px-2 py-1.5">
          <span
            aria-hidden
            className="flex h-8 w-8 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground"
          >
            F
          </span>
          <span className="text-sm font-semibold tracking-tight">Figment</span>
        </div>

        <nav aria-label="Main" className="mt-3 flex-1 space-y-1">
          {items.map((item) => {
            const active = item.id === activeId
            return (
              <a
                key={item.id}
                href="#"
                aria-current={active ? 'page' : undefined}
                onClick={(e) => {
                  e.preventDefault()
                  setActiveId(item.id)
                }}
                className={`flex items-center gap-3 rounded-full px-3.5 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${
                  active
                    ? 'bg-primary text-primary-foreground shadow-sm'
                    : 'text-muted-foreground hover:bg-muted hover:text-foreground'
                }`}
              >
                {item.icon}
                <span className="min-w-0 flex-1 truncate">{item.label}</span>
              </a>
            )
          })}
        </nav>

        <section
          aria-labelledby={`${uid}-promo`}
          className="rounded-xl border border-border/60 bg-muted/50 p-3"
        >
          <h2 id={`${uid}-promo`} className="flex items-center gap-1.5 text-sm font-semibold">
            <Sparkles aria-hidden className="h-4 w-4 text-primary" />
            Free plan
          </h2>
          <p id={meterLabel} className="mt-1 text-xs text-muted-foreground">
            {used}% of your 50 boards used
          </p>
          <div
            role="progressbar"
            aria-labelledby={meterLabel}
            aria-valuemin={0}
            aria-valuemax={100}
            aria-valuenow={used}
            className="mt-2 h-1.5 overflow-hidden rounded-full bg-border"
          >
            <div className="h-full rounded-full bg-primary border border-transparent" style={{ width: `${used}%` }} />
          </div>
          <button
            type="button"
            className="mt-3 w-full rounded-lg bg-foreground px-3 py-1.5 text-xs font-semibold text-background 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"
          >
            Upgrade
          </button>
        </section>
      </aside>

      <main className="hidden min-w-0 flex-1 rounded-2xl border border-border/60 bg-background p-6 shadow-sm sm:block">
        {children ?? (
          <div className="flex min-h-full min-w-0 items-center justify-center break-words rounded-xl border border-dashed border-border/60 p-4 text-center 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-floating-inset.tsx and import it where you need the section:

import { SidebarFloatingInset } from '@/components/sidebar-floating-inset'

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
itemsFloatingItem[]DEFAULT_ITEMS
defaultActiveIdstring'board'
usedPercent of the plan used, 0-100.number72
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-floating-inset.html
<!--
  Floating Inset 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] gap-2 overflow-hidden rounded-2xl bg-muted/60 p-2 ">
  <aside aria-label="Application" class="flex w-[240px] shrink-0 flex-col rounded-2xl border border-border/60 bg-card p-3 shadow-sm">
    <div class="flex items-center gap-2 px-2 py-1.5">
      <span aria-hidden="true" class="flex h-8 w-8 items-center justify-center rounded-xl bg-primary text-sm font-bold text-primary-foreground">F</span>
      <span class="text-sm font-semibold tracking-tight">Figment</span>
    </div>
    <nav aria-label="Main" class="mt-3 flex-1 space-y-1">
      <a href="#" aria-current="page" class="flex items-center gap-3 rounded-full px-3.5 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary bg-primary text-primary-foreground shadow-sm">
        <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-layout-grid h-4 w-4 shrink-0" aria-hidden="true">
          <rect width="7" height="7" x="3" y="3" rx="1"></rect>
          <rect width="7" height="7" x="14" y="3" rx="1"></rect>
          <rect width="7" height="7" x="14" y="14" rx="1"></rect>
          <rect width="7" height="7" x="3" y="14" rx="1"></rect>
        </svg>
        <span class="min-w-0 flex-1 truncate">Board</span>
      </a>
      <a href="#" class="flex items-center gap-3 rounded-full px-3.5 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-layers h-4 w-4 shrink-0" aria-hidden="true">
          <path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path>
          <path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path>
          <path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>
        </svg>
        <span class="min-w-0 flex-1 truncate">Layers</span>
      </a>
      <a href="#" class="flex items-center gap-3 rounded-full px-3.5 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-message-square h-4 w-4 shrink-0" aria-hidden="true">
          <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
        </svg>
        <span class="min-w-0 flex-1 truncate">Comments</span>
      </a>
      <a href="#" class="flex items-center gap-3 rounded-full px-3.5 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-bookmark h-4 w-4 shrink-0" aria-hidden="true">
          <path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"></path>
        </svg>
        <span class="min-w-0 flex-1 truncate">Saved</span>
      </a>
    </nav>
    <section aria-labelledby="_R_0_-promo" class="rounded-xl border border-border/60 bg-muted/50 p-3">
      <h2 id="_R_0_-promo" class="flex items-center gap-1.5 text-sm font-semibold"><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-sparkles h-4 w-4 text-primary" aria-hidden="true"><path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"></path><path d="M20 3v4"></path><path d="M22 5h-4"></path><path d="M4 17v2"></path><path d="M5 18H3"></path></svg>Free plan</h2>
      <p id="_R_0_-meter" class="mt-1 text-xs text-muted-foreground">72% of your 50 boards used</p>
      <div role="progressbar" aria-labelledby="_R_0_-meter" aria-valuemin="0" aria-valuemax="100" aria-valuenow="72" class="mt-2 h-1.5 overflow-hidden rounded-full bg-border">
        <div class="h-full rounded-full bg-primary border border-transparent" style="width:72%"></div>
      </div>
      <button type="button" class="mt-3 w-full rounded-lg bg-foreground px-3 py-1.5 text-xs font-semibold text-background 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">Upgrade</button>
    </section>
  </aside>
  <main class="hidden min-w-0 flex-1 rounded-2xl border border-border/60 bg-background p-6 shadow-sm sm:block">
    <div class="flex min-h-full min-w-0 items-center justify-center break-words rounded-xl border border-dashed border-border/60 p-4 text-center 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