public class Chip extends BaseDominoElement<elemental2.dom.HTMLDivElement,Chip> implements HasSelectionHandler<Chip,String>, HasDeselectionHandler<Chip>, Switchable<Chip>, HasRemoveHandler<Chip>
This component provides a clickable container that allows adding text and an image along with a remove icon to remove the container.
Customize the component can be done by overwriting classes provided by ChipStyles
For example:
Chip.create()
.setValue("Yay! I\'ll be there")
.setColorScheme(ColorScheme.RED)
Chip.create()
.setRemovable(true)
.setColorScheme(ColorScheme.GREY)
.setValue("Restaurants")
Chip.create()
.setValue("Schroeder Coleman")
.setColorScheme(ColorScheme.TRANSPARENT)
.setBorderColor(Color.INDIGO)
.setLeftImg(img("https://randomuser.me/api/portraits/med/men/0.jpg"))
BaseDominoElement.ElementHandler<T>, BaseDominoElement.ResizeHandler<T>, BaseDominoElement.StyleEditor<E extends elemental2.dom.HTMLElement,T extends org.jboss.elemento.IsElement<E>>, BaseDominoElement.WavesStylerHasSelectionHandler.SelectionHandler<V>HasDeselectionHandler.DeselectionHandlerHasRemoveHandler.RemoveHandler| Modifier and Type | Method and Description |
|---|---|
Chip |
addDeselectionHandler(HasDeselectionHandler.DeselectionHandler deselectionHandler) |
Chip |
addRemoveHandler(HasRemoveHandler.RemoveHandler removeHandler)
adds a remove handler to the component
|
Chip |
addSelectionHandler(HasSelectionHandler.SelectionHandler<String> selectionHandler)
Adds a Selection handler to the component
|
static Chip |
create() |
static Chip |
create(String value) |
Chip |
deselect()
Marks the chip as deselected.
|
Chip |
disable() |
elemental2.dom.HTMLDivElement |
element() |
Chip |
enable() |
DominoElement<elemental2.dom.HTMLElement> |
getLeftAddon() |
DominoElement<elemental2.dom.HTMLDivElement> |
getLeftAddonContainer() |
DominoElement<elemental2.dom.HTMLElement> |
getRemoveIcon() |
DominoElement<elemental2.dom.HTMLDivElement> |
getRemoveIconContainer() |
DominoElement<elemental2.dom.HTMLDivElement> |
getTextContainer() |
String |
getValue() |
boolean |
isEnabled() |
boolean |
isSelected() |
Chip |
remove()
removes the element from the DOM tree
|
Chip |
remove(boolean silent)
Removes the chip.
|
Chip |
removeLeftAddon()
Removes the left element.
|
Chip |
removeSelectionHandler(HasSelectionHandler.SelectionHandler<String> selectionHandler) |
Chip |
select()
Marks the chip as selected.
|
Chip |
setBorderColor(Color borderColor)
Sets the border
Color |
Chip |
setColor(Color color)
Sets the color.
|
Chip |
setColorScheme(ColorScheme colorScheme)
Sets the color scheme for this component.
|
Chip |
setLeftBackground(Color leftBackground)
Sets the left container background
|
Chip |
setLeftIcon(BaseIcon<?> icon)
Sets the left icon of the chip
|
Chip |
setLeftImg(elemental2.dom.HTMLImageElement imageElement)
Sets the left image of the chip.
|
Chip |
setLeftImg(org.jboss.elemento.IsElement<elemental2.dom.HTMLImageElement> imageElement)
Same as
setLeftImg(HTMLImageElement) but with a wrapper IsElement |
Chip |
setLeftLetter(String text)
Sets the left element as a letter.
|
Chip |
setRemovable(boolean removable)
Sets if this chip can be removed or not.
|
Chip |
setRemoveIcon(elemental2.dom.HTMLElement removeIcon)
Sets the remove icon element.
|
Chip |
setRemoveIcon(org.jboss.elemento.IsElement<?> removeIcon)
Same as
setRemoveIcon(HTMLElement) but accepts a wrapper IsElement |
Chip |
setSelectable(boolean selectable)
Sets if the chip can be selected or not.
|
Chip |
setValue(String value)
Sets the text of the chip.
|
Chip |
toggleSelect()
Selects/Deselects the chip based on its current status (i.e.
|
add, add, addClickListener, addCss, addCss, addEventListener, addEventListener, addEventsListener, addHideListener, addShowListener, alignCenter, alignRight, appendChild, appendChild, apply, attr, blur, childNodes, clearElement, contains, contains, contains, containsCss, css, css, cssClassByIndex, cssClassesCount, cssText, elevate, elevate, firstChild, getAttachObserver, getAttribute, getBoundingClientRect, getChildElementCount, getClickableElement, getCollapsible, getCollapsibleElement, getDetachObserver, getDominoId, getElementsCount, getElevation, getFirstChild, getId, getTextContent, getTooltip, getWavesElement, hasAttribute, hasChildNodes, hasDirectChild, hide, hideOn, id, init, insertAfter, insertAfter, insertAfter, insertAfter, insertBefore, insertBefore, insertBefore, insertBefore, insertFirst, insertFirst, insertFirst, isAttached, isCollapsed, isDisabled, isEmptyElement, isEqualNode, isForceHidden, isHidden, isReadOnly, item, lastChild, length, onAttached, onDetached, onResize, pullLeft, pullRight, querySelector, querySelectorAll, removeAttachObserver, removeAttribute, removeChild, removeChild, removeCss, removeCss, removeCssProperty, removeDetachObserver, removeEventListener, removeEventListener, removeHideListener, removeHideOn, removeShowListener, removeShowOn, removeTooltip, removeWaves, replaceCss, setAlignItems, setAttribute, setAttribute, setAttribute, setBackgroundColor, setBackgroundColor, setBorder, setBorderColor, setBottom, setBottom, setBoxShadow, setCollapseStrategy, setColor, setColor, setContent, setContent, setCssProperty, setCssProperty, setCursor, setCursor, setDisabled, setDisplay, setDisplay, setDropMenu, setFlex, setFloat, setFloat, setFontSize, setFontSize, setForceHidden, setHeight, setHeight, setId, setInnerHtml, setLeft, setLeft, setLineHeight, setLineHeight, setMargin, setMargin, setMarginBottom, setMarginBottom, setMarginLeft, setMarginLeft, setMarginRight, setMarginRight, setMarginTop, setMarginTop, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setOpacity, setOpacity, setOverFlow, setOverFlow, setOverFlowY, setPadding, setPadding, setPaddingBottom, setPaddingBottom, setPaddingLeft, setPaddingLeft, setPaddingRight, setPaddingRight, setPaddingTop, setPaddingTop, setPointerEvents, setPosition, setPosition, setReadOnly, setRight, setRight, setTabIndex, setTextAlign, setTextAlign, setTextContent, setTooltip, setTooltip, setTooltip, setTooltip, setTop, setTop, setTransitionDuration, setWidth, setWidth, setZIndex, show, showOn, style, style, styler, textContent, toggleDisplay, toggleDisplay, withWaves, withWavesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisExpandedadd, add, remove, remove, removeProperty, replace, setProperty, setPropertypublic Chip(String value)
public static Chip create()
public Chip select()
Selecting the chip will trigger all the SelectionHandler added to it. Also, it will
change the background based on the ColorScheme configured
public Chip deselect()
Deselecting the chip will trigger all the DeselectionHandler added to it. Also, it
will change the background based on the ColorScheme configured
public Chip toggleSelect()
select(),
deselect()public boolean isSelected()
public Chip setRemoveIcon(elemental2.dom.HTMLElement removeIcon)
EventListener to the
removeIcon that removes the chipremoveIcon - the new remove HTMLElementpublic Chip remove()
remove in class BaseDominoElement<elemental2.dom.HTMLDivElement,Chip>public Chip remove(boolean silent)
Accepts silent flag to call all the RemoveHandler added to it.
silent - if true, then this will call all the RemoveHandlerpublic Chip setRemoveIcon(org.jboss.elemento.IsElement<?> removeIcon)
setRemoveIcon(HTMLElement) but accepts a wrapper IsElementremoveIcon - the new remove icon IsElement to setpublic Chip setColorScheme(ColorScheme colorScheme)
The color scheme will be used for changing the color based on the chip status if it is selected or not.
colorScheme - the new ColorScheme to setpublic Chip setColor(Color color)
The color is used to get the background color to be set to this chip, if not set then the
color will be configured using the ColorScheme set.
color - the new Color to setpublic Chip setRemovable(boolean removable)
Setting this to removable will add the remove icon configured for this component
removable - true if the chip can be removedpublic Chip setValue(String value)
value - the new textpublic Chip setLeftIcon(BaseIcon<?> icon)
icon - the new BaseIconpublic Chip setLeftImg(elemental2.dom.HTMLImageElement imageElement)
imageElement - the new HTMLImageElementpublic Chip setLeftImg(org.jboss.elemento.IsElement<elemental2.dom.HTMLImageElement> imageElement)
setLeftImg(HTMLImageElement) but with a wrapper IsElementimageElement - the new IsElementpublic Chip setLeftLetter(String text)
text - the letter to setpublic Chip setLeftBackground(Color leftBackground)
leftBackground - the Colorpublic elemental2.dom.HTMLDivElement element()
element in interface org.jboss.elemento.IsElement<elemental2.dom.HTMLDivElement>element in class BaseDominoElement<elemental2.dom.HTMLDivElement,Chip>public Chip addSelectionHandler(HasSelectionHandler.SelectionHandler<String> selectionHandler)
addSelectionHandler in interface HasSelectionHandler<Chip,String>selectionHandler - Selectable.SelectionHandlerpublic Chip addDeselectionHandler(HasDeselectionHandler.DeselectionHandler deselectionHandler)
addDeselectionHandler in interface HasDeselectionHandler<Chip>deselectionHandler - HasDeselectionHandler.DeselectionHandlerpublic Chip removeSelectionHandler(HasSelectionHandler.SelectionHandler<String> selectionHandler)
removeSelectionHandler in interface HasSelectionHandler<Chip,String>public Chip enable()
enable in interface Switchable<Chip>enable in class BaseDominoElement<elemental2.dom.HTMLDivElement,Chip>public Chip disable()
disable in interface Switchable<Chip>disable in class BaseDominoElement<elemental2.dom.HTMLDivElement,Chip>public boolean isEnabled()
isEnabled in interface Switchable<Chip>public Chip addRemoveHandler(HasRemoveHandler.RemoveHandler removeHandler)
addRemoveHandler in interface HasRemoveHandler<Chip>removeHandler - HasRemoveHandler.RemoveHandlerpublic Chip setSelectable(boolean selectable)
selectable - true if the chip can be selectedpublic Chip setBorderColor(Color borderColor)
ColorborderColor - the Color to setpublic Chip removeLeftAddon()
public String getValue()
public DominoElement<elemental2.dom.HTMLDivElement> getTextContainer()
public DominoElement<elemental2.dom.HTMLDivElement> getLeftAddonContainer()
public DominoElement<elemental2.dom.HTMLDivElement> getRemoveIconContainer()
public DominoElement<elemental2.dom.HTMLElement> getRemoveIcon()
public DominoElement<elemental2.dom.HTMLElement> getLeftAddon()
Copyright © 2019–2022 Dominokit. All rights reserved.