lara-light-indigo

Chips

Chips is used to enter multiple values on an input field.

Basic
Comma Separator
Template
Import via Module

import { Chips } from 'primereact/chips';
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/chips/chips.min.js"></script>
 
Getting Started

Chips requires an array as its value and onChange callback to update the model.


<Chips value={value} onChange={(e) => setValue(e.value)}></Chips>
 
Custom Content

A chip is customized using itemTemplate function where value is passed to return JSX.


<Chips value={value} onChange={(e) => setValue(e.value)} itemTemplate={customChip}></Chips>
 

customChip(item) {
    return (
        <div>
            <span>{item} - (active) </span>
            <i className="pi pi-user-plus"></i>
        </div>
    );
}

 
Properties
NameTypeDefaultDescription
idstringnullUnique identifier of the component.
namestringnullName of the input field.
placeholderstringnullAdvisory information to display on input.
valuearraynullValue of the component.
maxnumbernullMaximum number of entries allowed.
disabledbooleanfalseWhen present, it specifies that the element should be disabled.
readOnlybooleanfalseWhen present, it specifies that the element should be read-only.
removablebooleantrueWhether an item is removable.
stylestringnullInline style of the element.
classNamestringnullStyle class of the element.
tooltipanynullContent of the tooltip.
tooltipOptionsobjectnullConfiguration of the tooltip, refer to the tooltip documentation for more information.
ariaLabelledBystringnullEstablishes relationships between the component and label(s) where its value should be one or more element IDs.
allowDuplicatebooleantrueWhether to allow duplicate values or not.
separatorstringnullSeparator char to add an item when pressed in addition to the enter key. Currently only possible value is ","
itemTemplatefunctionnullTemplate function to return the content of a chip.
Events
NameParametersDescription
onChangeoriginalEvent: Browser event
value: New value of the component
Callback to invoke when a chip is added or removed.
onAddoriginalEvent: Browser event
value: Added item value
Callback to invoke when a chip is added.
onRemoveoriginalEvent: Browser event
value: Removed item value
Callback to invoke when a chip is removed.
onFocusevent: Browser eventCallback to invoke when the component gets focus.
onBlurevent: Browser eventCallback to invoke when the component loses focus.
Styling

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
p-chipsContainer element
p-chips-tokenChip element container.
p-chips-token-iconIcon of a chip.
p-chips-token-labellabel of a chip.
p-chips-input-tokenContainer of input element.
Dependencies

None.

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma