DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

Themes

API Reference

CSS colour utility classes

The theme colours as utility classes: bg-* sets the background, color-* the text colour. They read the same CSS variables, so they follow the changes above too.

Background colours
.bg-success
.bg-info
.bg-warning
.bg-error
.bg-primary
.bg-primary-brighter
.bg-primary-darker
.bg-surface
.bg-accent
.bg-navbar
Text colours
.color-white
.color-success
.color-warning
.color-error
.color-info
.color-primary
.color-primary-text
.color-rating-star
Show Code
Colors.razor

<div class="bg-primary"><span class="color-black">.bg-primary</span></div>
<div class="bg-primary-darker"><span class="color-white">.bg-primary-darker</span></div>
<div class="bg-white"><span class="color-error">.color-error</span></div>
<div class="bg-black"><span class="color-primary-text">.color-primary-text</span></div>

Design tokens and high contrast

Besides the palette the stylesheet defines tokens for the spacing scale, the focus ring and the control heights (core/_theme.scss); the component styles use them instead of literal values. Override one on :root or on any container to change it for everything inside. The high-contrast theme is a third built-in theme: a black page, white text, light status colours with black text and a yellow focus colour, plus three theme tokens - a 3px focus ring, solid borders on outlined surfaces and a ring around cards, papers, dialogs and menus. Windows contrast themes (forced-colors) are answered by the stylesheet on its own, whatever theme is set.

TokenDefaultSample
--dws-space-1 0.25rem
--dws-space-2 0.5rem
--dws-space-3 0.75rem
--dws-space-4 1rem
--dws-space-5 1.5rem
--dws-space-6 2rem
--dws-control-height-compact 2.25rem
Aa
--dws-control-height 2.375rem
Aa
--dws-control-height-large 2.5rem
Aa
--dws-touch-target 2.75rem
Aa
--dws-focus-ring-width / -offset / -color 2px / 2px / var(--accent)
--dws-contrast-border-width / -color 0px / var(--text)
Paper
Overridden for this row (4px ring in the error colour, wider gap in the chips):
Show Code
site.css

/* Defaults (Styles/core/_theme.scss). Override on :root, or on a container for everything inside it. */
:root {
    --dws-space-1: 0.25rem;  --dws-space-2: 0.5rem;  --dws-space-3: 0.75rem;
    --dws-space-4: 1rem;     --dws-space-5: 1.5rem;  --dws-space-6: 2rem;

    --dws-focus-ring-width: 2px;
    --dws-focus-ring-offset: 2px;
    --dws-focus-ring-color: var(--accent);

    --dws-control-height: 2.375rem;
    --dws-control-height-compact: 2.25rem;
    --dws-control-height-large: 2.5rem;
    --dws-touch-target: 2.75rem;

    --dws-contrast-border-width: 0px;   /* 1px in the high-contrast theme and in forced-colors mode */
    --dws-contrast-border-color: var(--text);
}

.my-form { --dws-focus-ring-width: 4px; --dws-focus-ring-color: var(--error); }
Colors.razor.cs

// The built-in themes: DwsThemeTypes.Dark, Light and HighContrast.
await ThemeService.ChangeTheme(DwsThemeTypes.HighContrast, JS, renderMode: CurrentRenderMode);

// A theme of your own can carry tokens too (IDwsTheme.Tokens, optional):
public class MyTheme : IDwsTheme
{
    public string Name { get; set; } = "My-Theme";
    public DwsThemeTypes ThemeType { get; set; } = DwsThemeTypes.Light;
    public DwsPalette Palette { get; set; } = new DwsLightTheme().Palette;

    public IReadOnlyDictionary<string, string> Tokens { get; } = new Dictionary<string, string>
    {
        ["dws-focus-ring-width"] = "3px",
    };
}

await ThemeService.WriteThemeToCSSAsync(new MyTheme(), JS, renderMode: CurrentRenderMode);

Interface-Description

Name Typ Default Description
ColorDef DwsColorData? null The palette colour shown and edited, e.g. StateContainer.CurrentTheme.Palette.Primary. Changed in place once a colour is applied, so the palette holds the colour the document uses.
Label string string.Empty Name of the colour, shown as the label of the field.
ParamName string string.Empty The CSS custom property the colour is written to, without the leading -- (e.g. primary). Empty: the CSS_ParamName of ColorDef. Without either, a change only updates ColorDef.
Name Typ Description
OnColorChanged EventCallback<DwsColorData> Raised after a colour the user chose was applied, with the updated ColorDef. Not raised when writing it to the document failed: the colour stays as it was and a message says so.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.