Skip to content

Sidebar with User Profile Photo and Sections

Tailwind CSS app sidebar with a profile photo header, collapsible link groups, badges, a logout confirmation and an off-canvas drawer on mobile.

Also known as: admin sidebar with avatar, dashboard sidebar navigation, collapsible sidebar menu, off-canvas mobile sidebar, sidebar with user profile

Sidebar with User Profile Photo and Sections live demo

Open in new tab

Tailwind CSS code (HTML, CSS, JS)

An application sidebar built with Tailwind CSS that opens with a user profile header: a gradient cover strip, a round profile photo with an online dot, the name, the role and an "Edit profile" link. Below it, navigation links are grouped into collapsible sections, and the footer holds a help link and a logout button with an inline confirmation. It fits dashboards, SaaS admin areas and internal tools.

How it works

The root is div.tsp-app with a data-open attribute. It contains the aside#tsp-sidebar (.tsp-sidebar), a .tsp-backdrop for phones and the page area with a header and sample dashboard cards. The nav holds three .tsp-group blocks (Workspace, Team, Account). Each group heading is a button with aria-expanded and aria-controls that points to its ul; the chevron rotates through the group-aria-[expanded=false]/head:-rotate-90 variant. Links use aria-current="page" for the active item, which aria-[current=page]:bg-violet-50 turns into a violet highlight.

From the lg breakpoint the sidebar is a static column. Below it, style.css turns .tsp-sidebar into an off-canvas drawer that slides in when data-open="true". The script initializes each .tsp-app on DOMContentLoaded: .tsp-open opens the drawer and focuses the current link; any [data-tsp-close] element, the Escape key or choosing a link closes it and returns focus. Clicking a .tsp-link moves aria-current and copies its .tsp-label text into .tsp-title. The .tsp-logout button reveals the .tsp-confirm box with Cancel and Sign out buttons.

Customization

  • The img in the profile header: replace the photo, alt text, name and role with the signed-in user's data.
  • bg-linear-to-br from-violet-600 via-fuchsia-500 to-amber-300 on the cover strip: pick your own gradient or a solid bg-zinc-900.
  • aria-[current=page]:bg-violet-50 aria-[current=page]:text-violet-700 on .tsp-link: change the active link colors.
  • w-72 on .tsp-sidebar: use w-64 for a narrower column; the drawer width follows.
  • aria-expanded="false" on a group button plus hidden on its ul: start that section collapsed.
  • (max-width: 63.98rem) in style.css and DESKTOP in script.js: switch both to 48rem to show the static sidebar from the md breakpoint.
  • The .tsp-logout-confirm click handler in script.js: call your sign-out endpoint or redirect to your logout URL.

Use cases

  • SaaS dashboards: a profile header with photo, role and Edit profile link tops the sidebar
  • Admin areas: link groups such as Workspace, Team and Account collapse to keep long menus tidy
  • Internal tools: badges show unread counts next to menu items
  • Mobile web apps: the sidebar becomes a slide-in drawer that closes with Escape or a backdrop click
  • Account menus: the footer logout button asks for confirmation inline before signing out

Accessibility

The sidebar is an aside with aria-label="Sidebar" and a nav labelled "Main". Section buttons expose aria-expanded and aria-controls, the active link has aria-current="page", and badges include visually hidden text such as "3 unread". The online dot is decorative with a visually hidden "(online)" text. On phones the menu button reports aria-expanded, Tab is kept inside the open drawer, Escape closes it and focus returns to the menu button. The logout button exposes aria-expanded for its confirmation, and a role="status" region announces page changes and the demo sign out. All controls show visible focus rings, and the slide animation is disabled under prefers-reduced-motion.

Usage notes

The profile photo comes from Unsplash; replace it with your user's avatar. Real links should use real href values; the script only prevents navigation for href="#".

Sidebar with User Profile Photo and Sections at a glance

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

Questions about this template

Can I use the Sidebar with User Profile Photo and Sections 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.

Sidebar with User Profile Photo and Sections – free Tailwind CSS sidebar template
Sidebar with User Profile Photo and Sections · free Tailwind CSS sidebar template

More Sidebars

Icon Sidebar that Expands on Hover – free Pure CSS sidebar template

Icon Sidebar that Expands on Hover

Pure CSS icon rail that widens to reveal labels, section headings and a profile on hover or keyboard focus, with an active link and badge.

Sidebar with Nested Collapsible Menu – free Bootstrap 5 sidebar template

Sidebar with Nested Collapsible Menu

Dark Bootstrap 5 sidebar with three-level collapsible menu groups, accordion behavior, active link highlight and an off-canvas panel on mobile.

Collapsible Dashboard Sidebar – free Tailwind CSS sidebar template

Collapsible Dashboard Sidebar

Dark Tailwind CSS dashboard sidebar with icons, grouped sections, an unread badge and a button that collapses it to an icon rail with tooltips.