Chip Customization

17 Feb 20229 minutes to read

This section explains the customization of styles, leading icons, avatar, and trailing icons in Chip control.

Styles

The Chip control has the following predefined styles that can be defined using the cssClass property.

Class Description
e-primary Represents a primary chip.
e-success Represents a positive chip.
e-info Represents an informative chip.
e-warning Represents a chip with caution.
e-danger Represents a negative chip.
@Html.EJS().ChipList("chip-avatar").EnableDelete(true).Chips(chip =>
                        {
                            chip.Text("Primary").CssClass("e-primary").Enabled(true).Add();
                            chip.Text("Success").CssClass("e-success").Enabled(true).Add();
                            chip.Text("Info").CssClass("e-info").Enabled(true).Add();
                            chip.Text("Warning").CssClass("e-warning").Enabled(true).Add();
                            chip.Text("Danger").CssClass("e-danger").Enabled(true).Add();
                        }).Render()
public IActionResult Index()
    {
            return View();
    }

Leading Icon

You can add and customize the leading icon of chip using the leadingIconCss property.

@Html.EJS().ChipList("chip-avatar").Chips(chip =>
                        {
                            chip.Text("Andrew").LeadingIconCss("andrew").Enabled(true).Add();
                            chip.Text("Janet").LeadingIconCss("janet").Enabled(true).Add();
                            chip.Text("Laura").LeadingIconCss("laura").Enabled(true).Add();
                            chip.Text("Margaret").LeadingIconCss("margaret").Enabled(true).Add();
                        }).Render()

<style>
  #chip-avatar .andrew {
    background-image: url('./andrew.png')
  }

  #chip-avatar .margaret {
    background-image: url('./margaret.png')
  }

  #chip-avatar .laura {
    background-image: url('./laura.png')
  }

  #chip-avatar .janet {
    background-image: url('./janet.png')
  }
</style>
public IActionResult Index()
    {
            return View();
    }

Avatar

You can add and customize the avatar of chip using the avatarIconCss property.

@Html.EJS().ChipList("chip-avatar").Chips(chip =>
                        {
                            chip.Text("Andrew").AvatarIconCss("andrew").Enabled(true).Add();
                            chip.Text("Janet").AvatarIconCss("janet").Enabled(true).Add();
                            chip.Text("Laura").AvatarIconCss("laura").Enabled(true).Add();
                            chip.Text("Margaret").AvatarIconCss("margaret").Enabled(true).Add();
                        }).Render()

<style>
  #chip-avatar .andrew {
    background-image: url('./andrew.png')
  }

  #chip-avatar .margaret {
    background-image: url('./margaret.png')
  }

  #chip-avatar .laura {
    background-image: url('./laura.png')
  }

  #chip-avatar .janet {
    background-image: url('./janet.png')
  }
</style>
public IActionResult Index()
    {
            return View();
    }

Avatar Content

You can add and customize the avatar content of chip using the avatarText property.

@Html.EJS().ChipList("chip-avatar").Chips(chip =>
                        {
                            chip.Text("Andrew").AvatarText("A").Enabled(true).Add();
                            chip.Text("Janet").AvatarText("J").Enabled(true).Add();
                            chip.Text("Laura").AvatarText("L").Enabled(true).Add();
                            chip.Text("Margaret").AvatarText("M").Enabled(true).Add();
                        }).Render()
public IActionResult Index()
    {
            return View();
    }

Trailing Icon

You can add and customize the trailing icon of chip using the trailingIconCss property.

@Html.EJS().ChipList("chip-avatar").Chips(chip =>
                        {
                            chip.Text("Andrew").TrailingIconCss("e-dlt-btn").Enabled(true).Add();
                            chip.Text("Janet").TrailingIconCss("e-dlt-btn").Enabled(true).Add();
                            chip.Text("Laura").TrailingIconCss("e-dlt-btn").Enabled(true).Add();
                            chip.Text("Margaret").TrailingIconCss("e-dlt-btn").Enabled(true).Add();
                        }).Render()
public IActionResult Index()
    {
            return View();
    }

Outline Chip

Outline chip has the border with the background transparent. It can be set using the cssClass property.

<div>
@Html.EJS().ChipList("chip-avatar").CssClass("e-outline").Chips(chip =>
                        {
                            chip.Text("Chai").Enabled(true).Add();
                            chip.Text("Chung").Enabled(true).Add();
                            chip.Text("Aniseed Syrup").Enabled(true).Add();
                            chip.Text("Ikura").Enabled(true).Add();
                        }).Render()

@Html.EJS().ChipList("chip-avatar").CssClass("e-outline").EnableDelete(true).Chips(chip =>
                        {
                            chip.Text("Andrew").Enabled(true).Add();
                            chip.Text("Janet").Enabled(true).Add();
                            chip.Text("Laura").Enabled(true).Add();
                            chip.Text("Margaret").Enabled(true).Add();
                        }).Render()                        
</div>
public IActionResult Index()
    {
            return View();
    }