Search results

Types in React Chips component

05 Mar 2021 / 3 minutes to read

The ChipList control has the following types.

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

Input Chip

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

Source
Preview
app.tsx
index.html
index.css
app.jsx
Copied to clipboard
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.
class App extends React.Component<{}, {}> {
  render() {
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>
);
  }
}
ReactDom.render(<App />,document.getElementById('chip'));
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Button</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="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/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>
</head>

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

</html>
Copied to clipboard
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
Copied to clipboard
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.
class App extends React.Component {
    render() {
        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>);
    }
}
ReactDom.render(<App />, document.getElementById('chip'));

Choice Chip

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

Source
Preview
app.tsx
index.html
index.css
app.jsx
Copied to clipboard
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.
class App extends React.Component<{}, {}> {
  render() {
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>
);
  }
}
ReactDom.render(<App />,document.getElementById('chip'));
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Button</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="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/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>
</head>

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

</html>
Copied to clipboard
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
Copied to clipboard
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.
class App extends React.Component {
    render() {
        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>);
    }
}
ReactDom.render(<App />, document.getElementById('chip'));

Filter Chip

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

Source
Preview
app.tsx
index.html
index.css
app.jsx
Copied to clipboard
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.
class App extends React.Component<{}, {}> {
  render() {
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>
);
  }
}
ReactDom.render(<App />,document.getElementById('chip'));
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Button</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="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/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>
</head>

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

</html>
Copied to clipboard
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
Copied to clipboard
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.
class App extends React.Component {
    render() {
        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>);
    }
}
ReactDom.render(<App />, document.getElementById('chip'));

Action Chip

The Action Chip triggers the event like click or delete, which helps doing action based on the event.

Source
Preview
app.tsx
index.html
index.css
app.jsx
Copied to clipboard
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.
class App extends React.Component<{}, {}> {
  chipClick(e: any) {
alert('you have clicked ' + e.target.textContent);
  }

  render() {
return (
  <ChipListComponent id="chip-avatar" onClick={this.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>
);
  }
}
ReactDom.render(<App />,document.getElementById('chip'));
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Button</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="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/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>
</head>

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

</html>
Copied to clipboard
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
Copied to clipboard
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.
class App extends React.Component {
    chipClick(e) {
        alert('you have clicked ' + e.target.textContent);
    }
    render() {
        return (<ChipListComponent id="chip-avatar" onClick={this.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>);
    }
}
ReactDom.render(<App />, document.getElementById('chip'));

Deletable Chip

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

Source
Preview
app.tsx
index.html
index.css
app.jsx
Copied to clipboard
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.
class App extends React.Component<{}, {}> {
  chipClick(e: any) {
alert('you have clicked ' + e.target.textContent);
  }
  render() {
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>
);
  }
}
ReactDom.render(<App />,document.getElementById('chip'));
Copied to clipboard
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Button</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="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/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>
</head>

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

</html>
Copied to clipboard
#loader {
	color: #008cff;
	height: 40px;
	left: 45%;
	position: absolute;
	top: 45%;
	width: 30%;
}
Copied to clipboard
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.
class App extends React.Component {
    chipClick(e) {
        alert('you have clicked ' + e.target.textContent);
    }
    render() {
        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>);
    }
}
ReactDom.render(<App />, document.getElementById('chip'));