Theme

npm_versionnpm Paragon package page

Chips are compact elements that represent an input, attribute, or action. Similar to the Badge component, but interactive.

Basic Usage

Any Paragon component or export may be added to the code example.

Clickable Variant

Use onClick prop to make the whole Chip clickable, this will also add appropriate styles to make Chip interactive.

Any Paragon component or export may be added to the code example.

With isSelected prop

Any Paragon component or export may be added to the code example.

With Icon Before and After

Basic Usage

Use iconBefore and iconAfter props to provide icons for the Chip, note that you also can provide accessible names for these icons for screen reader support via iconBeforeAlt and iconAfterAlt respectively.

Any Paragon component or export may be added to the code example.

Clickable icon variant

Provide click handlers for icons via onIconAfterClick and onIconBeforeClick props.

Any Paragon component or export may be added to the code example.

Note: both Chip and its icons cannot be made interactive at the same time, e.g. if you provide both onClick and onIconAfterClick props, onClick will be ignored and only the icon will get interactive behaviour, see example below (this is done to avoid usability issues where users might click on the Chip itself by mistake when they meant to click the icon instead).

Any Paragon component or export may be added to the code example.

Inverse Pallete

Any Paragon component or export may be added to the code example.

Theme Variables#

CSS VariableComputed Value










Props API#

Chip Props API
  • children node Required

    Specifies the content of the Chip.

  • className string

    Specifies an additional className to add to the base element.

  • variant enum'light' | 'dark'

    The Chip style variant to use.

    DefaultSTYLE_VARIANTS.LIGHT
  • disabled bool

    Disables the Chip.

    Defaultfalse
  • onClick func

    Click handler for the whole Chip, has effect only when Chip does not have any interactive icons.

  • iconBefore PropTypes.elementType as Requireable<React.ComponentType>

    An icon component to render before the content. Example import of a Paragon icon component:

    import { Check } from '@openedx/paragon/icons';

  • iconBeforeAlt requiredWhen(PropTypes.string, ['iconBefore', 'onIconBeforeClick'])

    Specifies icon alt text.

  • onIconBeforeClick func

    A click handler for the Chip icon before.

  • iconAfter PropTypes.elementType as Requireable<React.ComponentType>

    An icon component to render before after the content. Example import of a Paragon icon component:

    import { Check } from '@openedx/paragon/icons';

  • iconAfterAlt requiredWhen(PropTypes.string, ['iconAfter', 'onIconAfterClick'])

    Specifies icon alt text.

  • onIconAfterClick func

    A click handler for the Chip icon after.

  • isSelected bool

    Indicates if Chip has been selected.

    Defaultfalse

Usage Insights#

Chip

Project NameParagon VersionInstance Count
frontend-app-admin-portal21.13.110
frontend-app-course-authoring22.8.14
frontend-app-learner-dashboard22.9.02
frontend-app-learner-portal-enterprise21.13.15
frontend-app-support-tools21.13.14
prospectus20.46.22