ConstReadonlybackground: (isDark?: boolean) => string | undefinedGet appropriate background color for theme
Returns the background color token for dark themes. Returns undefined for light themes (uses default/transparent).
Readonlyborder: (isDark?: boolean) => stringGet appropriate border color for theme
Returns border color appropriate for the theme. Dark themes use darker gray, light themes use light gray.
ReadonlyfontColor: (isDark?: boolean) => "light" | "dark"Get theme variant for font-related compose functions (alias for variant)
Alias for theme.variant() with a more explicit name for typography contexts. Use this when passing theme to compose functions like typography.sans.compose(), typography.campaign.compose(), or text.rich.composeSimple().
// Use with typography compose functions
typography.sans.compose('large', { theme: theme.fontColor(isThemeDark) })
elementStyles.text.rich.composeSimple({ theme: theme.fontColor(isThemeDark) })
// For actual color values, use foreground()
.withStyles({
element: {
color: theme.foreground(isThemeDark) // Returns 'white' | 'black'
}
})
Readonlyforeground: (isDark?: boolean) => "white" | "black"Get appropriate foreground color for theme
Returns the text/icon color that should be used for the given theme. Dark themes use white text, light themes use black text.
Readonlyinverse: (isDark?: boolean) => "white" | "black"Get inverted foreground color for theme
Returns the opposite of theme.foreground(). Useful for accent elements that should contrast with the theme.
Readonlymuted: (isDark?: boolean) => stringGet muted/tertiary text color for theme
Returns the most subtle text color appropriate for tertiary text, placeholder text, or disabled states. More muted than subdued().
Readonlysubdued: (isDark?: boolean) => stringGet subdued/secondary text color for theme
Returns a less prominent text color appropriate for secondary text, captions, labels, or supporting content. Adapts to theme context.
Readonlyvariant: (isDark?: boolean) => "light" | "dark"Convert boolean theme flag to theme variant string
Maps the boolean isThemeDark prop to the string values expected
by styles package compose functions (typography, campaign, etc.)
import { theme } from '@universityofmaryland/web-utilities-library/theme';
// Use in typography compose
const headlineStyles = {
...typography.sans.compose('large', {
theme: theme.variant(isThemeDark)
})
};
// Use in animation compose
const animationStyles = {
...animation.line.composeSlideUnder({
color: theme.foreground(isThemeDark)
})
};
// Use in element styles
.withStyles({
element: {
color: theme.foreground(isThemeDark),
backgroundColor: theme.background(isThemeDark)
}
})
Theme utility namespace
Provides functions to map boolean theme flags to style package values. All functions accept an optional boolean and return type-safe literals.