PeakUIPro

CheckboxButtonGroup

Multi-select group of card-style checkboxes

Usage

import {CheckboxButtonGroup} from "@peakui-pro/react";

Anatomy

import {CheckboxButtonGroup} from "@peakui-pro/react";

// `Item` takes every core `Checkbox` prop. Its `className` styles the card; the other props
// reach the checkbox around it. Put a core `Label` and `Description` inside `ItemContent`.
export default () => (
  <CheckboxButtonGroup>
    <CheckboxButtonGroup.Item value="a">
      <CheckboxButtonGroup.Indicator />
      <CheckboxButtonGroup.ItemIcon />
      <CheckboxButtonGroup.ItemContent />
    </CheckboxButtonGroup.Item>
  </CheckboxButtonGroup>
);

Examples

Grid Layout

No Indicator

Custom Indicator

Icon Cards

With Icons

Disabled Group

Render Prop Children

Controlled

Subscription Plans

Customization

Tailwind CSS

<CheckboxButtonGroup className="grid-cols-3 [--checkbox-button-group-item-radius:var(--radius-xl)]" layout="grid">
  <CheckboxButtonGroup.Item className="data-[selected=true]:bg-accent-soft" value="a" />
</CheckboxButtonGroup>

Global CSS

@layer components {
  .checkbox-button-group {
    --checkbox-button-group-item-radius: var(--radius-xl);
  }

  .checkbox-button-group__item[data-selected="true"] {
    --button-group-card-ring: 0 0 0 2px var(--color-success);
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The CheckboxButtonGroup component uses these CSS classes (view source styles):

Base & Layout Classes

  • .checkbox-button-group - The group
  • .checkbox-button-group--grid - Grid layout

Element Classes

  • .checkbox-button-group__item - The card: the checkbox's clickable label
  • .checkbox-button-group__indicator - The corner control or custom icon
  • .checkbox-button-group__item-content - The column holding the text
  • .checkbox-button-group__item-icon - The leading icon box

Slots

  • [data-slot="checkbox-group"] - The root, the core group's own slot
  • [data-slot="checkbox"] - The field around a card, the core's own slot
  • [data-slot="checkbox-content"] - The card
  • [data-slot="checkbox-control"] - The default indicator
  • [data-slot="checkbox-button-group-indicator"] - A custom indicator
  • [data-slot="checkbox-button-group-item-content"] - The content column
  • [data-slot="checkbox-button-group-item-icon"] - The icon box

CSS Variables

VariablePurpose
--checkbox-button-group-item-radiusCorner radius of a card; defaults to var(--radius-2xl)
--button-group-card-ringThe ring around a card; set by the card, shared with RadioButtonGroup

Interactive States

The card supports both CSS pseudo-classes and data attributes:

  • Hover: [data-hovered]
  • Selected: [data-selected] (accent ring)
  • Focus: [data-focus-visible]
  • Disabled: [data-disabled]

API Reference

CheckboxButtonGroup

PropTypeDefaultDescription
layout'flex' | 'grid''flex'A column of cards, or a grid; set its columns with a grid-cols-* class
variant'primary' | 'secondary''primary'The core group's variant, passed to every checkbox
valuestring[]-The selected values, controlled
defaultValuestring[]-The selected values, uncontrolled
onChange(value: string[]) => void-Called when the selection changes
isDisabledbooleanfalseDims and disables every item
classNamestring | ((values: CheckboxGroupRenderProps) => string)-Additional classes
...restCheckboxGroupRootProps-Every core CheckboxGroup prop

CheckboxButtonGroup.Item

PropTypeDefaultDescription
valuestring-The value this card adds to the group
childrenReactNode | ((state: CheckboxFieldRenderProps) => ReactNode)-The card's content, or a function of its state
classNamestring | ((state: CheckboxButtonRenderProps) => string)-Additional classes for the card
...restOmit<CheckboxRootProps, 'children' | 'className'>-Every core Checkbox prop, applied to the field around the card

CheckboxButtonGroup.Indicator

PropTypeDefaultDescription
childrenReactNode-With none, the core checkbox control; with children, a custom icon shown only while selected
classNamestring-Additional classes
...restComponentProps<'span'>-Native <span> attributes

CheckboxButtonGroup.ItemContent

PropTypeDefaultDescription
childrenReactNode-The title and description
classNamestring-Additional classes
...restComponentProps<'div'>-Native <div> attributes

CheckboxButtonGroup.ItemIcon

PropTypeDefaultDescription
childrenReactNode-The icon
classNamestring-Additional classes
...restComponentProps<'div'>-Native <div> attributes

Render Props

CheckboxButtonGroup.Item

PropTypeDescription
isSelectedbooleanWhether the card is selected
isIndeterminatebooleanWhether the checkbox is indeterminate
isDisabledbooleanWhether the card is disabled
isFocusVisiblebooleanWhether keyboard focus is on the card
isHoveredbooleanWhether the pointer is over the card

On this page