Skip to content

Slide-Over Panel

Tailwind CSS slide-over drawer from the right with header, scrollable form content, sticky footer actions, focus trap and Escape to close.

Also known as: side drawer, slide over panel, off canvas panel, right side drawer, sliding sidebar form

Tailwind CSS Drawers Responsive #dialog #drawer #form #panel #slide-over

Slide-Over Panel live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

A right-side slide-over panel (drawer) built with Tailwind CSS and vanilla JavaScript, shown as an "Edit project" form with a colored header, a scrollable body and sticky footer actions. Use it for editing records, filters, settings or details views where a full page change or a centered modal would feel too heavy.

How it works

The root is .tso-drawer. It contains the page content with the data-tso-open trigger and the .tso-overlay, which starts with the hidden attribute. Inside the overlay are the dimmed .tso-backdrop and the #tso-panel element (.tso-panel), a full-height flex column with role="dialog": a bg-teal-700 header, a form whose middle area scrolls with overflow-y-auto, and a footer with Cancel and Save buttons that always stays visible.

On DOMContentLoaded the script initializes every .tso-drawer. Opening removes hidden, locks page scrolling, stores the focused element and moves focus to the field marked data-tso-autofocus. style.css plays the tso-slide and tso-fade keyframes on open; closing adds .tso-closing, which plays them in reverse before the overlay is hidden again. Escape, a backdrop click and every data-tso-close element close the panel, and a keydown listener keeps Tab inside it.

Submitting checks that the project name is not empty, shows "Saving…" on the data-tso-save button, waits 900 ms, writes the new name into data-tso-name-output and announces the result in data-tso-status. Closing without saving resets the form to the last saved values.

Customization

  • max-w-md on .tso-panel: use max-w-lg or max-w-2xl for wider forms or detail views.
  • right-0 and pl-8 sm:pl-16 on the panel wrapper: switch to left-0 with pr-8 sm:pr-16, and use translateX(-100%) in the tso-slide keyframes, for a left drawer.
  • bg-teal-700 on the header and Save button: change teal to your brand color; the header subtitle uses text-teal-100.
  • bg-slate-950/50 on .tso-backdrop: lighten or darken the dimming, or add backdrop-blur-sm.
  • The 900 ms window.setTimeout in the submit handler of script.js: replace it with a fetch() call to your API and close the panel when it succeeds.
  • animation: tso-slide 0.4s in style.css: tune the slide duration or easing.

Use cases

  • Record editing: an Edit project form opens from the right with sticky footer actions
  • Filters: keep search results visible while a panel holds filter options
  • Settings: scroll long content in the body while the header stays in place
  • Details views: focus trap and Escape to close make it lighter than a centered modal

Accessibility

The panel uses role="dialog", aria-modal="true", aria-labelledby="tso-title" and aria-describedby="tso-desc". The trigger has aria-haspopup="dialog", aria-controls and an aria-expanded state kept in sync by the script. Focus is trapped while the panel is open and returned to the trigger on close. The name field gets aria-invalid and an aria-describedby error message when left empty, the radio options are grouped in a fieldset with a legend, and the save result is read through a role="status" region. All controls have visible focus outlines, and the slide and fade animations are removed under prefers-reduced-motion.

Usage notes

For several drawers on one page, wrap each in its own .tso-drawer and give the panel, title and form fields unique id values.

Slide-Over Panel at a glance

Framework
Tailwind CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Tailwind CSS
Layout
Responsive, works on mobile
Category
Drawers
License
Free for personal and commercial use

Questions about this template

Can I use the Slide-Over Panel code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Tailwind CSS from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>

The Tailwind browser build is for prototyping. In production, compile Tailwind with its CLI or your bundler.

Slide-Over Panel – free Tailwind CSS drawer template
Slide-Over Panel · free Tailwind CSS drawer template

More Drawers

Settings Drawer with Tabs – free Bootstrap 6 drawer template

Settings Drawer with Tabs

Dark Bootstrap 6 Drawer with tabbed settings panels (General, Alerts, Privacy), switches, a Range slider, select menus and a save bar that tracks unsaved changes.

Bottom Drawer Action Sheet – free Bootstrap 6 drawer template

Bottom Drawer Action Sheet

Bootstrap 6 bottom Drawer styled as a mobile action sheet with a share row, edit actions in a list group, pin toggle, delete action and confirmation toasts.

Filter Drawer for Product Lists – free Bootstrap 6 drawer template

Filter Drawer for Product Lists

Bootstrap 6 Drawer from the left with category checks, a Range price slider, feature toggles, rating, in-stock switch, live result count and apply/reset buttons.

Drawer Shopping Cart – free Bootstrap 6 drawer template

Drawer Shopping Cart

Bootstrap 6 Drawer shopping cart that slides in from the right with product rows, quantity steppers, a free-shipping progress bar, subtotal and checkout.

Notification Drawer Panel – free Bootstrap 5 drawer template

Notification Drawer Panel

Bootstrap 5 offcanvas notification drawer with notifications grouped by day, unread filter, mark all as read and dismiss buttons.

Offcanvas Shopping Cart – free Bootstrap 5 drawer template

Offcanvas Shopping Cart

Bootstrap 5 offcanvas cart drawer with quantity steppers, remove buttons, free-shipping progress, live totals and an empty state.