Custom Styles
Customizing the styles of your Stack Auth components allows you to maintain your brand identity while leveraging the pre-built functionality. This approach is ideal when you want to quickly align the authentication UI with your application's design system without building custom components from scratch. Stack's theming system uses a React context to store colors and styling variables that can be easily overridden.
You can customize the following color variables to match your brand:
background: Main background color of the applicationforeground: Main text color on the backgroundcard: Background color for card elementscardForeground: Text color for card elementspopover: Background color for popover elements like dropdownspopoverForeground: Text color for popover elementsprimary: Primary brand color, used for buttons and important elementsprimaryForeground: Text color on primary-colored elementssecondary: Secondary color for less prominent elementssecondaryForeground: Text color on secondary-colored elementsmuted: Color for muted or disabled elementsmutedForeground: Text color for muted elementsaccent: Accent color for highlights and emphasisaccentForeground: Text color on accent-colored elementsdestructive: Color for destructive actions like delete buttonsdestructiveForeground: Text color on destructive elementsborder: Color used for bordersinput: Border color for input fieldsring: Focus ring color for interactive elements
And some other variables:
radius: border radius of components like buttons, inputs, etc.
These variables are CSS variables so you can use any valid CSS color syntax like hsl(0, 0%, 0%), black, #fff, rgb(255, 0, 0), etc.
The colors can be different for light and dark mode, allowing you to create a cohesive experience across both themes. You can pass these into the StackTheme component (in your layout.tsx file if you followed the Getting Started guide) as follows:
const theme = {
light: {
primary: 'red',
},
dark: {
primary: '#00FF00',
},
radius: '8px',
}
// ...
<StackTheme theme={theme}>
{/* children */}
</StackTheme>