Customization in Vue Chips component
18 Dec 202422 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. |
<template>
<ejs-chiplist id="chip" enableDelete="true">
<e-chips>
<e-chip text="Primary" cssClass="e-primary"></e-chip>
<e-chip text="Success" cssClass="e-success"></e-chip>
<e-chip text="Info" cssClass="e-info"></e-chip>
<e-chip text="Warning" cssClass="e-warning"></e-chip>
<e-chip text="Danger" cssClass="e-danger"></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script setup>
import { ChipListComponent as EjsChiplist, ChipsDirective as EChips, ChipDirective as EChip } from '@syncfusion/ej2-vue-buttons';
</script>
<template>
<ejs-chiplist id="chip" enableDelete="true">
<e-chips>
<e-chip text="Primary" cssClass="e-primary"></e-chip>
<e-chip text="Success" cssClass="e-success"></e-chip>
<e-chip text="Info" cssClass="e-info"></e-chip>
<e-chip text="Warning" cssClass="e-warning"></e-chip>
<e-chip text="Danger" cssClass="e-danger"></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script>
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-vue-buttons';
export default {
name: "App",
components: {
"ejs-chiplist":ChipListComponent,
"e-chips":ChipsDirective,
"e-chip":ChipDirective
}
}
</script>
Leading Icon
You can add and customize the leading icon of chip using the leadingIconCss
property.
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip text="Andrew" leadingIconCss='andrew'></e-chip>
<e-chip text="Janet" leadingIconCss='janet'></e-chip>
<e-chip text="Laura" leadingIconCss='laura'></e-chip>
<e-chip text="Margaret" leadingIconCss='margaret'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script setup>
import { ChipListComponent as EjsChiplist, ChipsDirective as EChips, ChipDirective as EChip } from '@syncfusion/ej2-vue-buttons';
</script>
<style>
#chip .andrew {
background-image: url('./andrew.png')
}
#chip .margaret {
background-image: url('./margaret.png')
}
#chip .laura {
background-image: url('./laura.png')
}
#chip .janet {
background-image: url('./janet.png')
}
</style>
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip text="Andrew" leadingIconCss='andrew'></e-chip>
<e-chip text="Janet" leadingIconCss='janet'></e-chip>
<e-chip text="Laura" leadingIconCss='laura'></e-chip>
<e-chip text="Margaret" leadingIconCss='margaret'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script>
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-vue-buttons';
export default {
name: "App",
components: {
"ejs-chiplist":ChipListComponent,
"e-chips":ChipsDirective,
"e-chip":ChipDirective
}
}
</script>
<style>
#chip .andrew {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/andrew.png');
}
#chip .margaret {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/margaret.png');
}
#chip .laura {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/laura.png');
}
#chip .janet {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/janet.png');
}
</style>
Avatar
You can add and customize the avatar of chip using the avatarIconCss
property.
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip text="Andrew" avatarIconCss='andrew'></e-chip>
<e-chip text="Janet" avatarIconCss='janet'></e-chip>
<e-chip text="Laura" avatarIconCss='laura'></e-chip>
<e-chip text="Margaret" avatarIconCss='margaret'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script setup>
import { ChipListComponent as EjsChiplist, ChipsDirective as EChips, ChipDirective as EChip } from '@syncfusion/ej2-vue-buttons';
</script>
<style>
#chip .andrew {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/andrew.png')
}
#chip .margaret {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/margaret.png')
}
#chip .laura {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/laura.png')
}
#chip .janet {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/janet.png')
}
</style>
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip text="Andrew" avatarIconCss='andrew'></e-chip>
<e-chip text="Janet" avatarIconCss='janet'></e-chip>
<e-chip text="Laura" avatarIconCss='laura'></e-chip>
<e-chip text="Margaret" avatarIconCss='margaret'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script>
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-vue-buttons';
export default {
name: "App",
components: {
"ejs-chiplist":ChipListComponent,
"e-chips":ChipsDirective,
"e-chip":ChipDirective
}
}
</script>
<style>
#chip .andrew {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/andrew.png')
}
#chip .margaret {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/margaret.png')
}
#chip .laura {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/laura.png')
}
#chip .janet {
background-image: url('https://ej2.syncfusion.com/demos/src/chips/images/janet.png')
}
</style>
Avatar Content
You can add and customize the avatar content of chip using the avatarText
property.
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip text="Andrew" avatarText= 'A'></e-chip>
<e-chip text="Janet" avatarText= 'J'></e-chip>
<e-chip text="Laura" avatarText= 'L'></e-chip>
<e-chip text="Margaret" avatarText= 'M'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script setup>
import { ChipListComponent as EjsChiplist, ChipsDirective as EChips, ChipDirective as EChip } from '@syncfusion/ej2-vue-buttons';
</script>
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip text="Andrew" avatarText= 'A'></e-chip>
<e-chip text="Janet" avatarText= 'J'></e-chip>
<e-chip text="Laura" avatarText= 'L'></e-chip>
<e-chip text="Margaret" avatarText= 'M'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script>
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-vue-buttons';
export default {
name: "App",
components: {
"ejs-chiplist":ChipListComponent,
"e-chips":ChipsDirective,
"e-chip":ChipDirective
}
}
</script>
Trailing Icon
You can add and customize the trailing icon of chip using the trailingIconCss
property.
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip text="Andrew" trailingIconCss= 'e-dlt-btn'></e-chip>
<e-chip text="Janet" trailingIconCss= 'e-dlt-btn'></e-chip>
<e-chip text="Laura" trailingIconCss= 'e-dlt-btn'></e-chip>
<e-chip text="Margaret" trailingIconCss= 'e-dlt-btn'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script setup>
import { ChipListComponent as EjsChiplist, ChipsDirective as EChips, ChipDirective as EChip } from '@syncfusion/ej2-vue-buttons';
</script>
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip text="Andrew" trailingIconCss= 'e-dlt-btn'></e-chip>
<e-chip text="Janet" trailingIconCss= 'e-dlt-btn'></e-chip>
<e-chip text="Laura" trailingIconCss= 'e-dlt-btn'></e-chip>
<e-chip text="Margaret" trailingIconCss= 'e-dlt-btn'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script>
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-vue-buttons';
export default {
name: "App",
components: {
"ejs-chiplist":ChipListComponent,
"e-chips":ChipsDirective,
"e-chip":ChipDirective
}
}
</script>
Outline Chip
Outline chip has the border with the background transparent. It can be set using the cssClass
property.
<template>
<div>
<ejs-chiplist id="chip" cssClass="e-outline">
<e-chips>
<e-chip text="Chai"></e-chip>
<e-chip text="Chang"></e-chip>
<e-chip text="Aniseed Syrup"></e-chip>
<e-chip text="Ikura"></e-chip>
</e-chips>
</ejs-chiplist>
<ejs-chiplist id="chip" cssClass="e-outline" enableDelete="true">
<e-chips>
<e-chip text="Andrew"></e-chip>
<e-chip text="Janet"></e-chip>
<e-chip text="Laura"></e-chip>
<e-chip text="Margaret"></e-chip>
</e-chips>
</ejs-chiplist>
</div>
</template>
<script setup>
import { ChipListComponent as EjsChiplist, ChipsDirective as EChips, ChipDirective as EChip } from '@syncfusion/ej2-vue-buttons';
</script>
<template>
<div>
<ejs-chiplist id="chip" cssClass="e-outline">
<e-chips>
<e-chip text="Chai"></e-chip>
<e-chip text="Chang"></e-chip>
<e-chip text="Aniseed Syrup"></e-chip>
<e-chip text="Ikura"></e-chip>
</e-chips>
</ejs-chiplist>
<ejs-chiplist id="chip" cssClass="e-outline" enableDelete="true">
<e-chips>
<e-chip text="Andrew"></e-chip>
<e-chip text="Janet"></e-chip>
<e-chip text="Laura"></e-chip>
<e-chip text="Margaret"></e-chip>
</e-chips>
</ejs-chiplist>
</div>
</template>
<script>
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-vue-buttons';
export default {
name: "App",
components: {
"ejs-chiplist":ChipListComponent,
"e-chips":ChipsDirective,
"e-chip":ChipDirective
}
}
</script>
Template
The template
property of the Chips component allows users to fully customize the layout and design of each chip. By using the template
property, users can include custom HTML elements, such as links, icons, or additional content.
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip leadingIconCss="trendingIcon"
template='<a href="https://timesofindia.indiatimes.com/news" target="_blank" class="anchorElement">#BreakingNews</a><span class="textElement">125k posts</span>'></e-chip>
<e-chip leadingIconCss="cameraIcon"
template='<a href="https://blog.google/products/photos/" target="_blank" class="anchorElement">#PhotoOfTheDay</a>'></e-chip>
<e-chip leadingIconCss="trendingIcon"
template='<a href="https://indianexpress.com/section/technology/" target="_blank" class="anchorElement">#TechNews</a><span class="textElement">107k posts</span>'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script setup>
import { ChipListComponent as EjsChiplist, ChipsDirective as EChips, ChipDirective as EChip } from '@syncfusion/ej2-vue-buttons';
</script>
<style>
#chip .e-chip .trendingIcon {
margin: 4px 0 4px 6px;
width: 16px;
height: 16px;
background-image: url('data:image/svg+xml;utf8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iNDgiIHdpZHRoPSI0OCI+PHBhdGggZD0ibTMyIDEyIDQuNTkgNC41OS05Ljc2IDkuNzUtOC04TDQgMzMuMTcgNi44MyAzNmwxMi0xMiA4IDggMTIuNTgtMTIuNTlMNDQgMjRWMTJ6Ii8+PHBhdGggZD0iTTAgMGg0OHY0OEgweiIgZmlsbD0ibm9uZSIvPjwvc3ZnPg==');
}
#chip .e-chip .cameraIcon {
margin: 4px 0 4px 6px;
width: 16px;
height: 16px;
background-image: url('data:image/svg+xml;utf8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTE5LDYuNUgxNy43MmwtLjMyLTFhMywzLDAsMCwwLTIuODQtMkg5LjQ0QTMsMywwLDAsMCw2LjYsNS41NWwtLjMyLDFINWEzLDMsMCwwLDAtMywzdjhhMywzLDAsMCwwLDMsM0gxOWEzLDMsMCwwLDAsMy0zdi04QTMsMywwLDAsMCwxOSw2LjVabTEsMTFhMSwxLDAsMCwxLTEsMUg1YTEsMSwwLDAsMS0xLTF2LThhMSwxLDAsMCwxLDEtMUg3YTEsMSwwLDAsMCwxLS42OGwuNTQtMS42NGExLDEsMCwwLDEsLjk1LS42OGg1LjEyYTEsMSwwLDAsMSwuOTUuNjhsLjU0LDEuNjRBMSwxLDAsMCwwLDE3LDguNWgyYTEsMSwwLDAsMSwxLDFabS04LTlhNCw0LDAsMSwwLDQsNEE0LDQsMCwwLDAsMTIsOC41Wm0wLDZhMiwyLDAsMSwxLDItMkEyLDIsMCwwLDEsMTIsMTQuNVoiLz48L3N2Zz4=');
}
#chip .e-chip .anchorElement {
margin: 0 4px;
font-weight: 600;
height: 16px;
line-height: 16px;
font-size: 12px;
color: #0f6cbd;
text-decoration: none;
}
#chip .e-chip .textElement {
font-weight: 400;
height: 14px;
line-height: 14px;
font-size: 10px;
margin-right: 6px;
}
</style>
<template>
<ejs-chiplist id="chip">
<e-chips>
<e-chip leadingIconCss="trendingIcon"
template='<a href="https://timesofindia.indiatimes.com/news" target="_blank" class="anchorElement">#BreakingNews</a><span class="textElement">125k posts</span>'></e-chip>
<e-chip leadingIconCss="cameraIcon"
template='<a href="https://blog.google/products/photos/" target="_blank" class="anchorElement">#PhotoOfTheDay</a>'></e-chip>
<e-chip leadingIconCss="trendingIcon"
template='<a href="https://indianexpress.com/section/technology/" target="_blank" class="anchorElement">#TechNews</a><span class="textElement">107k posts</span>'></e-chip>
</e-chips>
</ejs-chiplist>
</template>
<script>
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-vue-buttons';
export default {
name: "App",
components: {
"ejs-chiplist":ChipListComponent,
"e-chips":ChipsDirective,
"e-chip":ChipDirective
}
}
</script>
<style>
#chip .e-chip .trendingIcon {
margin: 4px 0 4px 6px;
width: 16px;
height: 16px;
background-image: url('data:image/svg+xml;utf8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iNDgiIHdpZHRoPSI0OCI+PHBhdGggZD0ibTMyIDEyIDQuNTkgNC41OS05Ljc2IDkuNzUtOC04TDQgMzMuMTcgNi44MyAzNmwxMi0xMiA4IDggMTIuNTgtMTIuNTlMNDQgMjRWMTJ6Ii8+PHBhdGggZD0iTTAgMGg0OHY0OEgweiIgZmlsbD0ibm9uZSIvPjwvc3ZnPg==');
}
#chip .e-chip .cameraIcon {
margin: 4px 0 4px 6px;
width: 16px;
height: 16px;
background-image: url('data:image/svg+xml;utf8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTE5LDYuNUgxNy43MmwtLjMyLTFhMywzLDAsMCwwLTIuODQtMkg5LjQ0QTMsMywwLDAsMCw2LjYsNS41NWwtLjMyLDFINWEzLDMsMCwwLDAtMywzdjhhMywzLDAsMCwwLDMsM0gxOWEzLDMsMCwwLDAsMy0zdi04QTMsMywwLDAsMCwxOSw2LjVabTEsMTFhMSwxLDAsMCwxLTEsMUg1YTEsMSwwLDAsMS0xLTF2LThhMSwxLDAsMCwxLDEtMUg3YTEsMSwwLDAsMCwxLS42OGwuNTQtMS42NGExLDEsMCwwLDEsLjk1LS42OGg1LjEyYTEsMSwwLDAsMSwuOTUuNjhsLjU0LDEuNjRBMSwxLDAsMCwwLDE3LDguNWgyYTEsMSwwLDAsMSwxLDFabS04LTlhNCw0LDAsMSwwLDQsNEE0LDQsMCwwLDAsMTIsOC41Wm0wLDZhMiwyLDAsMSwxLDItMkEyLDIsMCwwLDEsMTIsMTQuNVoiLz48L3N2Zz4=');
}
#chip .e-chip .anchorElement {
margin: 0 4px;
font-weight: 600;
height: 16px;
line-height: 16px;
font-size: 12px;
color: #0f6cbd;
text-decoration: none;
}
#chip .e-chip .textElement {
font-weight: 400;
height: 14px;
line-height: 14px;
font-size: 10px;
margin-right: 6px;
}
</style>