BigBlocks

Theme Token Provider

On-chain theme picker using @theme-token/sdk with provider context and settings panel for blockchain-inscribed ThemeTokens

Installation

bunx shadcn@latest add https://registry.bigblocks.dev/r/theme-token-provider.json

Usage

Wrap your app with ThemeTokenProvider to enable on-chain theme fetching. Use ThemeTokenSettings to render the settings panel, and useThemeTokenContext to access theme state from any child component.

import {
  ThemeTokenProvider,
  ThemeTokenSettings,
} from "@/components/blocks/theme-token-provider"
 
export function App() {
  return (
    <ThemeTokenProvider
      onThemeApplied={(origin) => console.log("Applied:", origin)}
      onThemeCleared={() => console.log("Cleared")}
    >
      <ThemeTokenSettings />
      <main>{/* Your app content */}</main>
    </ThemeTokenProvider>
  )
}

Props

ThemeTokenProvider

PropTypeDefaultDescription
defaultOriginstring--Default ThemeToken origin to apply on mount
storageKeystring--localStorage key for persisting the selected theme origin
onThemeApplied(origin: string) => void--Called after a theme is applied
onThemeCleared() => void--Called when the theme is cleared
onError(error: Error) => void--Called on error
childrenReactNode--Child elements to wrap
classNamestring--Additional CSS classes on the wrapper

ThemeTokenSettings

PropTypeDefaultDescription
onApply(origin: string) => void--Called after a theme is applied
onClear() => void--Called when the theme is cleared
classNamestring--Additional CSS classes

useThemeTokenContext

Access the theme state from any child of ThemeTokenProvider:

const { origin, theme, status, error, setOrigin, clearOrigin } =
  useThemeTokenContext()