Passer au contenu principal
useAuth0Themes()
Hook React permettant d’obtenir les options du thème actuel avec une configuration à plat issue du contexte d’image de marque.

Renvoie

FlattenedTheme | nullObjet FlattenedTheme contenant les couleurs, les polices, les bordures, pageBackground et les configurations du widget, ou null si aucune image de marque n’est disponible
Exemple
import React from 'react';
import { useAuth0Themes } from '@auth0/auth0-acul-react';

const ThemedComponent: React.FC = () => {
  const theme = useAuth0Themes();

  if (!theme) {
    return <div>No theme available</div>;
  }

  return (
    <div
      style={{
        backgroundColor: theme.colors.primary_button,
        color: theme.colors.primary_button_label,
        borderRadius: theme.borders.button_border_radius,
      }}
    >
      <h1
        style={{
          fontWeight: theme.fonts.title.bold ? 'bold' : 'normal',
          fontSize: `${theme.fonts.title.size}%`,
        }}
      >
        Styled with Auth0 Theme
      </h1>
      <button
        style={{
          backgroundColor: theme.colors.primary_button,
          borderRadius: theme.borders.button_border_radius,
        }}
      >
        Primary Button
      </button>
      <p>Body text color: {theme.colors.body_text}</p>
    </div>
  );
};