Chip

A compact tag: a label, an optional icon or avatar, and - given onClick - a button, and - given onDelete - a delete control.

Demos

For usage examples, visit the component demo page: Chip

Import

import { Chip } from '@soroush.tech/design-system/Chip'

Props

PropTypeDefaultDescription
labelReactNode-What the chip says. A long one truncates with an ellipsis.
variant'contained' | 'outlined' | 'text''contained'Filled, outlined, or only its text - as Button's.
colorkeyof Theme['palette']'default'Resolves to theme.palette.
sizekeyof Theme['sizes']'md'Resolves against theme.sizes.
shape'square' | 'rounded' | 'pill''pill'The corners: 0, theme.radii.md, or fully round.
borderRadiuskeyof Theme['radii']'md'The radius of a 'rounded' chip; other shapes ignore it.
iconReactNode-An icon before the label. An avatar takes its place.
avatarReactNode-An avatar before the label.
onClick(event) => void-Makes the chip a button.
onDelete(event) => void-Shows a delete control, and deletes on Backspace and Delete.
deleteLabelstring-Names the delete control.
disabledbooleanfalseStays as it is, off.
className, data-testidOn the root.

It takes the styled-system space props too.

Colors

A filled chip is the main of its color with the theme's contrastText on it, so its contrast is the theme's. Outlined, it is the color as its border and text; with no color ('default'), the theme's border.default and text.initial.

Customization

theme.components.Chip styles the root, the body (what is pressed: a button when clickable), the label, the icon, the avatar and the deleteIcon (the delete control). Its defaultProps set variant, color, size, shape, borderRadius and deleteLabel.

Source code

If this page does not answer your question, have a look at the implementation of the component for more detail.