Class MudChip<T>
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
Represents a compact element used to enter information, select a choice, filter content, or trigger an action.
public class MudChip<T> : MudComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged, IAsyncDisposable
Type Parameters
T
The type of item managed by this component.
- Inheritance
-
MudChip<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
MudChip()
public MudChip()
Properties
AvatarContent
The avatar content to display inside the chip.
[Parameter]
[Category("Appearance")]
public RenderFragment? AvatarContent { get; set; }
Property Value
CheckedIcon
The icon to display when Selected is true
.
[Parameter]
[Category("Appearance")]
public string? CheckedIcon { get; set; }
Property Value
Remarks
Defaults to null
.
ChildContent
The content within this chip.
[Parameter]
[Category("Behavior")]
public RenderFragment? ChildContent { get; set; }
Property Value
Classname
protected string Classname { get; }
Property Value
CloseIcon
The close icon to display when OnClose is set.
[Parameter]
[Category("Appearance")]
public string? CloseIcon { get; set; }
Property Value
Color
The color of this chip.
[Parameter]
[Category("Appearance")]
public Color? Color { get; set; }
Property Value
Remarks
Defaults to null
. When SelectedColor is set, this color is used when the chip is unselected.
Default
Selects this chip by default when part of a MudChipSet<T>.
[Parameter]
[Category("Behavior")]
public bool? Default { get; set; }
Property Value
- bool?
Remarks
Defaults to null
.
Disabled
Prevents the user from interacting with this chip.
[Parameter]
[Category("Behavior")]
public bool Disabled { get; set; }
Property Value
Remarks
Defaults to false
. When true
, the chip is visibly disabled and interaction is not allowed.
Href
The URL to navigate to when the chip is clicked.
[Parameter]
[Category("Click action")]
public string? Href { get; set; }
Property Value
Remarks
Defaults to null
. Use Target to control where the URL is opened.
Note: The close button cannot be enabled if this is set because interactive content violates the HTML spec.
Icon
The icon to display within the chip.
[Parameter]
[Category("Behavior")]
public string? Icon { get; set; }
Property Value
Remarks
Defaults to null
. Use the IconColor to control the color of this icon.
IconColor
The color of the Icon.
[Parameter]
[Category("Appearance")]
public Color? IconColor { get; set; }
Property Value
Remarks
Defaults to null
.
JsApiService
The service used to perform browser actions such as navigation.
[Inject]
public IJsApiService? JsApiService { get; set; }
Property Value
Label
Uses the theme border radius for chip edges.
[Parameter]
[Category("Appearance")]
public bool? Label { get; set; }
Property Value
- bool?
Remarks
Defaults to null
. When true
, the DefaultBorderRadius is used for chip edges.
OnClick
Occurs when this chip is clicked.
[Parameter]
public EventCallback<MouseEventArgs> OnClick { get; set; }
Property Value
Remarks
If an Href is set, this callback will not be triggered and the browser will handle the click.
OnClose
Occurs when this chip has been closed.
[Parameter]
public EventCallback<MudChip<T>> OnClose { get; set; }
Property Value
- EventCallback<MudChip<T>>
Remarks
Subscribing to this event enables the close button, unless Href is also set.
Rel
The relationship between the current document and the linked document when Href is set.
[Parameter]
[Category("Click action")]
public string? Rel { get; set; }
Property Value
Remarks
This property is typically used by web crawlers to get more information about a link. Common values can be found here: https://www.w3schools.com/tags/att_a_rel.asp
Ripple
Displays a ripple effect when this chip is clicked.
[Parameter]
[Category("Appearance")]
public bool? Ripple { get; set; }
Property Value
- bool?
Remarks
Defaults to null
.
Selected
Selects this chip.
[Parameter]
[Category("Behavior")]
public bool Selected { get; set; }
Property Value
Remarks
When true
, the chip is displayed in a selected state.
SelectedChanged
Occurs when the Selected property has changed.
[Parameter]
public EventCallback<bool> SelectedChanged { get; set; }
Property Value
SelectedColor
The color of the chip when it is selected.
[Parameter]
[Category("Appearance")]
public Color? SelectedColor { get; set; }
Property Value
Remarks
Defaults to null
. When set, this color is used for a selected chip, otherwise Color is used.
Size
The size of the chip.
[Parameter]
[Category("Appearance")]
public Size? Size { get; set; }
Property Value
- Size?
Remarks
Defaults to null
.
Target
The target to open URLs if Href is set.
[Parameter]
[Category("Click action")]
public string? Target { get; set; }
Property Value
Remarks
Defaults to null
. This value is typically _blank
, _self
, _parent
, _top
, or the name of an iframe
.
Text
The text label for the chip.
[Parameter]
[Category("Behavior")]
public string? Text { get; set; }
Property Value
Remarks
Defaults to null
. This will be shown so long as ChildContent is not set.
UriHelper
The service used to navigate the browser to another URL.
[Inject]
public NavigationManager? UriHelper { get; set; }
Property Value
Value
The value applied when the chip is selected.
[Parameter]
[Category("Behavior")]
public T? Value { get; set; }
Property Value
- T
Remarks
When part of a MudChipSet<T>, the SelectedValue is set to this value when the chip is selected. Once set, the value should not change.
Variant
The display variation to use.
[Parameter]
[Category("Appearance")]
public Variant? Variant { get; set; }
Property Value
Remarks
Defaults to null
.
Methods
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
RenderTreeBuilder
DisposeAsync()
Releases unused resources.
public ValueTask DisposeAsync()
Returns
GetAttributes()
protected Dictionary<string, object?> GetAttributes()
Returns
GetHtmlTag()
protected string GetHtmlTag()
Returns
OnAfterRenderAsync(bool)
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
firstRender
bool
Returns
OnClickAsync(MouseEventArgs)
protected Task OnClickAsync(MouseEventArgs ev)
Parameters
Returns
OnCloseAsync(MouseEventArgs)
protected Task OnCloseAsync(MouseEventArgs ev)
Parameters
Returns
OnInitializedAsync()
protected override Task OnInitializedAsync()