Class TwEmpty
- Namespace
- TwBlazor.Components
- Assembly
- TwBlazor.dll
Represents an empty state: a placeholder shown where there is no data or content yet, with an icon, a title, a description and optional actions that give the user a next step.
public class TwEmpty : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
- Inheritance
-
TwEmpty
- Implements
- Inherited Members
Remarks
The media is the first of these that is set: MediaContent, an avatar (AvatarSrc or AvatarName), then the Icon. Set Icon to null for an empty state with no media.
Accessibility: the icon or avatar is decorative and hidden from assistive technology. The title is a heading whose level is set with TitleLevel, so it fits the page's heading outline. Set Live when the empty state replaces results in response to the user, such as a search with no matches, so screen readers announce it.
Constructors
TwEmpty()
public TwEmpty()
Properties
ActionContent
Gets or sets custom actions, such as buttons, shown in the row of actions after any built-in ones.
[Parameter]
public RenderFragment? ActionContent { get; set; }
Property Value
ActionHref
Gets or sets the URL the primary action button links to. When set, the button renders as a link and OnAction is not invoked.
[Parameter]
public string? ActionHref { get; set; }
Property Value
ActionIcon
Gets or sets the icon shown at the start of the primary action button.
[Parameter]
public Icon? ActionIcon { get; set; }
Property Value
- Icon?
ActionText
Gets or sets the label of the built-in primary action button. The button is only shown when this is set.
[Parameter]
public string? ActionText { get; set; }
Property Value
AvatarName
Gets or sets the name of the person or entity shown in an avatar instead of the icon. It supplies the avatar's initials when there is no AvatarSrc.
[Parameter]
public string? AvatarName { get; set; }
Property Value
AvatarSrc
Gets or sets the URL of a picture shown in an avatar instead of the icon, for example when a person has no activity yet.
[Parameter]
public string? AvatarSrc { get; set; }
Property Value
ChildContent
Gets or sets extra content shown below the description, such as a search field or a help link.
[Parameter]
public RenderFragment? ChildContent { get; set; }
Property Value
Color
Gets or sets the color of the icon and its tile.
[Parameter]
public Color? Color { get; set; }
Property Value
Remarks
If not set, a neutral gray is used.
Description
Gets or sets the description shown below the title, such as why there is nothing here and what to do next.
[Parameter]
public string? Description { get; set; }
Property Value
Filled
Gets or sets whether the empty state has a subtle background.
[Parameter]
public bool Filled { get; set; }
Property Value
Icon
Gets or sets the icon shown above the title. Defaults to Inbox.
[Parameter]
public Icon? Icon { get; set; }
Property Value
- Icon?
Remarks
Set it to null to show no icon. Ignored when MediaContent or an avatar is set.
Live
Gets or sets whether the empty state is a live region (role="status"), so screen readers announce it
when it appears in response to the user, such as a search or filter that returns no results.
[Parameter]
public bool Live { get; set; }
Property Value
Remarks
Some screen readers only announce changes inside a live region that is already on the page, so a status that appears together with its text may not be read out. For the most reliable announcement, also update a persistent status message, such as a result count, when the results change.
MediaContent
Gets or sets custom media shown above the title instead of the icon or avatar, such as an illustration or a group of avatars.
[Parameter]
public RenderFragment? MediaContent { get; set; }
Property Value
MediaVariant
Gets or sets how the icon is shown: on a tinted tile or on its own. Defaults to Tile.
[Parameter]
public EmptyMediaVariant MediaVariant { get; set; }
Property Value
OnAction
Gets or sets the callback invoked when the primary action button is clicked. Not used when ActionHref is set.
[Parameter]
public EventCallback OnAction { get; set; }
Property Value
OnSecondaryAction
Gets or sets the callback invoked when the secondary action button is clicked. Not used when SecondaryActionHref is set.
[Parameter]
public EventCallback OnSecondaryAction { get; set; }
Property Value
Outlined
Gets or sets whether the empty state has a dashed border, marking out the area that has no content.
[Parameter]
public bool Outlined { get; set; }
Property Value
SecondaryActionHref
Gets or sets the URL the secondary action button links to. When set, the button renders as a link and OnSecondaryAction is not invoked.
[Parameter]
public string? SecondaryActionHref { get; set; }
Property Value
SecondaryActionText
Gets or sets the label of the built-in secondary action button, shown with an outline after the primary action. The button is only shown when this is set.
[Parameter]
public string? SecondaryActionText { get; set; }
Property Value
Size
Gets or sets the size: its padding, the size of the media and the size of the text. Defaults to Md.
[Parameter]
public Size Size { get; set; }
Property Value
Title
Gets or sets the title.
[Parameter]
public string? Title { get; set; }
Property Value
Remarks
If not set, the localized Empty_Title text ("No data") is shown. Set it to an empty string to show no title.
TitleLevel
Gets or sets the heading level (1 to 6) rendered for Title, so it fits the surrounding page's heading outline. Defaults to 3.
[Parameter]
public int TitleLevel { get; set; }
Property Value
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder