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
node
RequiredSpecifies the content of the
Chip
. - className
string
Specifies an additional
className
to add to the base element. - variant
enum
'light' | 'dark'DefaultSTYLE_VARIANTS.LIGHTThe
Chip
style variant to use. - disabled
bool
DefaultfalseDisables the
Chip
. - 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
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 |