DwsLabel
API ReferenceCommon patterns
Order details panel
A key/value panel as on an order page. The captions are small labels with Copyable and Selectable off, so a copied value never drags its caption along. The order ID keeps its copy button visible, the IBAN shows it on hover. The status takes its colour from the order state, and MaxWidth lets the long delivery address wrap instead of stretching the panel.
Show Code
Label.razor
<div class="row g-2" style="max-width: 540px;">
<div class="col-12 col-sm-4">
<DwsLabel Name="LabelDemo_Order_IdCaption" Text="Order ID" FontSize="DwsFontSize.Small" Class="fw-semibold" Copyable="false" Selectable="false" />
</div>
<div class="col-12 col-sm-8">
<DwsLabel Name="LabelDemo_Order_Id" Text="DWS-2026-004217" CopyButtonVisibility="DwsCopyButtonVisibility.Always" />
</div>
<div class="col-12 col-sm-4">
<DwsLabel Name="LabelDemo_Order_IbanCaption" Text="IBAN" FontSize="DwsFontSize.Small" Class="fw-semibold" Copyable="false" Selectable="false" />
</div>
<div class="col-12 col-sm-8">
<DwsLabel Name="LabelDemo_Order_Iban" Text="DE89 3704 0044 0532 0130 00" />
</div>
<div class="col-12 col-sm-4">
<DwsLabel Name="LabelDemo_Order_StatusCaption" Text="Status" FontSize="DwsFontSize.Small" Class="fw-semibold" Copyable="false" Selectable="false" />
</div>
<div class="col-12 col-sm-8 d-flex align-items-center gap-2">
<DwsLabel Name="LabelDemo_Order_Status" Text="@StatusText" Color="@StatusColor" Inline="true" Copyable="false" />
<DwsButton Name="LabelDemo_Order_NextStatus" Appearance="DwsAppearance.Outline" ButtonSize="DwsSize.Small" OnClick="NextStatus">Next status</DwsButton>
</div>
<div class="col-12 col-sm-4">
<DwsLabel Name="LabelDemo_Order_AddressCaption" Text="Delivery address" FontSize="DwsFontSize.Small" Class="fw-semibold" Copyable="false" Selectable="false" />
</div>
<div class="col-12 col-sm-8">
<DwsLabel Name="LabelDemo_Order_Address" MaxWidth="260"
Text="Jana Weber, Example Trading GmbH, 2nd floor, rear building, Musterstraße 123, 10115 Berlin, Germany" />
</div>
</div>Label.razor.cs
private enum OrderStatus { Pending, Paid, Shipped, Cancelled }
private OrderStatus _status = OrderStatus.Paid;
private string StatusText => _status switch
{
OrderStatus.Pending => "Awaiting payment",
OrderStatus.Paid => "Paid",
OrderStatus.Shipped => "Shipped",
_ => "Cancelled",
};
// The colour follows the state; the label itself knows nothing about orders.
private DwsColor StatusColor => _status switch
{
OrderStatus.Pending => DwsColor.Text,
OrderStatus.Paid => DwsColor.Success,
OrderStatus.Shipped => DwsColor.Primary,
_ => DwsColor.Error,
};
private void NextStatus() => _status = (OrderStatus)(((int)_status + 1) % 4);Copyable references in a sentence
Inline sizes a label to its text so it flows with the surrounding sentence, the way a confirmation page mentions an order number. The copy button floats beside the text and never widens the label: shown on hover it briefly covers the neighbouring text, shown always (the tracking number) it gets room of its own. CopyButtonAlignment Start puts it before the customer number.
Your order DWS-2026-004217 has been shipped with tracking number 00340434161094042557 and is on its way. When you contact us, please quote your customer number C-10458 (it is also printed on your invoice).
Show Code
Label.razor
<DwsTypography Name="LabelDemo_Inline_Sentence" Typography="DwsTypographyType.Paragraph">
Your order
<DwsLabel Name="LabelDemo_Inline_Order" Text="DWS-2026-004217" Inline="true" Color="DwsColor.Primary" />
has been shipped with tracking number
<DwsLabel Name="LabelDemo_Inline_Tracking" Text="00340434161094042557" Inline="true" Color="DwsColor.Primary" CopyButtonVisibility="DwsCopyButtonVisibility.Always" />
and is on its way. When you contact us, please quote your customer number
<DwsLabel Name="LabelDemo_Inline_Customer" Text="C-10458" Inline="true" Color="DwsColor.Primary" CopyButtonAlignment="DwsCopyCopyButtonAlignment.Start" />
(it is also printed on your invoice).
</DwsTypography>Reference
Colours and font sizes
Color takes a theme colour (DwsColor.Text by default); Undefined inherits the colour of the parent element. FontSize maps to the theme's --font-size-* variables, from ExtraSmall to Display. A label takes the full width of its container.
Show Code
Label.razor
<DwsLabel Name="LabelDemo_Color_Default" Text="Default text colour" />
<DwsLabel Name="LabelDemo_Color_Primary" Text="Primary: new message" Color="DwsColor.Primary" />
<DwsLabel Name="LabelDemo_Color_Success" Text="Success: payment received" Color="DwsColor.Success" />
<DwsLabel Name="LabelDemo_Color_Error" Text="Error: card declined" Color="DwsColor.Error" />
<div style="color: var(--success);">
<DwsLabel Name="LabelDemo_Color_Inherit" Text="Undefined: inherits the parent's colour" Color="DwsColor.Undefined" />
</div>
<div class="mt-3">
@foreach (DwsFontSize size in _fontSizes)
{
<DwsLabel Name="@($"LabelDemo_FontSize_{size}")" Text="@($"{size}: Total 1,249.00")" FontSize="size" Copyable="false" />
}
</div>Label.razor.cs
private static readonly DwsFontSize[] _fontSizes =
[
DwsFontSize.ExtraSmall,
DwsFontSize.Small,
DwsFontSize.Default,
DwsFontSize.Header,
DwsFontSize.Large,
DwsFontSize.ExtraLarge,
DwsFontSize.BigIcon,
DwsFontSize.Title,
DwsFontSize.Display,
];Hover styling
HoverEffect fades the text on hover. With HoverColor it switches to another theme colour instead, and HoverClass replaces the built-in hover styling with your own class on the root element. Without HoverEffect a label does not change on hover.
Show Code
Label.razor
<style>
.label-demo-hover:hover .dws-label__text {
letter-spacing: 0.05em;
text-decoration: underline wavy var(--accent);
}
</style>
<DwsLabel Name="LabelDemo_Hover_Fade" Text="Edit address (fades on hover)" Color="DwsColor.Primary" HoverEffect="true" Copyable="false" />
<DwsLabel Name="LabelDemo_Hover_Color" Text="Remove item (turns red on hover)" HoverEffect="true" HoverColor="DwsColor.Error" Copyable="false" />
<DwsLabel Name="LabelDemo_Hover_Class" Text="Show more (custom HoverClass)" HoverEffect="true" HoverClass="label-demo-hover" Copyable="false" />Copy button: position, visibility and style
CopyButtonAlignment puts the copy button before (Start) or after (End) the text. CopyButtonVisibility shows it always, on hover (the default) or while the text has focus - click or tab into it. StartIconStyle and EndIconStyle style the button inline.
Show Code
Label.razor
<DwsLabel Name="LabelDemo_Copy_Invoice" Text="Invoice no. RE-2026-1187" CopyButtonAlignment="DwsCopyCopyButtonAlignment.Start"
CopyButtonVisibility="DwsCopyButtonVisibility.Always" StartIconStyle="color: var(--primary);" />
<DwsLabel Name="LabelDemo_Copy_Customer" Text="Customer ID C-10458 (copy on hover)" CopyButtonVisibility="DwsCopyButtonVisibility.OnHover" />
<DwsLabel Name="LabelDemo_Copy_Voucher" Text="Voucher code WINTER-25 (copy on focus)" CopyButtonVisibility="DwsCopyButtonVisibility.OnFocus" />
<DwsLabel Name="LabelDemo_Copy_Licence" Text="Licence 4F2A-9C1D-77B0" CopyButtonVisibility="DwsCopyButtonVisibility.Always" EndIconStyle="color: var(--success);" />Alignment inside a fixed height
Height gives the label a fixed height in px. HorizontalAlignment aligns the text, VerticalAlignment places text and copy button inside that height - like the cells of a summary table, with the total at the bottom right.
Show Code
Label.razor
<div class="d-flex flex-column gap-2" style="max-width: 360px;">
<DwsLabel Name="LabelDemo_Align_Note" Text="Note: fragile" Height="60" HorizontalAlignment="DwsHorizontalAlignment.Left" VerticalAlignment="DwsVerticalAlignment.Top"
CopyButtonVisibility="DwsCopyButtonVisibility.Always" Style="border: 1px dashed var(--secondary);" />
<DwsLabel Name="LabelDemo_Align_Quantity" Text="3 items" Height="60" HorizontalAlignment="DwsHorizontalAlignment.Center" VerticalAlignment="DwsVerticalAlignment.Center"
CopyButtonVisibility="DwsCopyButtonVisibility.Always" Style="border: 1px dashed var(--secondary);" />
<DwsLabel Name="LabelDemo_Align_Total" Text="Total: 1,249.00" Height="60" HorizontalAlignment="DwsHorizontalAlignment.Right" VerticalAlignment="DwsVerticalAlignment.Bottom"
CopyButtonVisibility="DwsCopyButtonVisibility.Always" Style="border: 1px dashed var(--secondary);" />
</div>Interface-Description
| Name | Typ | Parameters | Description |
|---|---|---|---|
| CopyToClipboardAsync | Task | Copies the displayed text to the clipboard. Does nothing before the component is interactive. |
| Name | Typ | Default | Description |
|---|---|---|---|
| Text | string | string.Empty | The text to show. |
| FontSize | DwsFontSize | DwsFontSize.Default | Font size from the theme's --font-size-* variables: ExtraSmall, Small, Default, Header, Large, ExtraLarge, BigIcon, Title, Display. |
| Color | DwsColor | DwsColor.Text | Text color from the theme. DwsColor.Undefined inherits the color of the parent (or of a color class passed through Class). |
| MaxWidth | int? | null | Maximum width in px. Longer text wraps. |
| Height | int? | null | Height in px. VerticalAlignment places the text inside it. |
| Inline | bool | false | Sizes the label to its text so it flows with surrounding content, instead of taking the full width. The copy button floats beside the text and does not add to the label's width. |
| Copyable | bool | true | Shows a copy button that copies the text to the clipboard. |
| Selectable | bool | true | Allows selecting the text. |
| Readonly | bool | false | Freezes the text at the value it had when Readonly was set; later Text changes are ignored until it is turned off. |
| Underline | bool | false | Underlines the text. |
| HoverEffect | bool | false | Changes the text on hover: it fades, or takes HoverColor when that is set. |
| HoverColor | DwsColor | DwsColor.Undefined | Text color while hovered, with HoverEffect on. Undefined only fades the text. |
| HoverClass | string? | null | A CSS class that replaces the built-in hover styling, with HoverEffect on. It is set on the root element: style it with '.your-class:hover .dws-label__text'. |
| HorizontalAlignment | DwsHorizontalAlignment | DwsHorizontalAlignment.Left | Horizontal text alignment. The Space* values justify the text; None leaves it to the parent. |
| VerticalAlignment | DwsVerticalAlignment | DwsVerticalAlignment.Center | Vertical alignment of text and copy button inside the label (see Height), and of the label inside a flex container. |
| CopyButtonVisibility | DwsCopyButtonVisibility | DwsCopyButtonVisibility.OnHover | When the copy button shows: Always, OnHover, or OnFocus (while the text has focus). |
| CopyButtonAlignment | DwsCopyCopyButtonAlignment | DwsCopyCopyButtonAlignment.End | Places the copy button before (Start) or after (End) the text. |
| Href | string | string.Empty | Navigates here on click. Makes the label clickable. |
| OnClickPreventDefault | bool | false | Prevents the browser's default action for the click. |
| OnClickPropagation | bool | true | Lets the click bubble to parent elements. |
| StartIconStyle | string | string.Empty | Inline style of the copy button when it sits before the text. |
| EndIconStyle | string | string.Empty | Inline style of the copy button when it sits after the text. |
| Name | Typ | Description |
|---|---|---|
| OnClick | EventCallback<MouseEventArgs> | Raised on click, and on Enter while the label has focus. Makes the label clickable. Not raised while disabled. |
| 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. |
