import type { JSX, ReactNode } from "react"; import type { Appearance } from "#appearance"; /** * Props for {@link AppearanceProvider}. * * @since 0.5.0-canary.2 */ export type AppearanceProviderProps = { readonly children: ReactNode; /** * When true, temporarily suppresses CSS transitions during appearance changes. * Prevents jarring color animations when switching appearances. * Default: false */ readonly disableTransition?: boolean | undefined; /** * CSP nonce for inline styles when `disableTransition` is enabled. */ readonly nonce?: string | undefined; /** * Custom async persistence for appearance changes; replaces the `localStorage` auto-persist. */ readonly persistAppearance?: ((value: Appearance) => Promise) | undefined; /** * Callback invoked when `persistAppearance` rejects. */ readonly onPersistError?: ((error: unknown, attemptedAppearance: Appearance) => void) | undefined; /** * Fallback preference when storage has no valid entry — also what SSR renders. * Defaults to {@link DEFAULT_APPEARANCE}. */ readonly appearance?: Appearance | undefined; /** * `localStorage` key the preference is restored from and persisted under. * Defaults to {@link STORAGE_KEY}; pair with `` using the **same key**. * * The provider reads the stored value in its initial client render (so the first paint already * matches the preference — no flash, no post-mount settle), auto-persists changes to * `localStorage` (unless {@link persistAppearance} is also given, which then wins), and syncs * across tabs via the `storage` event. * * @remarks SSR has no `localStorage`, so the server renders the {@link AppearanceProviderProps.appearance} * prop. For a returning visitor whose stored preference differs, components that render * preference-dependent markup hydrate-reconcile once; gate them behind a mounted flag to avoid that. */ readonly storageKey?: string | undefined; }; /** * Provider component for appearance state management. * * **React 19 Features Used:** * - `useOptimistic` - Immediate UI feedback while persisting the preference * - `useSyncExternalStore` - SSR-safe subscription to the OS color scheme preference * - `useEffectEvent` - Stable callback for cross-tab sync without effect re-runs * * @example * ```tsx * // In your root layout — pair with using the same storage key * {children} * ``` * * @since 0.5.0-canary.2 */ export declare function AppearanceProvider({ children, disableTransition, nonce, onPersistError, persistAppearance, storageKey, appearance: initialAppearance, }: AppearanceProviderProps): JSX.Element;