Types in React Chips component

27 Dec 202420 minutes to read

The ChipList component has the following types.

  • Input Chip
  • Choice Chip
  • Filter Chip
  • Action Chip

Input Chip

Input Chip holds information in compact form. It allows converting user input into chips.

import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
// To render Chip.
function App() {
    return (<ChipListComponent id="chip-avatar" enableDelete={true} selection="Single">
        <ChipsDirective>
            <ChipDirective text="Andrew"></ChipDirective>
            <ChipDirective text="Janet"></ChipDirective>
            <ChipDirective text="Laura"></ChipDirective>
            <ChipDirective text="Margaret"></ChipDirective>
        </ChipsDirective>
    </ChipListComponent>);
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

// To render Chip.
function App() {
    return (
        <ChipListComponent id="chip-avatar" enableDelete={true} selection="Single">
            <ChipsDirective>
                <ChipDirective text="Andrew"></ChipDirective>
                <ChipDirective text="Janet"></ChipDirective>
                <ChipDirective text="Laura"></ChipDirective>
                <ChipDirective text="Margaret"></ChipDirective>
            </ChipsDirective>
        </ChipListComponent>
    );
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Chips</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-react-buttons/styles/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='chip'>
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

Choice Chip

Choice Chip allows you to select a single chip from a set of ChipList/ChipCollection items. This can be enabled by setting the selection property to Single.

import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
// To render Chip.
function App() {
    return (<ChipListComponent id="chip-avatar" selection="Single">
        <ChipsDirective>
            <ChipDirective text="Small"></ChipDirective>
            <ChipDirective text="Medium"></ChipDirective>
            <ChipDirective text="Large"></ChipDirective>
            <ChipDirective text="Extra Large"></ChipDirective>
        </ChipsDirective>
    </ChipListComponent>);
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

// To render Chip.
function App() {
    return (
        <ChipListComponent id="chip-avatar" selection="Single">
            <ChipsDirective>
                <ChipDirective text="Small"></ChipDirective>
                <ChipDirective text="Medium"></ChipDirective>
                <ChipDirective text="Large"></ChipDirective>
                <ChipDirective text="Extra Large"></ChipDirective>
            </ChipsDirective>
        </ChipListComponent>
    );
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Chips</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-react-buttons/styles/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='chip'>
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

Filter Chip

Filter Chip allows you to select multiple chip from a set of ChipList/ChipCollection items. This can be enabled by setting the selection property to Multiple.

import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
// To render Chip.
function App() {
    return (<ChipListComponent id="chip-avatar" selection="Multiple">
        <ChipsDirective>
            <ChipDirective text="Chai"></ChipDirective>
            <ChipDirective text="Chung"></ChipDirective>
            <ChipDirective text="Aniseed Syrup"></ChipDirective>
            <ChipDirective text="Ikura"></ChipDirective>
        </ChipsDirective>
    </ChipListComponent>);
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

// To render Chip.
function App() {
    return (
        <ChipListComponent id="chip-avatar" selection="Multiple">
            <ChipsDirective>
                <ChipDirective text="Chai"></ChipDirective>
                <ChipDirective text="Chung"></ChipDirective>
                <ChipDirective text="Aniseed Syrup"></ChipDirective>
                <ChipDirective text="Ikura"></ChipDirective>
            </ChipsDirective>
        </ChipListComponent>
    );
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Chips</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-react-buttons/styles/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='chip'>
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

Action Chip

The Action Chip triggers events like click or delete, allowing actions to be performed based on these events.

import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
// To render Chip.
function App() {
  function chipClick(e) {
    alert('you have clicked ' + e.target.textContent);
  }
  return (<ChipListComponent id="chip-avatar" onClick={chipClick.bind(this)}>
    <ChipsDirective>
      <ChipDirective text="Send a text" />
      <ChipDirective text="Set a remainder" />
      <ChipDirective text="Read my emails" />
      <ChipDirective text="Set alarm" />
    </ChipsDirective>
  </ChipListComponent>);
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';


enableRipple(true);

// To render Chip.
function App() {
  function chipClick(e: any) {
    alert('you have clicked ' + e.target.textContent);
  }
  return (
    <ChipListComponent id="chip-avatar" onClick={chipClick.bind(this)}>
      <ChipsDirective>
        <ChipDirective text="Send a text" />
        <ChipDirective text="Set a remainder" />
        <ChipDirective text="Read my emails" />
        <ChipDirective text="Set alarm" />
      </ChipsDirective>
    </ChipListComponent>
  );
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Chips</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-react-buttons/styles/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='chip'>
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>

Deletable Chip

Deletable Chip allows users to delete a chip from ChipList/ChipCollection. This feature can be enabled by setting the enableDelete property to true.

import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
// To render Chip.
function App() {
    return (<ChipListComponent id="chip-avatar" enableDelete={true}>
        <ChipsDirective>
            <ChipDirective text="Send a text"></ChipDirective>
            <ChipDirective text="Set a remainder"></ChipDirective>
            <ChipDirective text="Read my emails"></ChipDirective>
            <ChipDirective text="Set alarm"></ChipDirective>
        </ChipsDirective>
    </ChipListComponent>);
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { ChipListComponent, ChipsDirective, ChipDirective } from '@syncfusion/ej2-react-buttons';
import { enableRipple } from '@syncfusion/ej2-base';


enableRipple(true);

// To render Chip.
function App() {
  return (
    <ChipListComponent id="chip-avatar" enableDelete={true}>
      <ChipsDirective>
        <ChipDirective text="Send a text"></ChipDirective>
        <ChipDirective text="Set a remainder"></ChipDirective>
        <ChipDirective text="Read my emails"></ChipDirective>
        <ChipDirective text="Set alarm"></ChipDirective>
      </ChipsDirective>
    </ChipListComponent>
  );
}
export default App;
ReactDom.render(<App />, document.getElementById('chip'));
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Chips</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="https://cdn.syncfusion.com/ej2/28.1.33/ej2-react-buttons/styles/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='chip'>
        <div id='loader'>Loading....</div>
    </div>
</body>

</html>