Types in React Chips component

30 Jan 202314 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.

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'));

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.

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'));

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.

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'));

Action Chip

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

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'));

Deletable Chip

Deletable Chip allows you to delete a chip from ChipList/ChipCollection. It 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() {
    function chipClick(e) {
        alert('you have clicked ' + e.target.textContent);
    }
    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() {
  function chipClick(e: any) {
    alert('you have clicked ' + e.target.textContent);
  }
  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'));