ns-ui

Toggle Theme ASCII

A light/dark toggle whose chip reads the real resolved --background/--foreground values at mount and on every theme change and paints itself in their negative, so it previews almost exactly what the page will look like the instant you click it.

Install

npx shadcn add https://design.helpmarq.com/r/toggle-theme-ascii.json
  • theme
  • toggle
  • dark-mode
  • ascii
  • mono
  • accessibility

ns-ui / toggle-theme-ascii

appearance

The chip is painted in the negative of the current theme's real token colors — it previews almost exactly what the page will look like the instant you click it.

Props

PropTypeDefaultDescription
dark?booleancontrolled dark state; omit for uncontrolled (reads/writes <html class="dark">)
defaultDark?boolean
onDarkChange?(dark: boolean) => void
syncDocument?booleanwhether clicking mutates document.documentElement's "dark" class + localStorage
storageKey?stringlocalStorage key used when syncDocument is true
className?string