Skip to content

Footer

Preview



Features

  • Responsive Design: It automatically rearranges elements according to the screen size (mobile, tablet, PC), ensuring good readability.

  • Optional Logo: If you don’t specify a logo, only the navigation links will be displayed and right-aligned.

  • Accessibility: Visual indicators are provided for hover and focus states on links, making keyboard navigation user-friendly.

  • Dark Mode Support: Background and text colors adapt automatically to system settings, leveraging design tokens for consistent styling.

  • Minimal Props: Only logo (optional) and navItems are required to quickly implement a fully-featured footer.

Tip

Even if the logo text is very long, styles are carefully applied to prevent layout breaking.

Properties

PropertyTypeDefault ValueDescription
logostringOptional
(If empty or undefined, no logo is shown)
The text displayed on the left side of the footer. If not specified, links are right-aligned.
navItems{label: string; href: string;}[][ { label: "Privacy Policy", href: "/privacy" } ]An array of link objects to display at the footer.

Github

Code Examples

Footer.tsx
import "@/styles/tailwind.css";
type NavItem = {
label: string;
href: string;
};
type FooterProps = {
logo?: string;
navItems?: NavItem[];
};
export default function Footer({
logo,
navItems = [
{ label: "About", href: "#" },
{ label: "Contact", href: "#" },
{ label: "Q&A", href: "#" },
],
}: FooterProps) {
return (
<footer className="relative w-full bg-white text-black dark:bg-black dark:text-white mt-8">
<div className="absolute top-0 left-0 w-full h-[2px] bg-gradient-to-r from-lime-500 via-teal-400 to-blue-500" />
<div
className={`flex flex-col md:flex-row items-center px-4 py-6 gap-4 text-center md:text-left md:px-8 ${
logo ? "md:justify-between" : "md:justify-end"
}`}
>
{logo && (
<h2 className="text-xl font-bold overflow-hidden text-ellipsis whitespace-nowrap">
{logo}
</h2>
)}
<nav className="flex flex-wrap items-center gap-4 md:gap-8 justify-center md:justify-end w-full md:w-auto">
{navItems.map(({ label, href }) => (
<a
key={href}
href={href}
className="block px-2 py-1 transition-opacity duration-200 hover:opacity-75 focus:opacity-75"
>
{label}
</a>
))}
</nav>
</div>
<div className="border-t border-dashed border-gray/30 dark:border-white/30 px-4 py-4 md:px-8 text-sm text-center">
© {new Date().getFullYear()} Your Company
</div>
</footer>
);
}

How to Use

Import the component into your page or layout. Override logo and navItems as needed. Adjust the import destination for each framework, and ideally keep the code in a separate file.

// import Footer from "@/components/Footer";
import Footer from "@/components/Footer";
export default function Layout({ children }) {
return (
<>
<main id="main">{children}</main>
<Footer
logo="MyWebsite"
navItems={[
{ label: "Privacy Policy", href: "/privacy" },
{ label: "Terms of Service", href: "/terms" },
{ label: "Contact", href: "/contact" },
]}
/>
</>
);
}

Additional Info