Skip to content

Chip ​

Chips are compact elements that represent an input, attribute, or action.

Importing ​

To use the chip component, first you need to register the component inside the page. You can register the component manually by importing the register function:

ts
import { register } from "@tapsioss/web-components/chip";

register(); // Now the chip component is ready to use!
ts
import { registerChip } from "@tapsioss/web-components";

registerChip(); // Now the chip component is ready to use!

Also you can automatically register the component by importing it with the following approach:

ts
import "@tapsioss/web-components/chip/element";

TIP

If you want to use all the component in your app, you can call registerAll at the root of your project.

ts
import { registerAll } from "@tapsioss/web-components";

registerAll(); // All the components are now available

In the React package, you can easily add the component using the following code:

ts
import { Chip } from "@tapsioss/react-components";

Component Usage ​

html
<tapsi-chip></tapsi-chip>
tsx
<Chip />

Properties ​

NameAttribute NameDescriptionTypeDefault Value
selectedselectedWhether the chip is selected or not.booleanfalse
disableddisabledWhether the chip is disabled or not.booleanfalse
sizesizeThe size of the chip."sm" | "md""md"
valuevalueThe value associated with the chip.string""

Slots ​

NameValueDescription
LEADING_ICONleading-iconThe slot for an optional trailing icon.
TRAILING_ICONtrailing-iconThe slot for an optional trailing icon.
DEFAULT-The slot for an optional trailing icon.

TIP

The value of slots are available for developer as JavaScript Variables:

ts
// Option 1
import { ChipSlots } from "@tapsioss/web-components";

// Option 2
import { Slots } from "@tapsioss/web-components/chip";
ts
// Option 1
import { ChipSlots } from "@tapsioss/react-components";

// Option 2
import { Slots } from "@tapsioss/react-components/Chip";

Events ​

NameDescriptionTypeBubblesCancelable
selectFired when the chip is selected.SelectEvent✅❌
deselectFired when the chip is deselected.DeselectEvent✅❌

TIP

Event details are available as JavaScript variables:

ts
// Option 1
import {
 SelectEvent,
 DeselectEvent
} from "@tapsioss/web-components/chip";

// Option 2
import {
 ChipSelectEvent,
 ChipDeselectEvent
} from "@tapsioss/web-components";

You can have access to the event name using the type property:

ts
// Option 1
element.addEventListener(SelectEvent.type, handleSelect);
element.addEventListener(DeselectEvent.type, handleDeselect);

// Option 2
element.addEventListener(ChipSelectEvent.type, handleSelect);
element.addEventListener(ChipDeselectEvent.type, handleDeselect);

Created with 🧡