shadcn-solid
DocsComponentsCharts


Get Started
  • Introduction
  • Installation
  • Theming
  • Dark Mode
Form
  • Tanstack Form
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Badge
  • Breadcrumbs
  • Button Group
  • Button
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Data Table
  • Date Picker
  • Dialog
  • Drawer
  • Dropdown Menu
  • File Field
  • Hover Card
  • Kbd
  • Menubar
  • Navigation Menu
  • Number Field
  • OTP Field
  • Pagination
  • Popover
  • Progress
  • Radio Group
  • Resizable
  • Search
  • Segmented Control
  • Select
  • Separator
  • Sidebar
  • Skeleton
  • Slider
  • Sonner
  • Switch
  • Table
  • Tabs
  • Text Field
  • Toggle Group
  • Toggle Button
  • Tooltip

Dark Mode

Adding dark mode to your site.

Wrap your root layout

Add the ColorModeProvider and ColorModeScript to your app.

src/app.tsx
import { Suspense } from "solid-js"
import { isServer } from "solid-js/web"
import {
  ColorModeProvider,
  ColorModeScript,
  cookieStorageManagerSSR,
} from "@kobalte/core"
import { MetaProvider } from "@solidjs/meta"
import { Router } from "@solidjs/router"
import { FileRoutes } from "@solidjs/start"
import { getCookie } from "vinxi/http"
 
const getServerCookies = () => {
  "use server"
  const colorMode = getCookie("kb-color-mode")
  return colorMode ? `kb-color-mode=${colorMode}` : ""
}
 
export default function App() {
  const storageManager = cookieStorageManagerSSR(
    isServer ? getServerCookies() : document.cookie,
  )
 
  return (
    <Router
      root={(props) => (
        <MetaProvider>
          <Suspense>
            <ColorModeScript storageType={storageManager.type} />
            <ColorModeProvider storageManager={storageManager}>
              {props.children}
            </ColorModeProvider>
          </Suspense>
        </MetaProvider>
      )}
    >
      <FileRoutes />
    </Router>
  )
}

Add a mode toggle

Place a mode toggle on your site to toggle between light and dark mode.

Component mode-toggle not found in registry.

ThemingTanstack Form
Built & designed by shadcn. Ported to Solid by hngngn. The source code is available on GitHub.