Skip to content
Product block

Slide-Over Edit Panel

A side sheet for editing a record without losing the list behind it — native <dialog> for the trapping, a data attribute for the slide, and a sticky footer so Save never scrolls away.

208 lineslucide-reactAdded 8 Aug 2026Updated 11 Sept 2026
  • drawer
  • sheet
  • slide-over
  • panel
  • dialog

What's included

  • components/slide-over-panel.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add slide-over-panel

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

Edit customer

Changes apply immediately and are visible to everyone on the team.

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

Source

components/slide-over-panel.tsx
'use client'

/**
 * <SlideOverPanel> — a side sheet for editing a record without leaving the list.
 *
 * The reason to reach for one over a route: the context behind it is the
 * point. Editing a row in a table is much easier when the table is still
 * visible, and a full-page form loses that.
 *
 * Also built on native `<dialog>` + `showModal()`, so the focus trap, top
 * layer, page inertness and Escape all come from the browser rather than
 * from an effect hook. What that leaves is the animation, which is the one
 * thing `<dialog>` makes awkward:
 *
 *   A modal dialog is `display: none` when closed, and you cannot transition
 *   out of `display: none`. So the open state is driven by a data attribute
 *   set one frame after `showModal()`, and closing waits for `transitionend`
 *   before calling `close()`. `@starting-style` would remove the first half
 *   of that, but it is too new to rely on in copied code.
 *
 * The slide is gated behind `motion-safe:` — a full-height panel flying in
 * from the edge is exactly the movement `prefers-reduced-motion` is for, and
 * under `reduce` it simply appears.
 *
 * The footer is `sticky` inside a scrolling body, so Save never scrolls out
 * of reach on a long form — the single most common complaint about sheets.
 */

import * as React from 'react'
import { X } from 'lucide-react'

export interface SlideOverPanelProps {
  triggerLabel?: string
  title?: string
  description?: string
  saveLabel?: string
  cancelLabel?: string
  /** Panel content. Defaults to a small example form. */
  children?: React.ReactNode
  onSave?: () => void | Promise<void>
  className?: string
}

export function SlideOverPanel({
  triggerLabel = 'Edit customer',
  title = 'Edit customer',
  description = 'Changes apply immediately and are visible to everyone on the team.',
  saveLabel = 'Save changes',
  cancelLabel = 'Cancel',
  children,
  onSave,
  className = '',
}: SlideOverPanelProps) {
  // Per-instance ids. A literal id in a reusable component is a
  // collision waiting for the second copy on the page — and a <label>
  // then resolves to whichever input rendered first.
  const uid = React.useId()
  const dialogRef = React.useRef<HTMLDialogElement>(null)
  const panelRef = React.useRef<HTMLDivElement>(null)
  const [shown, setShown] = React.useState(false)

  function open() {
    dialogRef.current?.showModal()
    // One frame later, so the transition has a start value to move from.
    requestAnimationFrame(() => setShown(true))
  }

  const close = React.useCallback(() => {
    const panel = panelRef.current
    setShown(false)

    // If motion is reduced there is no transition to wait for, and
    // `transitionend` would never fire — close immediately instead of
    // leaving an invisible modal trapping focus.
    const reduced =
      typeof window !== 'undefined' &&
      window.matchMedia('(prefers-reduced-motion: reduce)').matches

    if (!panel || reduced) {
      dialogRef.current?.close()
      return
    }

    panel.addEventListener('transitionend', () => dialogRef.current?.close(), { once: true })
  }, [])

  async function save() {
    await (onSave?.() ?? Promise.resolve())
    close()
  }

  return (
    <div className={`flex justify-center p-10 ${className}`}>
      <button
        type="button"
        onClick={open}
        className="inline-flex h-11 items-center rounded-xl border border-border/60 bg-card/60 px-5 text-sm font-semibold transition-colors hover:bg-card focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
      >
        {triggerLabel}
      </button>

      <dialog
        ref={dialogRef}
        aria-labelledby={`${uid}-slideover-title`}
        aria-describedby={`${uid}-slideover-description`}
        onCancel={(e) => {
          // Take over Escape so it runs the same exit transition as the
          // buttons rather than snapping shut.
          e.preventDefault()
          close()
        }}
        onClick={(e) => {
          if (e.target === dialogRef.current) close()
        }}
        // The dialog itself is the full-screen surface; the panel inside is
        // what slides. `ms-auto` pins it to the end edge,
        // which is the right in English and the left in Arabic.
        className="m-0 h-full max-h-full w-full max-w-full bg-transparent p-0 text-foreground backdrop:bg-black/50 backdrop:backdrop-blur-sm"
      >
        <div
          ref={panelRef}
          data-shown={shown ? '' : undefined}
          className="ms-auto flex h-full w-full max-w-md flex-col border-s border-border/60 bg-background shadow-2xl motion-safe:translate-x-full motion-safe:rtl:-translate-x-full motion-safe:transition-transform motion-safe:duration-300 motion-safe:ease-out motion-safe:data-shown:translate-x-0"
        >
          <div className="flex shrink-0 items-start justify-between gap-4 border-b border-border/60 p-5">
            <div className="min-w-0">
              <h2 id={`${uid}-slideover-title`} className="text-base font-semibold">
                {title}
              </h2>
              <p id={`${uid}-slideover-description`} className="mt-1 text-sm text-muted-foreground">
                {description}
              </p>
            </div>
            <button
              type="button"
              onClick={close}
              aria-label="Close panel"
              className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
            >
              <X aria-hidden className="h-5 w-5" />
            </button>
          </div>

          <div className="flex-1 overflow-y-auto p-5">{children ?? <ExampleFields />}</div>

          {/* Sticky, so Save is reachable without scrolling a long form. */}
          <div className="sticky bottom-0 flex shrink-0 justify-end gap-2 border-t border-border/60 bg-background/95 p-5 backdrop-blur">
            <button
              type="button"
              onClick={close}
              className="inline-flex h-10 items-center rounded-lg border border-border/60 px-4 text-sm font-semibold transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
            >
              {cancelLabel}
            </button>
            <button
              type="button"
              onClick={save}
              className="inline-flex h-10 items-center rounded-lg bg-primary px-4 text-sm font-semibold text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
            >
              {saveLabel}
            </button>
          </div>
        </div>
      </dialog>
    </div>
  )
}

