Chip
Chips are compact elements that represent an input, attribute, or action.
Chips allow users to enter information, make selections, filter content, or trigger actions.
Basic Chip
The chip
component supports outlined and filled styling.
Preview
Usage
import { Chip } from 'archi-ui'
<Chip>Basic Chip</Chip>
Chip actions
You can use the following actions.
- Chips with the
onClick
prop defined change appearance on focus, hover, and click. - Chips with the
onDelete
prop defined will display a delete icon which changes appearance on hover.
Chip clickable
Preview
Chip Deletable
Preview
Clickable and deletable
Preview
Clickable link
To use the chip
component as hyperlink, just pass href
prop or change the root element to <a>
tag using component
prop.
Preview
Custome delete icon
Use the deleteIcon
prop to override an default delete icon. Your deleteIcon
can be an SVG icon, or a React component.
Preview
Chip adornments
You can add ornaments to the beginning of the component.
Use the avatar
prop to add an avatar or use the icon
prop to add an icon.
Avatar Chip
Preview
Icon Chip
Preview
Chip color
Use color
prop to apply different colors for component.
Preview
Chip Size
Use size
prop to change the size of the button.
Preview
Chip with badge
Preview
Chip array
An example of rendering multiple chips from n array of values, Deleting a chip removes it from the array.
Example:
Filter the Movie Genres, and fetch the API for the filtered data to display movie details.
Preview
Chip API
API reference docs for the React Chip component.
Props
Name | Type | Default | Description |
---|---|---|---|
children | node | - | The content of the component. |
className | string | - | Override or extend the styles applied to the component. |
variant | 'filled' | 'outlined' | 'filled' | The variant to use. |
size | 'sm' | 'md' | 'md' | The size of the component. |
color | 'default' | 'primary' | 'secondary' | 'info' | 'warning' | 'success' | 'error' | 'default' | The color of the component. |
disabled | bool | false | If true , the component is disabled. |
clickable | bool | - | If true , the chip will be appear clickable, and will raise when pressed, even if the onClick prop is not defined. If false , the chip will not appear clickable, even if onClick prop is defined. This can be used, for example, along with the component prop to indicate an anchor Chip is clickable. Note: this controls the UI and does not affect the onClick event. |
component | elementType | - | The component used for the root node. Either a string to use a HTML element or a component. |
href | string | - | The URL to link to when the button is clicked. If defined, an <a> element will be used as the root node. |
avatar | element | - | The Avatar element to display. |
icon | node | - | Icon element. |
deleteIcon | element | - | Override the default delete icon element. Shown only if onDelete is set. |
onDelete | func | - | Callback fired when the delete icon is clicked. If set, the delete icon will be shown. |