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 (SCSS)#
$chip-padding-x: .5rem !default;$chip-padding-y: 1px !default;$chip-icon-margin: .25rem !default;$chip-margin: .125rem !default;$chip-border-radius: .375rem !default;$chip-disable-opacity: .3 !default;$chip-icon-size: 1.5rem !default;$chip-label-color: $primary-700 !default;$chip-border-color: $light-800 !default;$chip-outline-width: 3px !default;$chip-light-bg-color: $white !default;$chip-light-outline-color: $chip-label-color !default;$chip-light-selected-outline-distance: 3px !default;$chip-light-selected-focus-border-color: $dark-500 !default;$chip-light-hover-bg: $dark-500 !default;$chip-light-hover-border-color: $chip-light-hover-bg !default;$chip-light-hover-label-color: $chip-light-bg-color !default;$chip-light-hover-icon-color: $chip-light-hover-label-color !default;$chip-light-focus-outline-distance: .313rem !default;$chip-dark-bg: $primary-300 !default;$chip-dark-outline-color: $white !default;$chip-dark-selected-outline-distance: 3px !default;$chip-dark-selected-focus-border-color: $chip-dark-outline-color !default;$chip-dark-label-color: $chip-dark-outline-color !default;$chip-dark-hover-bg: $white !default;$chip-dark-hover-border-color: $chip-dark-hover-bg !default;$chip-dark-hover-label-color: $primary-500 !default;$chip-dark-focus-outline-distance: .313rem !default;
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 |