Note: This page is specific to the optum theme. For other themes, please switch to the appropriate theme in the top right corner of the page.
import { createTheme } from '@uhg-abyss/web/tools/theme';The createTheme tool uses Abyss's preset themes and allows you to override those themes to fit your design needs. createTheme is used in conjunction with ThemeProvider and leverages Emotion for styling.
Usage
createTheme accepts two arguments. The first is the name of a default theme (required). There are currently two themes available: 'uhc', 'optum'. The second argument is an optional themeConfig object that can include theme overrides and other configuration options.
createTheme( themeName: 'uhc' | 'optum', themeConfig?: { /** Theme token overrides */ theme?: DeepPartial<ThemeTokens>; /** Global CSS style overrides */ css?: Record<string, React.CSSProperties>; /** Whether to include base CSS styles (reset, normalize, foundational styles). @default true */ includeBaseCss?: boolean; /** Whether to include theme-specific font face definitions. @default true */ includeFonts?: boolean; /** Whether to include default heading styles (h1-h6). @default true */ includeHeadings?: boolean; /** Custom CDN URL for brand assets (logos, icons, brandmarks) */ brandAssetsCdn?: string; /** Use Enterprise Sans font family (UHC theme only). @default false */ enterpriseFont?: boolean; /** Override the theme name */ themeName?: string; /** Enable CSS variable caching. @default true */ enableCSSVariableCache?: boolean; /** Enable theme object caching. @default false */ enableThemeCache?: boolean; }): BaseTheme;Theme overrides
The themeConfig object accepts theme and css properties to override the default theme tokens and/or create custom tokens that can be used in the styled tool or the available css prop on each component. This allows teams to customize the theme for specific projects or brands in a single location.
import { ThemeProvider } from '@uhg-abyss/web/ui/ThemeProvider';import { createTheme } from '@uhg-abyss/web/tools/theme';
const themeConfig = { theme: { breakpoints: { xs: 0, sm: 360, md: 744, lg: 1248, }, colors: { 'core.color.brand.70': '#0C55B8', 'core.color.brand.80': '#004BA0', 'core.color.brand.100': '#002677', }, sizes: {...}, space: {...}, fontSizes: {...}, fonts: {...}, fontWeights: {...}, lineHeights: {...}, letterSpacings: {...}, borderWidths: {...}, borderStyles: {...}, radii: {...}, shadows: {...}, opacities: {...}, }, css: { // provide custom global css overrides p: { marginBottom: '10px', }, },};
const theme = createTheme('optum', themeConfig);
const App = () => { return <ThemeProvider theme={theme}>...</ThemeProvider>;};
ReactDOM.render(<App />, document.getElementById('root'));Abyss theme tokens
You can create your own themes by white labeling and applying overrides to our theme tokens. Please see the white labeling overview documentation for more information.