Over the past few months, I've learned a bit about creating modern websites.
As I embark on a new venture to build a movie app similar to Netflix, I plan to blog about any major milestones in this project.
If you are someone experienced you can straight away have a look at the source code here
Let's start by creating the navbar. While making a navbar might seem simple, following certain steps can ensure consistency across all your applications.
Step 0 (Optional): Design Your Navbar
Working with a design in hand has always been my preferred method. You can use any design software of your choice; I use Excalidraw.
Step 1: Determine What You Need in Your Navigation Bar
Having a cluttered navbar is not ideal; try to keep it minimal. In my application, the navbar includes the following items: [Home, Movies, TV Shows, Anime, People, Trending]. Let's first create the data for the navbar.
Create a site config file:
src/config/site.ts
src/config/site.ts
Now, export these as an array of NavItem
Step 2: Create a Navbar Component
I will be using Shadcn's Navbar Component. If you want to use it too, run the following command in the terminal:
shell
ts pnpm ui:add navigation-menu
The navigation-menu structure follows this hierarchy:
Since we will be using links to redirect the user to different routes, we should create a new SiteNavItem component to function as a navigation link:
src/components/header/site-nav.tsx
useActiveNav is a custom hook that checks whether the current path matches the href param, helping to achieve the active item effect:
src/hooks/useActiveNav.ts
Now, if you check how it looks, it should resemble the intended design.
Step 3 Layout the design
Depending on how you designed your Header you can now start implementing that design
In my case I just added a Home icon ,search input,modeToggle around my navbar
src/components/header/site-header.tsx
Now create the hamburger menu
shell
src/components/header/site-menu.tsx
Now fit the menu in the header component
src/components/header/site-header.tsx
Looks Good!
Feel free to reach out to me on LinkedIn or Twitter if you have any questions or suggestions. I'm always open to feedback.
You can find all my links here Linkotree