Skip to content

feat(bpk-component-checkbox-v2): Add composable checkbox using Ark UI#4222

Open
Gert-Jan Vercauteren (gert-janvercauteren) wants to merge 1 commit intobpk-layout-PoCfrom
bpk-component-checkbox-v2
Open

feat(bpk-component-checkbox-v2): Add composable checkbox using Ark UI#4222
Gert-Jan Vercauteren (gert-janvercauteren) wants to merge 1 commit intobpk-layout-PoCfrom
bpk-component-checkbox-v2

Conversation

@gert-janvercauteren

Summary

  • Adds a new composable checkbox component (bpk-component-checkbox-v2) built on top of Ark UI
  • Includes BpkCheckboxRoot, BpkCheckboxControl, BpkCheckboxLabel, BpkCheckboxContent, BpkCheckboxHiddenInput, and BpkCheckboxGroup subcomponents
  • Cherry-picked from [PoC][Preview] Bpk layout PoC Preview #4069 to isolate the checkbox work from the layout PoC branch

Test plan

  • Verify unit tests pass for the new checkbox component
  • Check Storybook examples render correctly
  • Verify accessibility tests pass

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 11, 2026 02:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new composable bpk-component-checkbox-v2 built on Ark UI, including core subcomponents, styles, Storybook examples, and automated tests.

Changes:

  • Added BpkCheckbox Root/Control/Label/Content/HiddenInput/Group components and SCSS styling
  • Added unit + accessibility tests and Storybook examples for the new checkbox
  • Updated repo dependencies and ESLint config to support Ark UI checkbox parts

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/package.json Adds Ark UI (and Chakra) dependencies needed by the new checkbox implementation
packages/bpk-component-checkbox-v2/src/common-types.ts Defines shared CheckedState type
packages/bpk-component-checkbox-v2/src/accessibility-test.tsx Adds jest-axe accessibility tests for checkbox states
packages/bpk-component-checkbox-v2/src/snapshots/BpkCheckbox-test.tsx.snap Adds snapshots for checkbox rendering variants
packages/bpk-component-checkbox-v2/src/BpkCheckboxRoot.tsx Implements Root wrapper over Checkbox.Root with Backpack classes/data-attrs
packages/bpk-component-checkbox-v2/src/BpkCheckboxLabel.tsx Implements Label with attempt to avoid toggling when clicking links
packages/bpk-component-checkbox-v2/src/BpkCheckboxHiddenInput.tsx Wraps Ark UI HiddenInput for form submission
packages/bpk-component-checkbox-v2/src/BpkCheckboxGroup.tsx Adds group wrapper over Checkbox.Group
packages/bpk-component-checkbox-v2/src/BpkCheckboxControl.tsx Implements control + indicators (check and indeterminate)
packages/bpk-component-checkbox-v2/src/BpkCheckboxContent.tsx Adds content slot wrapper
packages/bpk-component-checkbox-v2/src/BpkCheckbox.module.scss Adds component styling and state/variant handling
packages/bpk-component-checkbox-v2/src/BpkCheckbox-test.tsx Adds unit tests for rendering and behaviors
packages/bpk-component-checkbox-v2/index.ts Exposes the composed API surface and types
examples/bpk-component-checkbox-v2/stories.tsx Registers Storybook stories
examples/bpk-component-checkbox-v2/examples.tsx Adds interactive examples demonstrating variants and group usage
.eslintrc Allows styling props on Ark UI checkbox parts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +38 to +43
const handleClick = (e: MouseEvent) => {
// Allow links inside the label to be clicked without toggling the checkbox
if ((e.target as HTMLElement).closest('a')) {
e.stopPropagation();
}
};
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stopping propagation on the label’s click handler typically does not prevent the native <label> activation behavior (toggling the associated checkbox) when clicking inside it. If the goal is “links inside the label should not toggle the checkbox”, consider restructuring so the link isn’t inside the clickable label/root (e.g., render links outside the label/root and associate descriptive text via aria-describedby), or use an approach that cancels label activation in a way that still allows navigation.

Copilot uses AI. Check for mistakes.
}

// --- Disabled + On Dark ---
&--disabled#{&}--white {
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This selector works but is harder to read/maintain due to interpolation. Consider simplifying it to the more idiomatic &--disabled&--white (same specificity/meaning) to improve readability.

Suggested change
&--disabled#{&}--white {
&--disabled&--white {

Copilot uses AI. Check for mistakes.
New Backpack 2.0 checkbox component wrapping Ark UI headless primitives.
Uses namespace/static property API (BpkCheckbox.Root, .Control, .Label,
etc.) with BpkVStack layout primitives in Storybook examples.

Includes:
- BpkCheckboxRoot with forwardRef, all checkbox states
- BpkCheckboxControl encapsulating Ark UI indicators + SVG icons
- BpkCheckboxLabel with link stopPropagation
- BpkCheckboxContent for rich label layouts
- BpkCheckboxGroup for multi-checkbox groups
- BpkCheckboxHiddenInput for form submission
- SCSS with Ark data-attribute selectors and Backpack tokens
- Full test suite (22 tests) + jest-axe accessibility tests
- 9 Storybook stories using BpkVStack/BpkSpacing layout primitives
- ESLint allowlist for Checkbox.* Ark UI primitives

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai: claude minor Non breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants