MCPcopy
hub / github.com/streamlit/streamlit / createCustomThemes

Function createCustomThemes

frontend/lib/src/theme/utils.ts:1492–1532  ·  view source on GitHub ↗
(
  themeInput: CustomThemeConfig
)

Source from the content-addressed store, hash-verified

1490 * @returns 1 or 3 custom themes
1491 */
1492export const createCustomThemes = (
1493 themeInput: CustomThemeConfig
1494): ThemeConfig[] => {
1495 const hasLightConfigs = hasThemeSectionConfigs(themeInput.light)
1496 const hasDarkConfigs = hasThemeSectionConfigs(themeInput.dark)
1497
1498 const customThemes: ThemeConfig[] = []
1499
1500 // When light or dark theme section configs are set, need to create a custom theme for each
1501 if (hasLightConfigs || hasDarkConfigs) {
1502 const lightThemeInput = handleSectionInheritance(themeInput, "light")
1503 const lightTheme = {
1504 ...createTheme(CUSTOM_THEME_LIGHT_NAME, lightThemeInput),
1505 displayName: "Light",
1506 }
1507
1508 const darkThemeInput = handleSectionInheritance(themeInput, "dark")
1509 const darkTheme = {
1510 ...createTheme(CUSTOM_THEME_DARK_NAME, darkThemeInput),
1511 displayName: "Dark",
1512 }
1513
1514 // Also add an auto custom theme based on the system preference
1515 const autoCustomTheme =
1516 getSystemThemePreference() === "dark" ? darkTheme : lightTheme
1517 const autoTheme = {
1518 ...autoCustomTheme,
1519 displayName: AUTO_THEME_NAME,
1520 name: CUSTOM_THEME_AUTO_NAME,
1521 }
1522 // Return light, dark, and auto custom themes
1523 customThemes.push(lightTheme, darkTheme, autoTheme)
1524 } else {
1525 // No light/dark section configs set - single "Custom Theme" returned
1526 const customTheme = createTheme(CUSTOM_THEME_NAME, themeInput)
1527 // Return the single custom theme
1528 customThemes.push(customTheme)
1529 }
1530
1531 return customThemes
1532}
1533
1534/**
1535 * Set the default heading font sizes for the sidebar.

Callers 2

utils.test.tsFile · 0.90
processThemeInputMethod · 0.90

Calls 5

hasThemeSectionConfigsFunction · 0.85
handleSectionInheritanceFunction · 0.85
getSystemThemePreferenceFunction · 0.85
createThemeFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…