Sidebar
React.js
easy
30 mins
Create a React sidebar component that can be toggled open or closed with a menu button. The sidebar appears on the right side of the screen and includes navigation items with hover effects.
Requirements
-
The interface must include:
- A sidebar positioned on the right side of the viewport.
- A toggle button (with a menu icon) that is always visible and vertically centered on the right edge of the screen.
- Use
"Menu"icon formlucide-react
-
Default Behavior:
- The sidebar is hidden by default.
- The toggle button remains fixed and accessible at all times.
-
Toggle Functionality:
- Clicking the toggle button opens or closes the sidebar.
- The sidebar should slide in and out from the right with a smooth transition effect.
-
Sidebar Content:
- When open, the sidebar displays a vertical list of navigation items:
- Home
- About
- Services
- Contact
- Each navigation item should have a clear and smooth hover effect for better user interaction.
- When open, the sidebar displays a vertical list of navigation items:
Data Test IDs (required for testing):
data-testid="sidebar"— sidebar container divdata-testid="btn-toggle"— toggle button elementdata-testid="icon-menu"— menu icon inside toggle buttondata-testid="nav-menu"— container for nav items when sidebar is opendata-testid="nav-item-home"— nav item Homedata-testid="nav-item-about"— nav item Aboutdata-testid="nav-item-services"— nav item Servicesdata-testid="nav-item-contact"— nav item Contact
Reference UI

Preview what you need to build
Companies:
tcs
amazon
wipro
adobe
Solve Similar questions 🔥
Want to upskill? Explore our courses!
Namaste DSA
Master DSA from scratch with numerous problems, and expert guidance.
Namaste React
Wanna dive deep into React and become Frontend Expert? Learn with me now!
Namaste Frontend System Design
The most comprehensive and detailed course for frontend system design.
Namaste Node.js
Wanna dive deep into Node.js? Enroll into `Namaste Node.js` now!
