Class SfChip
The SfChip component displays a list of chip each of which contains a block of essential information that triggers an event on click action.
Inherited Members
Namespace: Syncfusion.Blazor.Buttons
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfChip : SfBaseComponent
Constructors
SfChip()
Declaration
public SfChip()
Properties
Chips
This chips property helps to render chipitem component.
Declaration
public List<ChipItem> Chips { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<ChipItem> | Accepts the list of chip items. Each chip item should contain a text value. |
CssClass
Specifies the custom classes to be added to the chip element used to customize the chip component.
Declaration
public string CssClass { get; set; }
Property Value
Type | Description |
---|---|
System.String | Accepts the CSS class string separated by space to customize the appearance of component. The default value is empty. |
Enabled
This enabled property helps to enable/disable chipitem component.
Declaration
public bool Enabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnableDelete
This enableDelete property helps to enable delete functionality.
Declaration
public bool EnableDelete { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
EnableRtl
Enable or disable rendering component in right to left direction.
Declaration
public bool EnableRtl { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
HtmlAttributes
You can add the additional html attributes such as title, native events etc., to the wrapper element.
Declaration
public Dictionary<string, object> HtmlAttributes { get; set; }
Property Value
Type |
---|
System.Collections.Generic.Dictionary<System.String, System.Object> |
SelectedChips
This selectedChips property helps to select chip items.
Declaration
public string[] SelectedChips { get; set; }
Property Value
Type | Description |
---|---|
System.String[] | Accepts the list of string (chip's text) to select items in chips. The default value is an empty array. |
SelectedChipsChanged
Specifies the callback to trigger when the selected chips changes.
Declaration
public EventCallback<string[]> SelectedChipsChanged { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.EventCallback<System.String[]> | An event callback function. |
Remarks
You can get the updated SelectedChips value.
Examples
In the below code example, the SelectedChips value can be obtained from the SelectedChipsChanged
event.
<SfChip Selection="SelectionType.Multiple" SelectedChipsChanged="SelectedChipsChanged">
<ChipItems>
<ChipItem Text = "Small"></ChipItem>
<ChipItem Text = "Medium"></ChipItem>
<ChipItem Text = "Large"></ChipItem>
<ChipItem Text = "Extra Large"></ChipItem>
</ChipItems>
</SfChip>
@code {
private void SelectedChipsChanged(string[] args) {
string[] selectedChipItem = args;
}
}
Selection
This selection property enables chip selection type.
Declaration
public SelectionType Selection { get; set; }
Property Value
Type | Description |
---|---|
SelectionType | One of the SelectionType enumeration that specifies the selection of chip items in selection mode. The default value is None. |
Methods
AddChip(ChipItem)
A function that adds chip items based on given input.
Declaration
public void AddChip(ChipItem item)
Parameters
Type | Name | Description |
---|---|---|
ChipItem | item | Chip Item to be added should be passed. |
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder | __builder |
FindChip(String)
A function that finds chip based on given chip value.
Declaration
public ChipItem FindChip(string chipValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | chipValue | Value of the chip need to be passed to get the corresponding chip model. |
Returns
Type | Description |
---|---|
ChipItem | GetItem. |
GetSelectedChips()
A function that returns selected chips data.
Declaration
public List<ChipItem> GetSelectedChips()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<ChipItem> | selectedChipModels. |
OnAfterRenderAsync(Boolean)
Method invoked after each time the component has been rendered.
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender | Set to true for the first time component rendering; otherwise gets false. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | ="Task". |
Overrides
OnInitializedAsync()
Method gets invoked when the component is ready to start.
Declaration
protected override Task OnInitializedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | ="Task". |
Overrides
RemoveChips(String[])
A function that removes chip items based on given chip values.
Declaration
public void RemoveChips(string[] removableChipValues)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | removableChipValues | Values of the chips which are to be removed should be passed. |
SelectChips(String[])
A function that selects chip items based on given index.
Declaration
public void SelectChips(string[] selectableChips)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | selectableChips | Values of the chips which are to be selected should be passed. |
UpdateAttributes()
Updates the class and multiselection attributes of the chip root element.
Declaration
protected void UpdateAttributes()
UpdateAttributes(Dictionary<String, Object>)
Updates the attributes value.
Declaration
protected void UpdateAttributes(Dictionary<string, object> htmlAttributes = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> | htmlAttributes | The htmlAttributes. |