Types in Angular Chips component
18 Jan 20257 minutes to read
The Chips component has the following types:
- Input Chips
- Choice Chips
- Filter Chips
- Action Chips
Input Chips
Input Chips holds information in compact form. It allows users to convert their input into chips.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChipListModule } from '@syncfusion/ej2-angular-buttons'
import { Component, OnInit } from '@angular/core';
@Component({
imports: [
ChipListModule
],
standalone: true,
selector: 'my-app',
// specifies the template string for the Chip component
template: `
<ejs-chiplist id="chip">
<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>`
})
export class AppComponent {
}
@import 'node_modules/@syncfusion/ej2-base/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-buttons/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-base/styles/material.css';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Choice Chips
Choice Chips allows users to select a single Chips from the set of ChipList/ChipCollection. It can be enabled by setting the selection
property to Single
.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChipListModule } from '@syncfusion/ej2-angular-buttons'
import { Component, OnInit } from '@angular/core';
@Component({
imports: [
ChipListModule
],
standalone: true,
selector: 'my-app',
// specifies the template string for the Chip component
template: `
<ejs-chiplist id="chip" selection="Single">
<e-chips>
<e-chip text="Small"></e-chip>
<e-chip text="Medium"></e-chip>
<e-chip text="Large"></e-chip>
<e-chip text="Extra Large"></e-chip>
</e-chips>
</ejs-chiplist>`
})
export class AppComponent {
}
@import 'node_modules/@syncfusion/ej2-base/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-buttons/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-base/styles/material.css';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Filter Chips
Filter Chips allows you to select multiple chips from the set of ChipList/ChipCollection. It can be enabled by setting the selection
property to Multiple
.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChipListModule } from '@syncfusion/ej2-angular-buttons'
import { Component, OnInit } from '@angular/core';
@Component({
imports: [
ChipListModule
],
standalone: true,
selector: 'my-app',
// specifies the template string for the Chip component
template: `
<ejs-chiplist id="chip" selection="Multiple">
<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>`
})
export class AppComponent {
}
@import 'node_modules/@syncfusion/ej2-base/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-buttons/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-base/styles/material.css';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Action Chips
The Action Chips triggers events like click or delete, which helps perform actions based on the event.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChipListModule } from '@syncfusion/ej2-angular-buttons'
import { Component, OnInit } from '@angular/core';
import { ClickEventArgs } from '@syncfusion/ej2-buttons';
@Component({
imports: [
ChipListModule
],
standalone: true,
selector: 'my-app',
// specifies the template string for the Chip component
template: `
<ejs-chiplist id="chip" (click)="chipclick($event)">
<e-chips>
<e-chip text="Send a text"></e-chip>
<e-chip text="Set a remainder"></e-chip>
<e-chip text="Read my emails"></e-chip>
<e-chip text="Set alarm"></e-chip>
</e-chips>
</ejs-chiplist>
`
})
export class AppComponent {
constructor() { }
chipclick(e: ClickEventArgs) {
if (e.text) {
alert("you have clicked " + e.text);
}
}
}
@import 'node_modules/@syncfusion/ej2-base/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-buttons/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-base/styles/material.css';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Deletable Chips
Deletable Chips allows users to delete a Chips from ChipList/ChipCollection. It can be enabled by setting the enableDelete
property to true
.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ChipListModule } from '@syncfusion/ej2-angular-buttons'
import { Component, OnInit } from '@angular/core';
@Component({
imports: [
ChipListModule
],
standalone: true,
selector: 'my-app',
// specifies the template string for the Chip component
template: `
<ejs-chiplist id="chip" enableDelete="true">
<e-chips>
<e-chip text="Send a text"></e-chip>
<e-chip text="Set a remainder"></e-chip>
<e-chip text="Read my emails"></e-chip>
<e-chip text="Set alarm"></e-chip>
</e-chips>
</ejs-chiplist>
`
})
export class AppComponent {
}
@import 'node_modules/@syncfusion/ej2-base/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-buttons/styles/material.css';
@import 'node_modules/@syncfusion/ej2-angular-base/styles/material.css';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));