Icon
API ReferenceColors
Icons in the theme colors
Show Code
Icon.razor
<DwsIcon Name='IconsDemo_Icon01' Icon='@Icons.Solid.AddressBook' Color='@DwsColor.Primary'></DwsIcon>
<DwsIcon Name='IconsDemo_Icon02' Icon='@Icons.Solid.Anchor' Color='@DwsColor.Secondary'></DwsIcon>
<DwsIcon Name='IconsDemo_Icon03' Icon='@Icons.Solid.Passport' Color='@DwsColor.Success'></DwsIcon>
<DwsIcon Name='IconsDemo_Icon04' Icon='@Icons.Solid.X' Color='@DwsColor.Error'></DwsIcon>
<DwsIcon Name='IconsDemo_Icon05' Icon='@Icons.Solid.Exclamation' Color='@DwsColor.Warning'></DwsIcon>Sizes
The icon sizes from XSmall to XLarge
Show Code
Icon.razor
<DwsIcon Name='IconsDemo_Icon06' Icon='@Icons.Solid.AddressBook' Color='@DwsColor.Primary' Size='@DwsSize.XSmall' />
<DwsIcon Name='IconsDemo_Icon07' Icon='@Icons.Solid.AddressBook' Color='@DwsColor.Primary' Size='@DwsSize.Small' />
<DwsIcon Name='IconsDemo_Icon08' Icon='@Icons.Solid.AddressBook' Color='@DwsColor.Primary' Size='@DwsSize.Medium' />
<DwsIcon Name='IconsDemo_Icon09' Icon='@Icons.Solid.AddressBook' Color='@DwsColor.Primary' Size='@DwsSize.Large' />
<DwsIcon Name='IconsDemo_Icon10' Icon='@Icons.Solid.AddressBook' Color='@DwsColor.Primary' Size='@DwsSize.XLarge' />Icon types
Font icons (Type=Font) take Color. SVG files (Type=Svg) are placed inline and take Color too wherever they use currentColor or no fill of their own. Images (Type=Image) keep their own colors; the black sample image sits on a light background here.
Show Code
Icon.razor
<DwsIcon Name='IconsDemo_Icon11' Size='DwsSize.Large' Icon='@Icons.Solid.AddressBook' Color='@DwsColor.Primary' Type='DwsIconType.Font' />
<DwsIcon Name='IconsDemo_Icon12' Width='75' Height='75' Icon='/images/blackhole_black.png' Style='background-color: var(--white); border-radius: 8px; padding: 4px;' Type='DwsIconType.Image' Size='DwsSize.Large' />
<DwsIcon Name='IconsDemo_Icon13' Width='75' Height='75' Icon='/svg/test.svg' Color='@DwsColor.Primary' Type='DwsIconType.Svg' />Sprite sheets
An Icon of the form sprite.svg#name is one symbol of a sprite sheet: the browser draws it through use, nothing is fetched by script, and one file serves all three icons. Same-origin sheets only.
Show Code
Icon.razor
@* A symbol of a sprite sheet: drawn by the browser through <use>, nothing is fetched by script. Same origin only. *@
<DwsIcon Name='IconsDemo_Sprite_Home' Icon='/svg/sprite.svg#home' Type='DwsIconType.Svg' Size='DwsSize.Large' Color='@DwsColor.Primary' AriaLabel='Home' />
<DwsIcon Name='IconsDemo_Sprite_Star' Icon='/svg/sprite.svg#star' Type='DwsIconType.Svg' Size='DwsSize.Large' Color='@DwsColor.Warning' Tooltip='Favourite' />
<DwsIcon Name='IconsDemo_Sprite_Bell' Icon='/svg/sprite.svg#bell' Type='DwsIconType.Svg' Width='40' Height='40' Color='@DwsColor.Error' />Tooltips
Tooltip is shown by DwsTooltip, not by the browser's title attribute: it opens on mouse hover and on a long press on a touch screen, moves to another side when it does not fit, and Escape closes it. It is also the icon's accessible name unless AriaLabel is set. An icon is not a Tab stop by default; TooltipFocusable makes one of it, so keyboard users can open the tooltip by moving the focus onto the icon (the fourth icon below). A clickable icon is focusable anyway. For an action, prefer a real button with a DwsTooltip around it, as the last example does.
Show Code
Icon.razor
@* Tooltip: shown by DwsTooltip on hover and long press, and the accessible name. *@
<DwsIcon Name='IconsDemo_Icon14' Icon='@Icons.BS.InfoCircle' Color='@DwsColor.Primary' Tooltip='Information' />
<DwsIcon Name='IconsDemo_Icon15' Icon='@Icons.BS.QuestionCircle' Color='@DwsColor.Secondary' Tooltip='Help' />
<DwsIcon Name='IconsDemo_Icon16' Icon='@Icons.BS.ExclamationTriangle' Color='@DwsColor.Warning' Tooltip='Warning' TooltipPosition='DwsTooltipPosition.Bottom' />
@* A Tab stop: the tooltip also opens on keyboard focus. *@
<DwsIcon Name='IconsDemo_IconFocusable' Icon='@Icons.BS.Keyboard' Color='@DwsColor.Success' Tooltip='Reachable with Tab' TooltipFocusable='true' />
@* For an action: the icon in a button, wrapped in a DwsTooltip. *@
<DwsTooltip Name='IconsDemo_IconTooltip' TooltipPosition='DwsTooltipPosition.Top'>
<ChildContent>
<DwsButton Name='IconsDemo_Icon14b' Appearance='DwsAppearance.Icon' Icon='@Icons.BS.QuestionCircle' Color='@DwsColor.Primary' Class='ms-2'
AdditionalAttributes='@(new Dictionary<string, object> { ["aria-label"] = "Help" })' />
</ChildContent>
<TooltipContent>Help: hover, focus or tap the button to read this.</TooltipContent>
</DwsTooltip>Animations
The available icon animations
Show Code
Icon.razor
<DwsVertical Name='IconsDemo_AnimationSection' Style='padding: 5px; row-gap: 25px;'>
<DwsHorizontal Name='IconsDemo_Horizontal_Spin'>
<DwsLabel Name='IconsDemo_Label_Spin' Text='Spin'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon17' Icon='@Icons.Solid.ArrowDown' Color='@DwsColor.Primary' Animation='DwsAnimationType.Spin' Size='@DwsSize.Large' />
</DwsHorizontal>
<DwsHorizontal Name='IconsDemo_Horizontal_Bounce'>
<DwsLabel Name='IconsDemo_Label_Bounce' Text='Bounce'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon18' Icon='@Icons.Solid.Bell' Color='@DwsColor.Secondary' Animation='DwsAnimationType.Bounce' Size='@DwsSize.Large' />
</DwsHorizontal>
<DwsHorizontal Name='IconsDemo_Horizontal_Flash'>
<DwsLabel Name='IconsDemo_Label_Flash' Text='Flash'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon19' Icon='@Icons.Solid.Star' Color='@DwsColor.Success' Animation='DwsAnimationType.Flash' Size='@DwsSize.Large' />
</DwsHorizontal>
<DwsHorizontal Name='IconsDemo_Horizontal_Pulse'>
<DwsLabel Name='IconsDemo_Label_Pulse' Text='Pulse'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon20' Icon='@Icons.Solid.Heart' Color='@DwsColor.Error' Animation='DwsAnimationType.Pulse' Size='@DwsSize.Large' />
</DwsHorizontal>
<DwsHorizontal Name='IconsDemo_Horizontal_Shake'>
<DwsLabel Name='IconsDemo_Label_Shake' Text='Shake'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon21' Icon='@Icons.Solid.BellConcierge' Color='@DwsColor.Warning' Animation='DwsAnimationType.Shake' Size='@DwsSize.Large' />
</DwsHorizontal>
<DwsHorizontal Name='IconsDemo_Horizontal_Swing'>
<DwsLabel Name='IconsDemo_Label_Swing' Text='Swing'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon22' Icon='@Icons.Solid.Star' Color='@DwsColor.Info' Animation='DwsAnimationType.Swing' Size='@DwsSize.Large' />
</DwsHorizontal>
<DwsHorizontal Name='IconsDemo_Horizontal_FlipAnimation' Style='column-gap: 16px;'>
<DwsLabel Name='IconsDemo_Label_Flip' Text='Flip'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon23' Width='25' Height='25' Icon='/images/blackhole_black.png' Type='DwsIconType.Image' Color='@DwsColor.Info' Animation='DwsAnimationType.Flip' Size='@DwsSize.Large' />
</DwsHorizontal>
</DwsVertical>Animation speed
AnimationSpeed sets how fast an animation runs
Show Code
Icon.razor
<DwsVertical Name='IconsDemo_AnimationSpeedSection' Style='padding: 5px; row-gap: 25px;'>
<DwsHorizontal Name='IconsDemo_Horizontal_Slow'>
<DwsLabel Name='IconsDemo_Label_Slow' Text='Slow'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon24' Icon='@Icons.Solid.ArrowDown' Color='@DwsColor.Primary' Animation='DwsAnimationType.Spin' AnimationSpeed='2' Size='@DwsSize.Large' />
</DwsHorizontal>
<DwsHorizontal Name='IconsDemo_Horizontal_Normal'>
<DwsLabel Name='IconsDemo_Label_Normal' Text='Normal'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon25' Icon='@Icons.Solid.ArrowDown' Color='@DwsColor.Secondary' Animation='DwsAnimationType.Spin' AnimationSpeed='1' Size='@DwsSize.Large' />
</DwsHorizontal>
<DwsHorizontal Name='IconsDemo_Horizontal_Fast'>
<DwsLabel Name='IconsDemo_Label_Fast' Text='Fast'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon26' Icon='@Icons.Solid.ArrowDown' Color='@DwsColor.Success' Animation='DwsAnimationType.Spin' AnimationSpeed='0.5' Size='@DwsSize.Large' />
</DwsHorizontal>
</DwsVertical>Background badge
Appearance Filled or Outline puts a badge behind the icon; Shape makes it round or square.
Show Code
Icon.razor
<DwsHorizontal Name='IconsDemo_Horizontal_Appearance' Style='column-gap: 16px;'>
<DwsIcon Name='IconsDemo_Icon27' Icon='@Icons.Solid.Bell' Color='@DwsColor.Primary' Appearance='DwsAppearance.Filled' Shape='DwsShape.Round' Size='@DwsSize.Large' />
<DwsIcon Name='IconsDemo_Icon28' Icon='@Icons.Solid.Heart' Color='@DwsColor.Error' Appearance='DwsAppearance.Filled' Shape='DwsShape.Square' Size='@DwsSize.Large' />
<DwsIcon Name='IconsDemo_Icon29' Icon='@Icons.Solid.Star' Color='@DwsColor.Warning' Appearance='DwsAppearance.Outline' Shape='DwsShape.Round' Size='@DwsSize.Large' />
</DwsHorizontal>Flipping
FlipMode mirrors the icon horizontally, vertically or both; the first icon is not flipped.
Show Code
Icon.razor
<DwsHorizontal Name='IconsDemo_Horizontal_Flip' Style='column-gap: 16px;'>
<DwsIcon Name='IconsDemo_Icon30' Icon='@Icons.Solid.HandPointRight' Color='@DwsColor.Primary' Size='@DwsSize.Large' />
<DwsIcon Name='IconsDemo_Icon31' Icon='@Icons.Solid.HandPointRight' Color='@DwsColor.Primary' FlipMode='DwsFlipMode.Horizontal' Size='@DwsSize.Large' />
<DwsIcon Name='IconsDemo_Icon32' Icon='@Icons.Solid.HandPointRight' Color='@DwsColor.Primary' FlipMode='DwsFlipMode.Vertical' Size='@DwsSize.Large' />
<DwsIcon Name='IconsDemo_Icon33' Icon='@Icons.Solid.HandPointRight' Color='@DwsColor.Primary' FlipMode='DwsFlipMode.Both' Size='@DwsSize.Large' />
</DwsHorizontal>Animate on hover
AnimationPlayType decides when the animation may play: OnHover plays it only while the pointer is on the icon.
Show Code
Icon.razor
<DwsHorizontal Name='IconsDemo_Horizontal_AnimOnHover'>
<DwsLabel Name='IconsDemo_Label_AnimOnHover' Text='Animate only on hover'></DwsLabel>
<DwsIcon Name='IconsDemo_Icon35' Icon='@Icons.Solid.Bell' Color='@DwsColor.Secondary' Size='@DwsSize.Large'
Animation='DwsAnimationType.Shake'
AnimationPlayType='DwsIconAnimationPlayType.OnHover' />
</DwsHorizontal>Interface-Description
| Name | Typ | Default | Description |
|---|---|---|---|
| Icon | string | Specifies the icon to be displayed. | |
| AriaLabel | string? | null | Accessible name of the icon. An icon without AriaLabel, Tooltip or a click handler is decoration: hidden from assistive technology (aria-hidden), as an icon next to text should be. |
| OnClickPropagation | bool | false | Whether a click the icon handles (OnClick bound) also reaches the elements around it. A decorative icon handles no click, so its clicks always reach the parent. |
| OnClickPreventDefault | bool | false | Cancels the browser's default action of a click on the icon. |
| Type | DwsIconType | DwsIconType.Font | Defines the type of icon: Font (Icon is a CSS class), Svg (Icon is the URL of an SVG file, placed inline - see InlineSvg) or Image (Icon is an image URL). |
| InlineSvg | bool | true | Type=Svg only. The SVG file is fetched once per URL, sanitised (scripts, event-handler attributes, foreignObject, external references and javascript: links are removed; ids are made unique per icon) and placed inline: currentColor follows Color and the theme, and without Width / Height the icon is 1em square. An Icon of the form sprite.svg#name is one symbol of a sprite sheet: the browser draws it through <use> (same-origin sheets only), nothing is fetched by script and InlineSvg does not apply. A style element in the file is kept, with its rules scoped to this icon and everything that could load something removed. On Blazor Server a file over about 24 KB is fetched as a stream. A file that cannot be inlined (cross-origin without CORS, not found, not well-formed, over 512 000 characters, a style sheet with backslash escapes) is shown through an object element instead, as with false. |
| Color | DwsColor | DwsColor.Text | Sets the color of the icon. |
| Size | DwsSize | DwsSize.Medium | Specifies the size of the icon. |
| Tooltip | string | Text shown in a DwsTooltip next to the icon: on hover, on a long press (touch) and - when the icon can be focused - on keyboard focus; Escape closes it. Without AriaLabel it is also the icon's accessible name. (Until batch 35 this was the native title attribute.) | |
| TooltipPosition | DwsTooltipPosition | DwsTooltipPosition.Top | The side of the icon the tooltip prefers; it moves to another side when it does not fit there. |
| TooltipFocusable | bool | false | Makes an icon with a Tooltip a Tab stop, so the tooltip opens on keyboard focus. Off by default because it adds a stop to the page's Tab order. |
| Width | int? | null | Defines the width of the icon. |
| MinWidth | int? | null | Sets the minimum width of the icon. |
| MaxWidth | int? | null | Sets the maximum width of the icon. |
| Height | int? | null | Defines the height of the icon. |
| MinHeight | int? | null | Sets the minimum height of the icon. |
| MaxHeight | int? | null | Sets the maximum height of the icon. |
| Animation | DwsAnimationType | null | Specifies the animation type for the icon. |
| AnimationSpeed | double? | null | Sets the speed of the animation. |
| AnimationPlayType | DwsIconAnimationPlayType | DwsIconAnimationPlayType.Always | Determines when the configured animation is allowed to play (Always, OnHover, OnFocus, OnHoverFocus, None). |
| AnimationLoop | bool | true | When false, the animation runs a single iteration instead of looping indefinitely. |
| Appearance | DwsAppearance | DwsAppearance.None | Controls the filled/outline background badge behind the icon. |
| Shape | DwsShape | DwsShape.Round | Shape of the background badge when Appearance is not None. |
| FlipMode | DwsFlipMode | DwsFlipMode.None | Mirrors the icon horizontally, vertically, or both. |
| OnHoverEffect | bool | false | Feature flag that enables the built-in subtle hover scale/opacity effect. |
| OnHoverCss | string? | null | Optional raw inline CSS applied only while the pointer is hovering the icon. |
| OnClick | EventCallback<MouseEventArgs> | Raised when the icon is clicked. | |
| OnDblClick | EventCallback<MouseEventArgs> | Raised when the icon is double-clicked. | |
| OnHover | EventCallback<MouseEventArgs> | Raised when the pointer enters the icon. | |
| OnFocus | EventCallback<FocusEventArgs> | Raised when the icon receives focus. |
| 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. |
