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 { type LinksFunction } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'
import Document from '~/components/shared-layout/Document'
import ThemeSwitch from '~/components/shared-layout/ThemeSwitch'
import { useNonce } from '~/utils/nonce-provider.ts'
import rootLinkElements from '~/utils/providers/rootLinkElements'
import { loader } from './__root.server'
import useTheme from './hooks/useTheme.tsx'
import HeaderWithSearch from './components/organisms/HeaderWithSearch'
10 collapsed lines
export const links: LinksFunction = () => {
return rootLinkElements
}
export { headers, meta } from './__root.client.tsx'
export { action, loader } from './__root.server.tsx'
export default function App() {
const data = useLoaderData<typeof loader>()
const nonce = useNonce()
const theme = useTheme()
return (
<Document nonce={nonce} theme={theme}>
<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.