Package org.zkoss.zul

Class Chip

All Implemented Interfaces:
Serializable, Cloneable, Component, Disable, Scope, ComponentCtrl

public class Chip extends LabelImageElement implements Disable
A display-only chip used to show categories, statuses, or keywords, with an optional close button and a severity theme.

There is no color attribute on this component. To customize appearance, either set the style attribute (e.g. style="--zk-chip-background-color: #6366f1;") or override the CSS custom properties --zk-chip-background-color / --zk-chip-color / --zk-chip-border-color declared in chip.less.

Default getZclass(): "z-chip".

Since:
11.0.0
Author:
yuehfeng
See Also:
  • Constructor Details

    • Chip

      public Chip()
    • Chip

      public Chip(String label)
  • Method Details

    • getSeverity

      public String getSeverity()
      Returns the severity (color theme).

      Default: "info".

    • setSeverity

      public void setSeverity(String severity) throws WrongValueException
      Sets the severity.
      Parameters:
      severity - one of "info", "success", "warning", "error", "neutral". Pass null to reset to the default ("info").
      Throws:
      WrongValueException
    • getSize

      public String getSize()
      Returns the size of this chip.

      Default: "medium". One of "small" or "medium"; medium maps to the default 22px row, small reduces the row height for dense layouts.

    • setSize

      public void setSize(String size) throws WrongValueException
      Sets the chip size.
      Parameters:
      size - "small" or "medium". Pass null to reset to the default ("medium").
      Throws:
      WrongValueException
    • isDisabled

      public boolean isDisabled()
      Whether this chip is non-interactive. Disabled chips ignore close clicks and render at reduced opacity.
      Specified by:
      isDisabled in interface Disable
    • setDisabled

      public void setDisabled(boolean disabled)
      Sets whether this chip is non-interactive. Disabled chips ignore close clicks and render at reduced opacity.
      Specified by:
      setDisabled in interface Disable
      Parameters:
      disabled - whether the chip is disabled. Calls smartUpdate when changed.
    • isRounded

      public boolean isRounded()
      Whether this chip is rounded (pill-shaped).
    • setRounded

      public void setRounded(boolean rounded)
      Sets whether this chip is rounded (pill-shaped).
      Parameters:
      rounded - whether the chip is rounded. Calls smartUpdate when changed.
    • isClosable

      public boolean isClosable()
      Whether this chip displays a close button.
    • setClosable

      public void setClosable(boolean closable)
      Sets whether this chip displays a close button.
      Parameters:
      closable - whether the chip displays a close button. Calls smartUpdate when changed.
    • getZclass

      public String getZclass()
      Description copied from class: HtmlBasedComponent
      Returns the ZK Cascading Style class for this component. It usually depends on the implementation of the mold (AbstractComponent.getMold()).

      Default: null (the default value depends on element).

      HtmlBasedComponent.setZclass(java.lang.String)) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value of HtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, use HtmlBasedComponent.setSclass(java.lang.String) instead.

      Overrides:
      getZclass in class HtmlBasedComponent
      See Also:
    • renderProperties

      protected void renderProperties(ContentRenderer renderer) throws IOException
      Description copied from class: HtmlBasedComponent
      Renders the content of this component, excluding the enclosing tags and children.

      See also ZK Client-side Reference: Property Rendering

      Overrides:
      renderProperties in class LabelImageElement
      Throws:
      IOException
    • onClose

      public void onClose()
      Handles the onClose event sent when the close button is clicked.

      Default: detach this chip. Override or use event.stopPropagation() to keep the chip visible. Follows the same pattern as Window.onClose() — the framework's event-dispatch machinery skips the default handler when a prior listener stops propagation.

      Since:
      11.0.0
    • isChildable

      public boolean isChildable()
      Description copied from class: AbstractComponent
      Returns whether this component can have a child.

      Default: return true (means it can have children).

      Overrides:
      isChildable in class AbstractComponent