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.
Importing HeaderWithSearch
Section titled โImporting HeaderWithSearchโFirst, letโs add the component to our app/root.tsx
file.
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> )}
Check the browser
Section titled โCheck the browserโHead across to your browser and you should see the navigation bar at the top of the page. It should look something like this:
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.
๐ Congratulations! ๐
Section titled โ๐ Congratulations! ๐โYou now have a professional navigation bar and footer on your site! ๐
How can we start to customise it?
Summary
Section titled โSummaryโIn this tutorial we:
- Revised how to
import
components into ourroot.tsx
file. - Added a navigation bar to our site using the
<HeaderWithSearch />
component. - Added a footer to our site using the
<FooterMenuRight />
component.
Whatโs next?
Section titled โWhatโs next?โIn the next section, weโll look at how we can begin to customise the colours and content of our navigation bar and footer.