ThemeScope
Since 0.1.0-alpha.22Themes part of a page, in a div: a section in another brand, a denser panel, an inverse band.
A panel in another theme
Put the content inside a ThemeScope, and set any of Brand, a built-in Gray, Radius, Density, Preset (shape, density and depth) and ColorScheme, which here can also be Inverse. What it doesn't set comes from the theme around it.
Static
Preview
The page's theme
Standard, blue, medium radius.
In a ThemeScope
Compact, rose, small radius.
Code
@* A ThemeScope themes what's inside: here a compact, rose, small-radius panel next to one in the
page's theme. What it doesn't set comes from the theme around it. *@
<Grid Columns="new() { Base = 1, Sm = 2 }" Gap="4" Grow>
<Card Title="The page's theme" Description="Standard, blue, medium radius.">
<Row Gap="2" Wrap Align="Align.Center">
<Button>Approve</Button>
<Button Variant="ButtonVariant.Soft">Comment</Button>
<Badge Accent="Accent.Primary">Draft</Badge>
</Row>
</Card>
<ThemeScope Density="ThemeDensity.Compact" Brand="rose" Radius="ThemeRadius.Sm">
<Card Title="In a ThemeScope" Description="Compact, rose, small radius.">
<Row Gap="2" Wrap Align="Align.Center">
<Button>Approve</Button>
<Button Variant="ButtonVariant.Soft">Comment</Button>
<Badge Accent="Accent.Primary">Draft</Badge>
</Row>
</Card>
</ThemeScope>
</Grid>Add this example to a page with the izzy CLI:
izzy add component ThemeScope --at <file>:<line>Details
It takes Brand, a built-in Gray, Radius, Density, Preset (shape, density and depth only) and ColorScheme; what it doesn't set comes from around it. Fonts, HeadingWeight, Scrollbars and a hex Gray are the app's, on IzzyTheme. For one exact value, use CSS: its variable in your stylesheet, or Style and Class here (izzyblazor.com/docs/theming/tokens).
Mode support
| Feature | Static | Interactive |
|---|---|---|
| Everything | Yes | Yes |
Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.
Accessibility
- It renders a
divaround its content, with nothing people interact with. - A hex
Brandis adjusted until text on it, and the accent as text, reach 4.5:1 contrast.
Parameters
| Prop | Type | Default |
|---|---|---|
ColorSchemeThe color scheme here: ColorScheme.Light, ColorScheme.Dark, or ColorScheme.Inverse for the opposite of the page's. | ColorScheme? | |
ChildContentThe part of the page to theme. | RenderFragment? | Required |
ClassClasses for the div, such as one that sets CSS variables in your stylesheet. | string? | |
StyleInline style for the div, such as "--ib-card-padding: 1rem". | string? | |
PresetThe starting set of defaults: density, shape and type, and a default accent and gray, which the other settings override. | ThemePreset? | |
BrandThe brand color, over the preset's: a hex color ("#0a7d5a"), from which the fill, the text on it, the accent as text and the soft tint are derived in light and dark, each pair at AA (see BrandPalette); or a built-in, hand-tuned one: blue (the default), ink (monochrome), indigo, violet, teal, green, rose. | string? | |
GrayThe grays (page, surfaces, fills, borders and text), over the preset's: a built-in set, neutral (the default), slate (cool) or stone (warm paper). | string? | |
RadiusThe radius scale, over the preset's. | ThemeRadius? | |
DensityControl heights, table rows and card padding, over the preset's. | ThemeDensity? | |
ChartPaletteThe colors charts, gauges and the scheduler use, unless a chart sets its own ChartPalette. | ThemeChartPalette? |
See also
- IzzyTheme: sets the preset, brand color, fonts and color scheme on the server.
- ColorSchemeSwitch: lets the user pick System, Light or Dark.