Chips

Chips are compact components that represent discrete information.

Chips allow users to enter information, make selections, filter content, or trigger actions. While buttons are expected to appear consistently and with familiar calls to action, chips should appear dynamically as a group of multiple interactive elements.
The most common use will be in some form of input, so some of the behaviour demonstrated here is not shown in context.

ActionChips

Action chips trigger actions related to primary content.
Despite that buttons are an alternative to action chips, there is an important difference between them. Buttons should appear persistently and consistently, while action buttons should appear dynamically and contextually.

default
primary
secondary

You can declare the desired action with the onClick property.

with onClick

RemovableChips

Removable chips represent information used in fields, and they can be removed with the help of a remove button.
They enable user input and verify that input by converting text into chips.

default
primary
secondary

You can declare the desired remove action with the onRemove property.

with onRemove

ChoiceChips

Choice chips represent a selection / filters for a collection.
They are a good alternative to toggle buttons, radio buttons, checkboxes, and select menus.

default
primary
secondary

Choice chips can be controlled or uncontrolled.
To set the default state of the uncontrolled choice chips, use defaultSelected property with a boolean value.
To control the state of the controlled choice chips, use selected={boolean} and onToggle properties.

uncontrolled
controlled

Disabled

Disabled chips do not respond to any action.

default
primary
secondary

Rounded

To have a rounded version of chips use rounded property.

default
primary
secondary

Size

To have the larger or smaller chips, use the size property.

Large
Medium (default)
Small

Outlined

Outlined chips offer an alternative style.

default
primary
secondary

With Leading Icon

Sometimes you might want to have icons for certain chips to enhance the UX of the application as we recognize imagery more easily than plain text.

default
primary
secondary

API

Learn more about the properties and the customization points.

Usage

import ActionChip from "@sonnat/ui/ActionChip";
import RemovableChip from "@sonnat/ui/RemovableChip";
import ChoiceChip from "@sonnat/ui/ChoiceChip";
//or
import { ActionChip, RemovableChip, ChoiceChip } from "@sonnat/ui";

Properties

Note that the documentation avoids mentioning all the native props (there are a lot) in this section of the components.

Shared Properties

The properties that are common to choice, action, and removable chips.

Chips Shared Properties
NameTypeDefaultDescription
label
required
string-The content of the chip.
classNamestring-Append to the class names applied to the component so you can override or extend the styles.
roundedbooleanfalseIf true, the chip will be rounded.
disabledbooleanfalseIf true, the chip will be disabled.
size"large"
| "medium"
| "small"
"medium"The size of the chip.
color"default"
| "primary"
| "secondary"
"default"The color of the chip.
variant"filled"
| "outlined"
"filled"The variant of the chip.
leadingIconnode-The leading icon element placed before the label.
  • The ref is forwarded to the root element.
  • Any other properties supplied will be provided to the root element.

ActionChip Specific Properties

The properties that are only available to action chips.

ActionChip Specific Properties
NameTypeDefaultDescription
onClickfunction-Callback fired when the action chip is clicked.
Signature: function(event: React.MouseEvent) => void

RemovableChip Specific Properties

The properties that are only available to removable chips.

RemovableChip Specific Properties
NameTypeDefaultDescription
onRemovefunction-Callback fired when the remove button is clicked.
Signature: function(event: React.MouseEvent) => void

ChoiceChip Specific Properties

The properties that are only available to choice chips.

ChoiceChip Specific Properties
NameTypeDefaultDescription
selectedbooleanfalseIf true, the chip will be selected.
defaultSelectedbooleanfalseThe default state of selected. Use when the component is not controlled.
onTogglefunction-Callback fired when the chip is selected/unselected.
Signature: function(isSelected: boolean) => void