Header
A customizable header component for any website
The Header
component is a customizable header that can include a logo, app name (both pulled from config.js), navigation links, and a call-to-action button.
It is designed to be responsive and can adapt to different screen sizes automatically (dropdown menu on mobile).
Usage
The component automatically pulls the logo and app name from config.js if they are defined, so you can simply import the component and use it like this:
javascript
1import Header from '@/components/organisms/Header'; 2 3<Header 4 navLinks={[ 5 { title: 'Home', href: '/' }, 6 { title: 'About', href: '/about' }, 7 { title: 'Contact', href: '/contact' }, 8 ]} 9 ctaButton={{ 10 label: 'Get Started', 11 href: '/get-started', 12 }} 13/>
Since Header
uses TextLink
and Button
components, you can pass any prop that they accept to customize the header, for example:
javascript
1// For nav links 2{ 3 title: 'Home', 4 href: '/', 5 props: { underline: true, fade: true }, 6} 7 8// For CTA button 9{ 10 label: 'Get Started', 11 href: '/get-started', 12 props: { size: 'lg', color: 'primary' }, 13}
Props
Name | Type | Default | Description |
---|---|---|---|
showLogo | boolean | true | If true, the logo will be displayed. |
showAppName | boolean | true | If true, the app name will be displayed. |
navLinks | array | [] | Array of navigation links. Each link is an object with name , href , and optional props . |
ctaButton | object | null | Call-to-action button. An object with label , href , and optional props . |
background | string | "bg-bg-100 dark:bg-bg-800" | Background color (use tailwind.config). |
bottomBorder | boolean | false | If true, a bottom border will be displayed. |
sticky | boolean | false | If true, the header will be sticky. |
account | boolean | false | If true, the account button will be displayed. |
className | string | "" | Additional Tailwind utility classes. |
...props | object | - | Any other valid HTML attributes for the <header> element. |
The sticky
prop is disabled by default, so the header will scroll with the page. To make it sticky, set the sticky
prop to true
.
The account
prop can only be used under /app/(auth)
pages since it uses the UserProvider
.
It uses the AccountCard
component.
Examples
Default Header
Header Hiding App Name
Header with Custom Nav Links and CTA Button
Header with Custom Background Color
The background
prop accepts any valid Tailwind utility classes.