Démarrage rapide
1. Importez la feuille de style
Signaler un code incorrect
import "@auth0/universal-components-react/styles" ;
Utilisateurs Tailwind v4 : ajoutez @import "@auth0/universal-components-react/tailwind" à votre feuille de style CSS.Utilisateurs shadcn : aucune importation nécessaire, les styles se trouvent déjà dans votre build Tailwind.
2. Ajoutez la couleur de votre image de marque
Signaler un code incorrect
:root {
--primary : #4f46e5 ; /* your brand color */
--primary-foreground : #ffffff ; /* text on buttons */
}
Terminé. Tous les boutons, les liens et les états actifs affichent maintenant votre image de marque.
Préréglages du thème
Passer themeSettings à Auth0ComponentProvider pour basculer entre les thèmes intégrés.
Signaler un code incorrect
< Auth0ComponentProvider
themeSettings = { {
mode: "light" , // 'light' | 'dark'
theme: "default" , // 'default' | 'minimal' | 'rounded'
} }
>
< App />
</ Auth0ComponentProvider >
Préréglage Description defaultApparence Auth0 standard avec ombres et bordures équilibrées minimalPoids visuel réduit : moins d’ombres, bordures plus claires roundedDes rayons de bordure augmentés pour un rendu plus doux
Référence des variables CSS
Toutes les propriétés visuelles sont gérées par des propriétés CSS personnalisées. Vous pouvez les redéfinir dans votre feuille de style ou via la propriété themeSettings.variables.
Couleurs (claires)
Couleurs (sombres)
Rayon de bordure
Typographie
Signaler un code incorrect
:root {
/* Brand - the most impactful variables */
--primary : oklch ( 37 % 0 0 ); /* buttons, links, active states */
--primary-foreground : oklch ( 100 % 0 0 ); /* text on primary surfaces */
/_ Surfaces _/
--background : oklch ( 100 % 0 0 ); /_ page background _/
--foreground : oklch ( 9 % 0 0 ); /_ default text _/
--card : oklch ( 100 % 0 0 ); /_ card background _/
--card-foreground : oklch ( 0 % 0 0 ); /_ text inside cards _/
--popover : oklch ( 100 % 0 0 ); /_ dropdown / dialog background _/
--popover-foreground : oklch ( 9 % 0 0 ); /_ text inside popovers _/
--input : oklch ( 100 % 0 0 ); /_ input field background _/
/_ Secondary & muted _/
--secondary : oklch ( 96 % 0 0 );
--secondary-foreground : oklch ( 100 % 0 0 );
--muted : oklch ( 96 % 0 0 ); /_ disabled backgrounds _/
--muted-foreground : oklch ( 45 % 0 0 ); /_ placeholder text _/
/_ Accent & destructive _/
--accent : oklch ( 97 % 0 0 ); /_ hover highlights _/
--accent-foreground : oklch ( 9 % 0 0 );
--destructive : oklch ( 93 % 0.03 17 ); /_ error states _/
--destructive-foreground : oklch ( 36 % 0.14 17 );
/_ Borders _/
--border : oklch ( 89 % 0 0 );
--ring : oklch ( 89 % 0 0 ); /_ focus ring _/
}
Signaler un code incorrect
.dark {
/* Brand */
--primary : oklch ( 70 % 0.15 250 ); /* brighter for dark backgrounds */
--primary-foreground : oklch ( 10 % 0 0 );
/* Surfaces */
--background : oklch ( 12 % 0 0 );
--foreground : oklch ( 95 % 0 0 );
--card : oklch ( 15 % 0 0 );
--card-foreground : oklch ( 95 % 0 0 );
--popover : oklch ( 15 % 0 0 );
--popover-foreground : oklch ( 95 % 0 0 );
--input : oklch ( 18 % 0 0 );
/* Secondary & muted */
--secondary : oklch ( 20 % 0 0 );
--secondary-foreground : oklch ( 95 % 0 0 );
--muted : oklch ( 20 % 0 0 );
--muted-foreground : oklch ( 60 % 0 0 );
/* Accent & destructive */
--accent : oklch ( 25 % 0 0 );
--accent-foreground : oklch ( 95 % 0 0 );
--destructive : oklch ( 30 % 0.15 17 );
--destructive-foreground : oklch ( 95 % 0.05 17 );
/* Borders */
--border : oklch ( 25 % 0 0 );
--ring : oklch ( 35 % 0 0 );
}
Signaler un code incorrect
:root {
/* Common - adjust these for overall feel */
--radius-sm : 4 px ; /* tags, chips */
--radius-md : 6 px ; /* small elements */
--radius-lg : 10 px ; /* buttons, inputs */
--radius-xl : 12 px ; /* cards */
--radius-2xl : 16 px ; /* modals, large panels */
/_ Fine-grained ( rarely needed ) _/
--radius-xs : 2 px ;
--radius-3xl : 20 px ;
--radius-4xl : 24 px ;
--radius-5xl : 32 px ;
}
Signaler un code incorrect
:root {
--font-size-page-header : 2.25 rem ; /* 36px - main title */
--font-size-heading : 1.5 rem ; /* 24px - section headings */
--font-size-title : 1.25 rem ; /* 20px - card titles */
--font-size-subtitle : 1.125 rem ; /* 18px - secondary headings */
--font-size-body : 1 rem ; /* 16px - body text */
--font-size-paragraph : 0.875 rem ; /* 14px - descriptions */
--font-size-label : 0.875 rem ; /* 14px - form labels */
--font-size-page-description : 0.875 rem ; /* 14px - subtitles */
}
Style par composant
Chaque composant accepte une propriété styling pour des remplacements ciblés sans toucher les styles globaux.
Signaler un code incorrect
< SsoProviderTable
styling = { {
variables: {
common: {
"--primary" : "#059669" , // override just for this component
},
light: { "--card" : "#f8fafc" },
dark: { "--card" : "#1e293b" },
},
classes: {
"SsoProviderTable-header" : "shadow-lg" ,
"SsoProviderTable-table" : "rounded-xl" ,
},
} }
/>
Quand utiliser :
variables – Remplacements de propriétés CSS personnalisées limitées au composant
classes – Classes Tailwind ou classes personnalisées appliquées à des composants précis
Cibles de classe disponibles par composant
Chaque composant expose des cibles de classe pour ses sections principales : SsoProviderCreate – SsoProviderCreate-header, SsoProviderCreate-wizard
– ProviderSelect-root, ProviderDetails-root, ProviderConfigure-root SsoProviderTable – SsoProviderTable-header, SsoProviderTable-table, SsoProviderTable-row SsoProviderEdit – SsoProviderEdit-header, SsoProviderEdit-tabs
– SsoProviderEdit-ssoTab, SsoProviderEdit-provisioningTab, SsoProviderEdit-domainsTab DomainTable – DomainTable-header, DomainTable-table
– DomainTable-createModal, DomainTable-configureModal, DomainTable-deleteModal OrganizationDetailsEdit – OrganizationDetailsEdit-header, OrganizationDetailsEdit-form, OrganizationDetailsEdit-actions
Personnalisations courantes
Couleurs de la marque (HEX)
Convertissez la couleur hexadécimale de votre marque au format utilisé dans CSS :
Signaler un code incorrect
:root {
/* Using hex directly */
--primary : #4f46e5 ;
--primary-foreground : #ffffff ;
/* Or oklch for better color manipulation */
--primary : oklch ( 50 % 0.2 265 ); /* purple */
}
Coins plus arrondis
Pour une esthétique plus arrondie de tous les composants :
Signaler un code incorrect
:root {
--radius-lg : 16 px ; /* buttons, inputs */
--radius-xl : 20 px ; /* cards */
--radius-2xl : 24 px ; /* modals */
}
Typographie compacte
Pour des interfaces utilisateur plus denses :
Signaler un code incorrect
:root {
--font-size-page-header : 1.75 rem ;
--font-size-heading : 1.25 rem ;
--font-size-title : 1 rem ;
--font-size-body : 0.875 rem ;
}
Mode sombre
Les composants réagissent automatiquement au paramètre mode dans themeSettings. Pour synchroniser avec le mode sombre de votre application :
Signaler un code incorrect
function App () {
const [ isDark , setIsDark ] = useState ( false );
return (
< Auth0ComponentProvider
themeSettings = { {
mode: isDark ? "dark" : "light" ,
} }
>
< YourApp />
</ Auth0ComponentProvider >
);
}
Ou utilisez les préférences système :
Signaler un code incorrect
const prefersDark = window . matchMedia ( '(prefers-color-scheme: dark)' ). matches ;
< Auth0ComponentProvider
themeSettings = { { mode: prefersDark ? 'dark' : 'light' } }
>