Style configuration
Choose your app's default look in one place: filled or outlined fields, dense or roomy lists, text or filled buttons, and whether touch targets take up layout space. Every component you don't set by hand follows it.
Style configuration in depth
What you can change
Any variant, size, or density you don't set on a component comes from the style configuration. Set that value once for the whole app:
- Outlined fields across a form-heavy app. Set
defaultFieldVarianttoOutlined. - A denser data-entry or admin screen. Set
defaultFieldDensity,defaultListDensity,defaultMenuDensity, anddefaultTableDensityto one ofDense1toDense4, whereDense4is the tightest. - Filled buttons as the house style. Set
defaultButtonVarianttoFilled. - A compact mode the user switches on. Change the density settings while the app runs. Components already on the page update to match.
- Touch targets that take up layout space. Set
defaultTouchTargettoWrapper.
The style configuration chooses a component's variant, size, and density. Colors, corners, and type within that choice come from theming.
Which value a component uses
- An attribute on the component wins. A component uses its own attribute first, then the style configuration, then Chameleon's default. To give one part of the page a different look, set the attribute on the components in that part.
- An attribute set to a value the setting doesn't list counts as unset, so a field with
variant="invalid-value"falls back to the style configuration. - Reduced motion overrides every animation setting. When the user's system asks for reduced motion, dialogs and popovers open and close without animating, whatever their own attribute or the style configuration says.
- Filled fields hide their label at
Dense2and tighter, because there's no room for it to float into. Pair dense fields withOutlinedto keep labels.
Settings
The table spells names as JavaScript does; in Blazor each starts with a capital letter, such as DefaultButtonVariant. Each value belongs to the enum named in the Values column.
Fields, lists, menus, and tables
These are the settings you're most likely to change.
| Setting | Values | Default | Applies to |
|---|---|---|---|
defaultFieldVariant |
FieldVariant: Filled, Outlined, Text |
Filled |
Text fields, text areas, number, email, password, search, and telephone fields, and selects |
defaultFieldDensity |
Density: Standard, Dense1, Dense2, Dense3, Dense4 |
Standard |
The same fields as defaultFieldVariant |
defaultListDensity |
Density: Standard, Dense1, Dense2, Dense3, Dense4 |
Standard |
Lists |
defaultMenuDensity |
Density: Standard, Dense1, Dense2, Dense3, Dense4 |
Standard |
Menus and sub-menus |
defaultTableDensity |
Density: Standard, Dense1, Dense2, Dense3, Dense4 |
Standard |
Data grids and data tables |
defaultTableVariant |
TableVariant: Filled, Standard, Surface, Tonal |
Standard |
Data grids and data tables |
defaultTableCaptionPosition |
CaptionPosition: Leading, Trailing |
Leading |
Data grids and data tables |
Buttons, chips, cards, and sliders
| Setting | Values | Default | Applies to |
|---|---|---|---|
defaultButtonVariant |
ButtonVariant: Elevated, Filled, Tonal, Outlined, Text |
Text |
Buttons and toggle buttons |
defaultButtonSize |
Size: ExtraSmall, Small, Medium, Large, ExtraLarge |
Small |
Buttons and toggle buttons |
defaultIconButtonVariant |
IconButtonVariant: Filled, Outlined, Standard, Tonal |
Filled |
Icon buttons and toggle icon buttons |
defaultIconButtonSize |
Size: ExtraSmall, Small, Medium, Large, ExtraLarge |
Small |
Icon buttons and toggle icon buttons |
defaultIconButtonWidth |
IconButtonWidth: Narrow, Regular, Wide |
Regular |
Icon buttons and toggle icon buttons |
defaultFABMenuVariant |
FABMenuVariant: Primary, Secondary, Tertiary |
Primary |
Floating action button (FAB) menus |
defaultChipVariant |
ChipVariant: Elevated, Outlined |
Outlined |
Assist, filter, and suggestion chips |
defaultChipSize |
ChipSize: Small, ExtraSmall |
Small |
Every chip |
defaultCardVariant |
CardVariant: Elevated, Filled, Outlined |
Outlined |
Cards and action cards |
defaultSliderSize |
Size: ExtraSmall, Small, Medium, Large, ExtraLarge |
ExtraSmall |
Sliders, range sliders, and dials |
Touch targets
| Setting | Values | Default | Applies to |
|---|---|---|---|
defaultTouchTarget |
TouchTarget: None, Overflow, Wrapper |
Overflow |
Buttons, icon buttons, FABs, chips, checkboxes, radio buttons, switches, sliders, dials, list items, and action cards |
The setting decides what happens when a control is smaller than 48 by 48 pixels:
Overflowextends the area that responds to touch and the mouse beyond the control's visible edge, without changing the layout.Wrapperadds space around the control, so it takes up the full 48 by 48 pixels in the layout.Nonelimits the area to the visible control. Don't use it unless your layout already guarantees large enough targets.
Rarely changed
These set motion, loading indicators, scroll indicators, and tooltip placement.
| Setting | Values | Default | Applies to |
|---|---|---|---|
defaultDialogAnimation |
DialogAnimation: Fade, None, Slide |
Fade |
Dialogs |
defaultPopoverAnimation |
PopoverAnimation: None, Fade, FadedSlide, Expand |
FadedSlide |
Popovers, menus, sub-menus, selects, and FAB menus |
defaultScrollIndicator |
ScrollIndicator: Divider, None, Shadow |
Shadow |
Dialogs and scroll regions |
defaultTooltipPosition |
TooltipPosition: StartStart, StartCenter, StartEnd, CenterStart, CenterEnd, EndStart, EndCenter, EndEnd |
EndCenter |
Plain and rich tooltips |
defaultSkeletonVariant |
SkeletonVariant: Regular, Text |
Regular |
Skeletons |
defaultSkeletonAnimation |
SkeletonAnimation: None, Pulse, Wave |
Wave |
Skeletons |
defaultProgressTrackThickness |
ProgressTrackThickness: Standard, Thick |
Standard |
Linear and circular progress indicators |
defaultProgressWaveShape |
ProgressWaveShape: Flat, Wavy |
Flat |
Linear and circular progress indicators |
defaultProgressTrackShape |
ProgressTrackShape: Circle, SoftSquircle, Squircle |
Circle |
Circular progress indicators |
Set your defaults
Call setStyleConfiguration() once in your app's entry point, naming only the settings you change.
import { ButtonVariant, Density, FieldVariant, setStyleConfiguration } from "@materia-technologies-inc/chameleon-components-web";
setStyleConfiguration({
defaultButtonVariant: ButtonVariant.Filled,
defaultFieldVariant: FieldVariant.Outlined,
defaultFieldDensity: Density.Dense1,
});
Change them while the app runs
Call setStyleConfiguration() again with the settings to change. Settings you leave out keep their values, and components already on the page update to match.
import { Density, setStyleConfiguration } from "@materia-technologies-inc/chameleon-components-web";
function setCompactMode(compact) {
setStyleConfiguration({ defaultFieldDensity: compact ? Density.Dense3 : Density.Standard });
}
To return a setting to Chameleon's default, set it to "DEFAULT". getStyleConfiguration() returns the settings as you've set them, with "DEFAULT" for each one you haven't.
Set your defaults
Call setStyleConfiguration() in your entry point, before the first render, naming only the settings you change.
import { createRoot } from "react-dom/client";
import { ButtonVariant, FieldVariant, setStyleConfiguration } from "@materia-technologies-inc/chameleon-components-react";
import { App } from "./App";
setStyleConfiguration({
defaultButtonVariant: ButtonVariant.Filled,
defaultFieldVariant: FieldVariant.Outlined,
});
createRoot(document.getElementById("root")!).render(<App />);
Change them while the app runs
Call setStyleConfiguration() again, from an event handler for instance, with the settings to change. Settings you leave out keep their values. Components already on the page update to match, with no state or re-render on your side.
To return a setting to Chameleon's default, set it to "DEFAULT". getStyleConfiguration() returns the settings as you've set them, with "DEFAULT" for each one you haven't.
Set your defaults
Set options.StyleConfiguration where you register Chameleon's services, in Program.cs. Settings you don't name keep Chameleon's defaults.
using Chameleon.Blazor;
builder.Services.AddChameleonServices(options =>
{
options.StyleConfiguration = new()
{
DefaultButtonVariant = ButtonVariant.Filled,
DefaultFieldVariant = FieldVariant.Outlined,
DefaultFieldDensity = Density.Dense1,
};
});
Change them while the app runs
Inject IChameleonConfigurationService and assign its StyleConfiguration a copy of the current one, made with a with expression. Components already on the page update to match.
@inject IChameleonConfigurationService ChameleonConfiguration
@code {
private void UseCompactFields()
{
ChameleonConfiguration.StyleConfiguration = ChameleonConfiguration.StyleConfiguration with
{
DefaultFieldDensity = Density.Dense3,
};
}
}
The with expression keeps your other settings. Assigning a new() configuration resets every setting it doesn't name to Chameleon's default.
To return a setting to Chameleon's default, set it to Default.UseDefault.