Balance Logo
Balance
Reckon Design System
Open playroom

Chip

Install
pnpm add @balance-web/chip
Import usage
import {
MenuChip,
FilterChipRadioGroup,
FilterChipRadio,
FilterChipCheckboxGroup,
FilterChipCheckbox
} from '@balance-web/chip';
  • Code
  • API

This packages exposes components that helps users make selects, enter information or filter content.

The Chip component can be used in different use cases as it provides a convenient option for displaying complex information in a compact form.

It is especially useful for representing an entity which can be added or removed from a list.

This component is supposed to be used as a trigger for opening menus. It's meant to replace all usage of ActionButton and custom implementations as triggers.

Basic usage

The usage below is showed in isolation for demo purposes. This component should never be used by itself, it should always be composed together with a menu.

Note: Do not use this component as a button.

Edit in Playroom

variant

This component comes with two variants: filled and outline.

The default value is filled.

label

The label of the menu.

Labels should be kept short and not contain phrases or actions. Use plural form for multi select menus.

Good ✅
  • Flavors
  • Date
Bad ❌
  • Choose flavors
  • Select a date

size

This component comes in two sizes: small and medium.

The default value is medium.

aria-expanded

The open/closed state of the menu.

Because this component is meant to be composed with a menu, we need to use aria attributes to control various states instead of a conventional boolean like isOpen.

hasValue

Tells the component if the menu has a value selected.

disabled

Makes the tirggered disabled so that the user is unable to access the menu.

iconBefore

Renders an icon before the label. When the hasValue prop is true, this icon gets replaced by a tick icon to show that the menu has a selection.

selectionCount

Show the number of selections when a multi select menu has a large number of selections.

onClick

This component is rendered as a button so the onClick handler is required.

onClear (optional)

Optionally provide a function to clear the select directly from the trigger. This renders a delete button inside the trigger.

hasChevron (optional)

Optionally render a chevron icon that tracks the open/closed state of the menu. This should only be used in rare cases to support some legacy UIs.

Single select menu

Multi select menu

FilterChipRadioGroup

This component helps the user make a single selection from a small list of items, it is implemented as a radio group under the hood.

This component has the same variant and size props from above.

Note: Do not use this component if there are more than 5 items to choose from.

Basic usage

legend

Since this component is implemented as a radio group, we need a label for the underlying fieldset. This label will not be shown to the user, it's only there for accessibility purpose.

options

List of options that are presented to the user in the following shape:

type Options = Array<{ label: string; value: Value; disabled?: boolean }>;

value

The current value of the radio group.

onChange

Event handler for when user makes a selection.

FilterChipCheckboxGroup

This component helps the user make multiple selections from a small list of items, it is implemented as a checkbox group under the hood.

This component has the same variant and size props from above.

Note: Do not use this component if there are more than 5 items to choose from.

Basic usage

legend

Since this component is implemented as a checkbox group, we need a label for the underlying fieldset. This label will not be shown to the user, it's only there for accessibility purpose.

options

List of options that are presented to the user in the following shape:

type Options = Array<{ label: string; value: Value; disabled?: boolean }>;

value

The current value of the checkbox group.

onChange

Event handler for when user makes a selection.

Copyright © 2024 Reckon. Designed and developed in partnership with Thinkmill.
Bitbucket logoJira software logoConfluence logo