/** Placeholder body — replace with your own form. */
function ExampleFields() {
  // Per-instance ids. A literal id in a reusable component is a
  // collision waiting for the second copy on the page — and a <label>
  // then resolves to whichever input rendered first.
  const uid = React.useId()
  return (
    <div className="space-y-4">
      {[
        { id: 'so-name', label: 'Name', value: 'Ada Lovelace', type: 'text' },
        { id: 'so-email', label: 'Email', value: 'ada@acme.com', type: 'email' },
        { id: 'so-company', label: 'Company', value: 'Acme Inc', type: 'text' },
      ].map((field) => (
        <div key={field.id}>
          <label htmlFor={`${uid}-${field.id}`} className="block text-sm font-medium">
            {field.label}
          </label>
          <input
            id={`${uid}-${field.id}`}
            type={field.type}
            defaultValue={field.value}
            className="mt-1.5 h-11 w-full rounded-xl border border-border/60 bg-card/60 px-3 text-sm focus:border-primary/50 focus:outline-none focus:ring-2 focus:ring-ring/30"
          />
        </div>
      ))}

      <div>
        <label htmlFor={`${uid}-so-notes`} className="block text-sm font-medium">
          Notes
        </label>
        <textarea
          id={`${uid}-so-notes`}
          rows={5}
          className="mt-1.5 w-full resize-y rounded-xl border border-border/60 bg-card/60 px-3 py-2.5 text-sm focus:border-primary/50 focus:outline-none focus:ring-2 focus:ring-ring/30"
        />
      </div>
    </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/slide-over-panel.tsx and import it where you need the section:

import { SlideOverPanel } from '@/components/slide-over-panel'

Customize

5 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
triggerLabelstring'Edit customer'
titlestring'Edit customer'
descriptionstring'Changes apply immediately and are visible to…
saveLabelstring'Save changes'
cancelLabelstring'Cancel'
childrenPanel content. Defaults to a small example form.React.ReactNode—
onSave() => void | Promise<void>—
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.

slide-over-panel.html
<!--
  Slide-Over Edit Panel — 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 justify-center p-10 ">
  <button type="button" class="inline-flex h-11 items-center rounded-xl border border-border/60 bg-card/60 px-5 text-sm font-semibold transition-colors hover:bg-card focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">Edit customer</button>
  <dialog aria-labelledby="_R_0_-slideover-title" aria-describedby="_R_0_-slideover-description" class="m-0 h-full max-h-full w-full max-w-full bg-transparent p-0 text-foreground backdrop:bg-black/50 backdrop:backdrop-blur-sm">
    <div class="ms-auto flex h-full w-full max-w-md flex-col border-s border-border/60 bg-background shadow-2xl motion-safe:translate-x-full motion-safe:rtl:-translate-x-full motion-safe:transition-transform motion-safe:duration-300 motion-safe:ease-out motion-safe:data-shown:translate-x-0">
      <div class="flex shrink-0 items-start justify-between gap-4 border-b border-border/60 p-5">
        <div class="min-w-0">
          <h2 id="_R_0_-slideover-title" class="text-base font-semibold">Edit customer</h2>
          <p id="_R_0_-slideover-description" class="mt-1 text-sm text-muted-foreground">Changes apply immediately and are visible to everyone on the team.</p>
        </div>
        <button type="button" aria-label="Close panel" class="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
          <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-x h-5 w-5" aria-hidden="true">
            <path d="M18 6 6 18"></path>
            <path d="m6 6 12 12"></path>
          </svg>
        </button>
      </div>
      <div class="flex-1 overflow-y-auto p-5">
        <div class="space-y-4">
          <div>
            <label for="_R_l_-so-name" class="block text-sm font-medium">Name</label>
            <input id="_R_l_-so-name" type="text" class="mt-1.5 h-11 w-full rounded-xl border border-border/60 bg-card/60 px-3 text-sm focus:border-primary/50 focus:outline-none focus:ring-2 focus:ring-ring/30" value="Ada Lovelace" />
          </div>
          <div>
            <label for="_R_l_-so-email" class="block text-sm font-medium">Email</label>
            <input id="_R_l_-so-email" type="email" class="mt-1.5 h-11 w-full rounded-xl border border-border/60 bg-card/60 px-3 text-sm focus:border-primary/50 focus:outline-none focus:ring-2 focus:ring-ring/30" value="ada@acme.com" />
          </div>
          <div>
            <label for="_R_l_-so-company" class="block text-sm font-medium">Company</label>
            <input id="_R_l_-so-company" type="text" class="mt-1.5 h-11 w-full rounded-xl border border-border/60 bg-card/60 px-3 text-sm focus:border-primary/50 focus:outline-none focus:ring-2 focus:ring-ring/30" value="Acme Inc" />
          </div>
          <div>
            <label for="_R_l_-so-notes" class="block text-sm font-medium">Notes</label>
            <textarea id="_R_l_-so-notes" rows="5" class="mt-1.5 w-full resize-y rounded-xl border border-border/60 bg-card/60 px-3 py-2.5 text-sm focus:border-primary/50 focus:outline-none focus:ring-2 focus:ring-ring/30"></textarea>
          </div>
        </div>
      </div>
      <div class="sticky bottom-0 flex shrink-0 justify-end gap-2 border-t border-border/60 bg-background/95 p-5 backdrop-blur">
        <button type="button" class="inline-flex h-10 items-center rounded-lg border border-border/60 px-4 text-sm font-semibold transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">Cancel</button>
        <button type="button" class="inline-flex h-10 items-center rounded-lg bg-primary px-4 text-sm font-semibold text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">Save changes</button>
      </div>
    </div>
  </dialog>
</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

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

7 more blocks in Modals & Drawers

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 Modals & Drawers

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 Modals & Drawers blocks

View category
Open the full page for this block

Destructive Confirm Dialog

A type-to-confirm dialog built on native <dialog>, so the focus trap, top layer and escape handling come from the browser. Focus lands on Cancel, and the button says the verb.

Modals & Drawers184 lines1 dep
Open the full page for this block

Cookie Consent Banner

Per-category consent where refusing is exactly as easy as accepting, nothing non-essential is pre-ticked, and the page behind it stays readable — the shape the law expects, wired to your own script gating.

Modals & Drawers232 lines1 dep
Open the full page for this block

Faceted Filter Drawer

Facets with per-option counts, zero-result options disabled rather than hidden so the list never jumps, and a pending selection applied on a button that says how many choices changed.

Modals & Drawers241 lines1 dep
Open the full page for this block

Share & Access Dialog

The share modal where a design mistake is a data leak: general access stated as its consequence rather than its setting, and a copy button that never silently widens access.

Modals & Drawers312 lines1 dep
Open the full page for this block

Mobile Bottom Sheet

Half and full snap points where the content owns the scroll and overscroll-contain keeps the page behind still. The drag handle is a real button, Escape and the backdrop close it, and safe-area padding keeps the last row pressable.

Modals & Drawers266 lines1 dep
Open the full page for this block

Unsaved Changes Prompt

The interception that keeps work: three answers rather than two, the changed fields listed by name, a destructive-styled discard, and Escape resolving to cancel.

Modals & Drawers237 lines1 dep
Open the full page for this block

Record Inspector Drawer

A non-modal drawer that keeps the list on screen, with previous and next controls for moving between records and an activity tab beside the fields.

Modals & Drawers336 lines1 dep