CDP Frontend SDK
    Preparing search index...

    Function ThemeProvider

    • Provides the theme to its child components and injects CSS variables.

      Parameters

      • props: ThemeProviderProps

        The props for the component.

        Props for the ThemeProvider component.

        • children: ReactNode
        • OptionalclassName?: string
        • Optionalstyle?: CSSProperties
        • Optionaltheme?: Partial<Theme>

      Returns Element

      The theme provider component.

      const AuthBasedTheme = ({ children }: { children: React.ReactNode }) => {
      const { isSignedIn: signedIn } = useIsSignedIn();
      const { evmAddress: cdpEvmAddress } = useEvmAddress();
      const isAuthenticated = signedIn && cdpEvmAddress;
      const theme = useMemo(() => (isAuthenticated ? darkTheme : {}), [isAuthenticated]);
      return (
      <ThemeProvider theme={theme}>
      {children}
      </ThemeProvider>
      );
      };

      function App() {
      // Change the theme based on the user's authentication status
      return (
      <CDPHooksProvider config={cdpConfig}>
      <AuthBasedTheme>
      <YourApp />
      </AuthBasedTheme>
      </CDPHooksProvider>
      );
      }