Skip to content

Navbar and Footer

Now that we have light and dark mode, let’s add a navigation bar to our site. We’ll use the <HeaderWithSearch /> component that is included with the Epic Stack.

First, let’s add the component to our app/root.tsx file.

app/root.tsx
6 collapsed lines
import { useLoaderData } from 'react-router'
import { type Route } from './+types/root.ts'
import { type loader } from './__root.server.tsx'
import { GeneralErrorBoundary } from './components/error-boundary.tsx'
import Document from './components/shared-layout/Document.tsx'
import { ThemeSwitch, useTheme } from './routes/resources+/theme-switch.tsx'
import { useNonce } from './utils/nonce-provider.ts'
import rootLinkElements from './utils/providers/rootLinkElements.ts'
import HeaderWithSearch from './components/organisms/HeaderWithSearch'
10 collapsed lines
export const links: Route.LinksFunction = () => {
return rootLinkElements
}
export { meta } from './__root.client.tsx'
export { headers, loader } from './__root.server.tsx'
export default function App() {
const data = useLoaderData<typeof loader | null>()
const nonce = useNonce()
const theme = useTheme()
return (
<Document theme={theme} nonce={nonce} honeyProps={data?.honeyProps}>
<div className="flex h-screen flex-col justify-between">
<HeaderWithSearch />
9 collapsed lines
<div className="flex-1">
<main className="grid h-full place-items-center">
<h1 className="text-mega">Welcome to Epic News!</h1>
</main>
</div>
<div className="container flex justify-between pb-5">
<ThemeSwitch userPreference={data?.requestInfo.userPrefs.theme} />
</div>
</div>
</Document>
)
}

Head across to your browser and you should see the navigation bar at the top of the page. It should look something like this:

Navbar

You’ll notice that if you click the Log in button, nothing happens. This is because we haven’t implemented the login functionality yet. We’ll do that in a later section. For now, let’s add a footer to our site.

You now have a professional navigation bar and footer on your site! 😎

How can we start to customise it?

In this tutorial we:

  • Revised how to import components into our root.tsx file.
  • Added a navigation bar to our site using the <HeaderWithSearch /> component.
  • Added a footer to our site using the <FooterMenuRight /> component.

In the next section, we’ll look at how we can begin to customise the colours and content of our navigation bar and footer.