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.ReactNode
RequiredSpecifies the content of the
Chip
. - onClick
KeyboardEventHandler & MouseEventHandler
Click handler for the whole
Chip
, has effect only when Chip does not have any interactive icons. - className
string
Specifies an additional
className
to add to the base element. - variant
typeof STYLE_VARIANTS[keyof typeof STYLE_VARIANTS]
Default'light'The
Chip
style variant to use. - iconBefore
React.ComponentType
An icon component to render before the content. Example import of a Paragon icon component:
import { Check } from '@openedx/paragon/icons';
- iconBeforeAlt
string
Specifies icon alt text.
- iconAfter
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
string
Specifies icon alt text.
- onIconBeforeClick
KeyboardEventHandler & MouseEventHandler
A click handler for the
Chip
icon before. - onIconAfterClick
KeyboardEventHandler & MouseEventHandler
A click handler for the
Chip
icon after. - disabled
boolean
DefaultfalseDisables the
Chip
. - isSelected
boolean
DefaultfalseIndicates if
Chip
has been selected.
Usage Insights#
Chip
Project Name | Paragon Version | Instance Count | |
---|---|---|---|
frontend-app-admin-portal | 21.13.1 | 10 | |
frontend-app-course-authoring | 22.8.1 | 4 | |
frontend-app-learner-dashboard | 22.9.0 | 2 | |
frontend-app-learner-portal-enterprise | 21.13.1 | 5 | |
frontend-app-support-tools | 21.13.1 | 4 | |
prospectus | 20.46.2 | 2 |