1. Domino UI
  2. Components
  3. Chips
Top Basic Removable Images Letters Selectable Docs

Chip

A component for a Tag that can have a text and icon or image and can be set to be removable.

See also :

Chips group

This component groups a set of Chip s and controls the selection behavior of grouped chips

See also :

Examples

Basic chips

Removable chips Chips with a remove action.

Chips with images Chips can have images or icons

Chips with letters Chips can have text letters

Selectable chips Chips can be grouped and selected with listeners.

API Docs: Chip

Constructors

public void Chip(String text)
Creates a chip with the provided text

text

The chip text

Static methods

public static Chip create(String text)
factory methiod to create a Chip with the provided text.

text

The chip text



Returns:

new Chip instance

Public methods

public Chip select()
Selects the chip and trigger the selection listeners if not paused

Returns:

same chip instance

public Chip deselect()
Deselects the chip and trigger the deselection listeners if not paused

Returns:

same chip instance

public Chip select(boolean silent)
Selects the chip and trigger the selection listeners if the silent flag not true.

silent

boolean, true to ignore selection listeners, false to trigger selection listeners



Returns:

same chip instance

public Chip deselect(boolean silent)
Deselects the chip and trigger the deselection listeners if the silent flag not true.

silent

boolean, true to ignore deselection listeners, false to trigger deselection listeners



Returns:

same chip instance

public Chip setSelected(boolean selected)
Change the chip selection state based on the provided flag.

selected

boolean, true selects the chip, false deselect the chip



Returns:

same chip instance

public Chip setSelected(boolean selected, boolean silent)
Change the chip selection state based on the provided flag and trigger the selection listeners based on the silent flag.

selected

boolean, true selects the chip, false deselect the chip

silent

boolean, true ignore the selection/deselection listener, false trigger the selection/deselection listener



Returns:

same chip instance

public boolean isSelected()


Returns:

boolean, true if the chip is selectable and currently selected, otherwise false

public boolean isSelectable()


Returns:

boolean, true if the chip is selectable otherwise false

public Chip setSelectable(boolean selectable)
Sets this chip to be selectable or not.

selectable

boolean, true to make the chip selectable, false to make it not selectable



Returns:

same chip instance

public boolean isRemovable()
Use to check if this chip is removable or not.

Returns:

a boolean, true if the chip is removable otherwise false

public Chip setRemovable(boolean removable)
Toggle the chip removable state based on the provided flag

removable

a boolean, true to make the chip removable, false to make it not removable.



Returns:

same chip instance

public Chip setText(String text)
Set the chip text

text

the chip text string



Returns:

same chip instance

public Chip withTextElement(ChildHandler<Chip, SpanElement> handler)
Use to apply customization to the chip text element without breaking the fluent api chain

handler

The ChildHandler applying the customizations



Returns:

same chip instance

public SpanElement getTextElement()


Returns:

The SpanElement of this chip text.

public Chip appendChild(PrefixAddOn<?> prefixAddOn)
Appends a element to the left side of the chip

prefixAddOn

The PrefixAddOn wrapping another element



Returns:

same chip instance

public Chip setLetters(String text)
Appends a text as prefix to the chip

text

The text to be appended as a prefix.



Returns:

same chip instance

public Chip setImage(HTMLImageElement img)
Appends an image as a prefix to this chip

img

The HTMLImageElement to be appended as prefix



Returns:

same chip instance

public Chip setImage(ImageElement img)
Sets the prefix with the provided image.

img

The ImageElement to be appended as prefix



Returns:

same chip instance

public Chip clearAddOn()
Removes all elements appended as prefix to this chi[

Returns:

same chip instance

public Chip withAddon(ChildHandler<Chip, DivElement> handler)
Use to apply customization to the element containing prefixes appended to this chip without breaking the fluent api chain.

handler

The ChildHandler applying the customization



Returns:

same chip instance

API Docs: ChipGroup

Constructors

public void ChipsGroup()
Creates and empty chips group

Static methods

public static ChipsGroup create()
Factory method to create an empty chips group

Returns:

new ChipsGroup instance

Public methods

public ChipsGroup appendChild(Chip chip)
Adds a Chip to this chips group

This will automatically set the chip as selectable and adds selection/deselection handler to handle the switching between all the chips.

chip

the Chip to be added to the group



Returns:

same ChipsGroup instance

public ChipsGroup enable()
Enables chips selection
public ChipsGroup disable()
Disables chips selection
public boolean isEnabled()
Use to check if this group chips selection is enabled

Returns:

boolean, true if selection is enabled, false if selection is not enabled

public List<Chip> getSelectedChips()


Returns:

a List of currently selected chips in this group

public ChipsGroup selectAt(int index)
Selects a chip at provided index index only if the index within the acceptable range, otherwise ignore.

index

the index of the chip to select



Returns:

same instance

public List<Chip> getChips()


Returns:

a List of all chips in this group.

public Set<SelectionListener<? super Chip, ? super List<Chip>>> getSelectionListeners()
{@dominokit-site-ignore @inheritDoc}
public boolean isMultiSelect()
Use to check if this group allows the selection of multiple chips at the same time.

Returns:

a boolean, true multi-select is enabled, false multi-select is disabled

public ChipsGroup setMultiSelect(boolean multiSelect)
Enable/Disable multi-selection based on the provided flag.

multiSelect

a boolean, true enables multi-selection, false disable multi-selection



Returns:

same ChipsGroup instance

public boolean isRemovable()
Check if the chips in this group are removable or not.

Returns:

a boolean, true the chips in this group are removable, false the chips in this group are not removable

public ChipsGroup setRemovable(boolean removable)
Set all chips in this group to removable or not based on the provided flag.

removable

a boolean, true set all chips in this group to be removable, false set all chips in this group to be not removable.



Returns:

same ChipsGroup instance

We are a group of passionate people who love what we do

Donate & Support Us