Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Ink Theme Switch, animated React component

  • Pro
  • Inputs & Controls
  • Spring

A dark-mode toggle where the dark version of a settings panel pours out of the switch as a growing ink circle and drains back in when you switch off. The sun pulls in its rays and turns into a crescent moon, and only the component's own panel is themed.

Clicks on when it goes dark and off when it goes back to light. Sound is off on this site until you switch it on.

Props

PropTypeDefaultWhat it does
defaultDarkfalseStart with the panel dark. Only the component's own panel is themed; the page theme is never touched.
onChange—Called with the new value when the user flips the switch.
autoplayfalseFlips between light and dark every 2.2s until someone touches it.
className—Extra classes for the panel.
enableSoundtruePlays interface sounds on interaction. They follow the sound switch (setSoundsEnabled, on by default) and stay silent on hover. Autoplay makes the same sounds once the visitor has used the page. Pass false to silence this component.

Add it to your project

  1. 1

    Set up your project once

    You need a Next.js project with Tailwind CSS and the @/ import alias. In its root folder, run this once. It creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry with your API key

    Ink Theme Switch is a Pro item, so the CLI has to send your API key. Do this once per project:

    1. Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with nxs_ and is shown only once.
    2. In your project root, next to package.json, create a file named .env.local with this line, using your own key:
      NEXUS_API_KEY=nxs_your_key_here
    3. Open components.json and add this entry inside the outermost braces, next to "aliases". Leave {name} and ${NEXUS_API_KEY} exactly as written; the CLI fills them in:
      "registries": {
        "@nexus-labs": {
          "url": "https://www.nexus-ui.com/api/registry/{name}",
          "headers": {
            "Authorization": "Bearer ${NEXUS_API_KEY}"
          }
        }
      }

How Ink Theme Switch works

Theme switch that floods. Toggle dark mode and the dark version of the UI pours out of the switch as an ink circle, easing in and out, until it pulls in its rays and becomes a moon on the way. It themes only its own panel and never changes the site theme or the document's classes.

The source, the install command and the build prompt come with Pro.

Ink Theme Switch questions

How do I install Ink Theme Switch?

Run `npx shadcn@latest add @nexus-labs/ink-theme-switch`. It adds the component and installs framer-motion. It is a Pro component, so it needs a Pro plan and an API key; key setup is on the CLI docs page (/docs/cli).

Does it change my site's theme?

No. It themes only its own panel and never touches the page or the document's classes. Use `onChange`, which receives a boolean `dark`, to apply the choice to your own theme. `defaultDark` (default false) starts the panel dark.

Can I put my own UI inside the panel?

Not through props. There is no `children`; the panel is a fixed 320 by 300 px sample settings screen drawn by the internal `Panel` component, so replace that to show your own light and dark layouts. `className` adds classes to the panel.

How is the ink effect made?

A dark copy of the panel sits on top, revealed by a CSS `clip-path` circle centered on the switch. Framer Motion animates its radius, about 0.9s out and 0.7s back. The sun-to-moon change is an SVG mask plus rays that scale away.

Is the switch accessible?

The toggle is a native button with `role="switch"`, `aria-checked` and the label "Dark mode", so it works with Enter and Space. Only the visible copy of the panel is exposed to screen readers; the other is `aria-hidden`.

Does it make sound, and how do I turn it off?

Clicks on when it goes dark and off when it goes back to light. Sounds are synthesised with the Web Audio API, so there are no audio files, and they only play after a click or key press. Pass `enableSound={false}` to silence this component, or call `setSoundsEnabled(false)` from `@/lib/ui-sounds` to switch every sound off at once. The CLI installs `@/lib/ui-sounds` with the component.

Guides