ToolypetMCP
intermediate3 minutescss

Sidebar Navigation Layout

Build a responsive sidebar layout with CSS Grid, smooth width transition, and proper spacing.

sidebarlayoutgridresponsive

इस रेसिपी का उपयोग कब करें

Dashboard applications, admin panels, and documentation sites commonly use sidebar navigation. This creates a clean, responsive sidebar that can be toggled on mobile.

चरण

1

Create the sidebar + main layout

प्रॉम्प्ट:Generate a CSS grid with 2 columns: 260px sidebar and 1fr main content, no gap
2

Add subtle sidebar edge shadow

प्रॉम्प्ट:Generate a right-edge shadow for sidebar: 2px 0 8px rgba(0,0,0,0.06)
3

Smooth sidebar toggle animation

प्रॉम्प्ट:Generate a smooth cubic-bezier for 300ms width transition on sidebar collapse

अक्सर पूछे जाने वाले प्रश्न

How do I make the sidebar collapsible?

Toggle the grid-template-columns between '260px 1fr' and '60px 1fr' (icon-only mode). The transition will animate smoothly.

How do I handle the sidebar on mobile?

Use a CSS media query to change to a single column layout, and show the sidebar as an overlay with position: fixed.

संबंधित रेसिपी