Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Theme Toggle Footer Block for React

A slim footer for a design-token editor with a theme button that cycles light, dark and system and really changes the page's theme.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A slim footer with a working theme control for React with Base UI. The wordmark and a line sit at the start and three short groups of links (a nav labelled Footer) at the end. A legal row under them carries the copyright and the policies at the start and, at the end, the name of the theme in use beside the catalog's Theme Toggle Button, which cycles Light, Dark and System. It really switches the page: the dark class goes on or off the html element, System follows the device and keeps following it while it is chosen, and the footer starts from whatever theme the page is already showing. A polite live line says "Theme: Dark" once per change. The rails and top rule come from the Guides spine, the legal row's rule is drawn by Guides, and nothing is drawn under it because a footer ends the page.

FAQ

How do I wire it to my theme provider?

The block applies the theme itself with one small function, apply, which toggles the dark class on html. If your app uses next-themes, delete apply and the two effects, read theme from useTheme() for the button's theme prop and call setTheme(next) from change. The button itself never changes the page: it only reports the next theme, which is why this block owns that step.

What does System do?

It follows the device's colour scheme: the block asks the browser for prefers-color-scheme: dark and keeps listening while System is chosen, so a device that switches at sunset changes the page too. Choosing Light or Dark stops listening.

Is the choice remembered?

No. This block keeps it in state, so a reload shows the page's own theme again. To remember it, store the chosen value (a cookie your server reads, or localStorage read before the first paint) where you call apply; next-themes does this for you.

How is it named and announced?

The button's name says what a press does ("Switch to dark theme"), the visible label beside it shows the theme in use, and a live line that is empty from the start says "Theme: System" once per change. The icon turns from sun to moon to monitor with a CSS transition, and only fades under reduced motion.

Why is the button an outline button?

The page's one primary colour belongs to its main action, and a footer control isn't that. The button is an outline icon button in the theme's border colour, with the theme's focus ring.

How does it fit on a phone?

The brand stacks over the three groups, which stay in a row of three, and the legal row stacks with the theme control last. Nothing scrolls sideways at 320 pixels.

  • Pro

    A footer for a meeting-notes tool whose segmented control (EN, FR, DE, ES) rewrites the footer's own words, with three link groups and a legal row.

  • Pro

    Social Icons Footer

    Slim and minimal

    A two-row footer: a wordmark and tagline beside five social icon buttons with tooltips, and a ruled band with the copyright and the policy links.

  • Pro

    The classic link-column footer for an email API: a brand column with the wordmark, one sentence and four social links, four groups of links behind a split divider, and a legal band with the copyright and the policy links.

  • Pro

    One Row Footer

    Slim and minimal

    The smallest footer: one row on the spine with a wordmark and a copyright line at the start and four inline links with a drawn underline at the end.

  • Pro

    A corner-radius picker card for a design-token editor: four chips drawn with their own corners, a greyscale preview that re-rounds as you choose, and Apply and Reset actions.

  • Pro

    Theme Toggle Navbar

    Surface and theme

    A navbar whose theme button opens the new theme as a circle growing from the button you pressed (View Transitions, guarded), with a menu to pick Light, Dark or System by name.