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 Variable | Computed Value |
|---|---|
| | |
| | |
| | |
| | |
| | |
Props API#
- children
React.ReactNodeRequiredSpecifies the content of the
Chip. - onClick
KeyboardEventHandler & MouseEventHandlerClick handler for the whole
Chip, has effect only when Chip does not have any interactive icons. - className
stringSpecifies an additional
classNameto add to the base element. - variant
typeof STYLE_VARIANTS[keyof typeof STYLE_VARIANTS]Default'light'The
Chipstyle variant to use. - iconBefore
React.ComponentTypeAn icon component to render before the content. Example import of a Paragon icon component:
import { Check } from '@openedx/paragon/icons'; - iconBeforeAlt
stringSpecifies icon alt text.
- iconAfter
React.ComponentTypeAn icon component to render before after the content. Example import of a Paragon icon component:
import { Check } from '@openedx/paragon/icons'; - iconAfterAlt
stringSpecifies icon alt text.
- onIconBeforeClick
KeyboardEventHandler & MouseEventHandlerA click handler for the
Chipicon before. - onIconAfterClick
KeyboardEventHandler & MouseEventHandlerA click handler for the
Chipicon after. - disabled
booleanDefaultfalseDisables the
Chip. - isSelected
booleanDefaultfalseIndicates if
Chiphas been selected.
Usage Insights#
Chip
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-admin-portal | 22.20.3 | 3 | |
| frontend-app-course-authoring | 23.15.1 | 4 | |
| frontend-app-discussions | 23.16.0 | 15 | |
| frontend-app-learner-portal-enterprise | 22.17.0 | 5 | |
| frontend-app-library-authoring | 21.11.3 | 5 | |
| frontend-app-support-tools | 23.4.2 | 4 |