Skip to content

feat(checkbox): adds checkbox component in ui with story and unit tests - #8861

Open
sachin-thakur-bruno wants to merge 16 commits into
usebruno:mainfrom
sachin-thakur-bruno:chore/checkbox-ui
Open

feat(checkbox): adds checkbox component in ui with story and unit tests#8861
sachin-thakur-bruno wants to merge 16 commits into
usebruno:mainfrom
sachin-thakur-bruno:chore/checkbox-ui

Conversation

@sachin-thakur-bruno

@sachin-thakur-bruno sachin-thakur-bruno commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Description

BRU-4163

Adds a new reusable Checkbox primitive to the design-system location (packages/bruno-app/src/ui/Checkbox), plus a new border3 theme token added to all 13 built-in themes.

https://www.figma.com/design/uDY1jX4jDj8uBDand72oBf/%F0%9F%8C%9F-New-DS-2026?node-id=30-220&p=f&t=fcNSTF7uheutLp1N-0

Problem

There was no general-purpose Checkbox in ui/. The only existing Checkbox (components/Checkbox) was a single hardcoded 16px size, no ref/size/accessible-name support, and colors pulled from tokens that were never meant as a general checkbox API . It also had zero usages anywhere in the app.

Fix

  • Built ui/Checkbox (index.js + StyledWrapper.js).
  • Added border3 to the palette/schema of every theme file so the checkbox (and future components) has a dedicated border-only token instead of reusing text-muted colors.
  • Added Storybook stories (Checkbox.stories.jsx) and a full Jest spec (Checkbox.spec.jsx) covering checked/disabled/keyboard/ref-forwarding/accessible-name behavior.
  • Adds an indeterminate prop to ui/Checkbox for tri-state "select all" checkboxes, rendering a dash icon and syncing the DOM property via ref since it isn't a real HTML attribute. Includes matching styles, tests, and Storybook stories (Indeterminate, SelectAll).

Screenshots

Before After
image
image

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.
  • I've run the claude code review skill locally.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

New Features

  • Added a reusable Checkbox component with controlled, disabled, indeterminate, and keyboard-interactive states.
  • Added configurable sizing, labels, accessibility support, ref forwarding, and theme-aware styling.
  • Added Checkbox examples, state variations, and select-all demonstrations to the component catalog.
  • Introduced a fourth border hierarchy level across light and dark themes for consistent visual separation.

Documentation

  • Updated design-system guidance to describe all four border levels.

Tests

  • Added comprehensive Checkbox coverage for behavior, accessibility, interactions, indeterminate states, and theming.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The design system now defines four border hierarchy levels, including border3 across the schema and themes. A controlled, ref-forwarding Checkbox component was added with themed styling, tests, Storybook stories, and a public UI export.

Changes

Checkbox and border token system

Layer / File(s) Summary
Border3 theme contract
packages/bruno-app/src/themes/DesignSystem/Overview.jsx, packages/bruno-app/src/themes/schema/oss.js, packages/bruno-app/src/themes/dark/*, packages/bruno-app/src/themes/light/*
The border schema, documentation, palettes, and theme variants now define the required border3 color.
Checkbox component and styling
packages/bruno-app/src/ui/Checkbox/index.js, packages/bruno-app/src/ui/Checkbox/StyledWrapper.js, packages/bruno-app/src/ui/index.js
The public UI exports a controlled Checkbox with forwarded refs, accessibility and form props, size-aware icons, themed states, and labels.
Checkbox validation and stories
packages/bruno-app/src/ui/Checkbox/Checkbox.spec.jsx, packages/bruno-app/src/ui/Checkbox/Checkbox.stories.jsx
Tests cover state, interaction, accessibility, refs, and prop forwarding. Storybook covers sizes, states, controls, labeling, and select-all behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Checkbox
  participant StyledWrapper
  participant Theme
  User->>Checkbox: Interact with checkbox
  Checkbox->>StyledWrapper: Render input, icon, and label
  StyledWrapper->>Theme: Read themed border and state colors
  Theme-->>StyledWrapper: Return color values
  StyledWrapper-->>User: Display checkbox state
Loading

Suggested reviewers: bijin-bruno, utkarsh-bruno

Poem

Four borders define the theme,
Checkbox states align and gleam.
Icons scale from small to wide,
Tests and stories stand beside.
Focus and labels guide the way.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: adding a Checkbox component with Storybook stories and unit tests.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sachin-thakur-bruno sachin-thakur-bruno changed the title Chore/checkbox UI feat(checkbox)/adds checkbox component in ui with story and unit tests Aug 3, 2026
@sachin-thakur-bruno sachin-thakur-bruno changed the title feat(checkbox)/adds checkbox component in ui with story and unit tests chore(checkbox)/adds checkbox component in ui with story and unit tests Aug 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/bruno-app/src/themes/schema/oss.js (1)

153-158: 🗄️ Data Integrity & Integration | 🔵 Trivial

No change needed for builtin theme compatibility.

Every built-in theme file already defines border3. Any custom theme without border3 would fail validation and fall back to the default theme, so document or update that custom-theme requirement separately.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/themes/schema/oss.js` around lines 153 - 158, Keep the
builtin theme schema’s border3 requirement unchanged for compatibility with
existing built-in themes. Handle the custom-theme requirement separately by
documenting that custom themes must define border3, without modifying the
validation behavior in the schema.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/bruno-app/src/themes/DesignSystem/Overview.jsx`:
- Line 286: Update the Border Hierarchy preview data in Overview.jsx to add a
border3 row alongside border0, border1, and border2, using the existing row
shape and theme.border.border3 color so the preview displays all four hierarchy
levels.

In `@packages/bruno-app/src/ui/Checkbox/index.js`:
- Line 53: Remove the `'checkbox'` fallback from the `dataTestId` destructuring
in the Checkbox component so the attribute is only applied when callers
explicitly provide a value. Preserve the existing Checkbox rendering behavior
and ensure the `Sizes` and `States` stories no longer produce duplicate default
test IDs.

---

Nitpick comments:
In `@packages/bruno-app/src/themes/schema/oss.js`:
- Around line 153-158: Keep the builtin theme schema’s border3 requirement
unchanged for compatibility with existing built-in themes. Handle the
custom-theme requirement separately by documenting that custom themes must
define border3, without modifying the validation behavior in the schema.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d38a2307-f555-42dc-af1c-4eca913d8a05

📥 Commits

Reviewing files that changed from the base of the PR and between 384f326 and b57a055.

📒 Files selected for processing (20)
  • packages/bruno-app/src/themes/DesignSystem/Overview.jsx
  • packages/bruno-app/src/themes/dark/catppuccin-frappe.js
  • packages/bruno-app/src/themes/dark/catppuccin-macchiato.js
  • packages/bruno-app/src/themes/dark/catppuccin-mocha.js
  • packages/bruno-app/src/themes/dark/dark-monochrome.js
  • packages/bruno-app/src/themes/dark/dark-pastel.js
  • packages/bruno-app/src/themes/dark/dark.js
  • packages/bruno-app/src/themes/dark/nord.js
  • packages/bruno-app/src/themes/dark/vscode.js
  • packages/bruno-app/src/themes/light/catppuccin-latte.js
  • packages/bruno-app/src/themes/light/light-monochrome.js
  • packages/bruno-app/src/themes/light/light-pastel.js
  • packages/bruno-app/src/themes/light/light.js
  • packages/bruno-app/src/themes/light/vscode.js
  • packages/bruno-app/src/themes/schema/oss.js
  • packages/bruno-app/src/ui/Checkbox/Checkbox.spec.jsx
  • packages/bruno-app/src/ui/Checkbox/Checkbox.stories.jsx
  • packages/bruno-app/src/ui/Checkbox/StyledWrapper.js
  • packages/bruno-app/src/ui/Checkbox/index.js
  • packages/bruno-app/src/ui/index.js

{ name: 'Backgrounds', desc: '6 layered surface colors', color: theme.background.mantle },
{ name: 'Text', desc: '8 semantic text colors', color: theme.text },
{ name: 'Borders', desc: '3 hierarchy levels', color: theme.border.border2 },
{ name: 'Borders', desc: '4 hierarchy levels', color: theme.border.border2 },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add border3 to the Border Hierarchy preview.

The overview now states that four border levels exist and lists border3, but the Border Hierarchy preview still renders only border0, border1, and border2. Add a border3 row so both sections show the same hierarchy.

Also applies to: 1309-1310

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/themes/DesignSystem/Overview.jsx` at line 286, Update
the Border Hierarchy preview data in Overview.jsx to add a border3 row alongside
border0, border1, and border2, using the existing row shape and
theme.border.border3 color so the preview displays all four hierarchy levels.

Comment thread packages/bruno-app/src/ui/Checkbox/index.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/bruno-app/src/ui/Checkbox/index.js (1)

45-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression test for inputClassName.

Verify that a custom input class is appended while checkbox-input remains present. This protects the new public prop contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/ui/Checkbox/index.js` around lines 45 - 64, Add a
regression test for the Checkbox component covering the inputClassName prop:
render with a custom class and assert the input retains the base checkbox-input
class while also including the custom class.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/bruno-app/src/ui/Checkbox/index.js`:
- Around line 45-64: Add a regression test for the Checkbox component covering
the inputClassName prop: render with a custom class and assert the input retains
the base checkbox-input class while also including the custom class.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 63bb9e25-4754-4c40-807f-422d6455b80b

📥 Commits

Reviewing files that changed from the base of the PR and between b57a055 and 1a70b70.

📒 Files selected for processing (1)
  • packages/bruno-app/src/ui/Checkbox/index.js

@helloanoop

Copy link
Copy Markdown
Contributor

This is cool @sachin-thakur-bruno

I recommend updating once component in the codebase to use this new Checkbox component.
Also work with @bijin-bruno to create a user story for this. This need not go through @anusree-bruno

@pull-request-size pull-request-size Bot added size/XL and removed size/L labels Aug 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bruno-app/src/ui/Checkbox/index.js (1)

139-150: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Prevent passthrough props from overriding the input type.

Line 150 applies ...rest after type="checkbox". A caller can pass type="radio" or type="text" and break the component’s form and accessibility semantics.

Place the spread before invariant Checkbox attributes, or remove type from the forwarded props.

Proposed fix
             <input
+              {...rest}
               ref={mergeRefs(inputRef, forwardedRef)}
               type="checkbox"
               id={id}
               name={name}
               value={value}
               checked={checked}
               disabled={disabled}
               onChange={onChange}
               className={`checkbox-input ${inputClassName}`.trim()}
               data-testid={dataTestId}
               aria-label={ariaLabel}
               aria-labelledby={ariaLabelledBy}
-              {...rest}
             />
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/ui/Checkbox/index.js` around lines 139 - 150, Update
the Checkbox input JSX so the {...rest} spread cannot override the invariant
type="checkbox" attribute; move the spread before the fixed Checkbox attributes
in the input render block, or explicitly exclude type from forwarded props while
preserving other passthrough properties.
🧹 Nitpick comments (1)
packages/bruno-app/src/ui/Checkbox/Checkbox.stories.jsx (1)

92-92: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use Tailwind classes for story layout.

Replace these inline layout styles with Tailwind layout classes. The JSX guideline requires Tailwind classes specifically for layout.

For example, use flex items-center gap-6, flex flex-col gap-2, and pl-5.

As per coding guidelines, “Use styled components for component and child styling, and Tailwind classes specifically for layout.” <coding_guidelines>

Also applies to: 122-122, 131-131

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bruno-app/src/ui/Checkbox/Checkbox.stories.jsx` at line 92, Replace
the inline layout style objects on the story wrapper elements in the Checkbox
stories with equivalent Tailwind className values, including the affected
layouts at the referenced locations. Use classes such as flex, items-center,
gap-6, flex-col, gap-2, and pl-5 as appropriate, while preserving the existing
layout behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/bruno-app/src/ui/Checkbox/index.js`:
- Around line 95-99: Stabilize the callback returned by mergeRefs so rerenders
reuse the same ref function instead of triggering React ref replacement with an
intermediate null. Update the Checkbox implementation and add a callback-ref
test that rerenders with a changed checked value, verifying the DOM node is not
preceded by null.

---

Outside diff comments:
In `@packages/bruno-app/src/ui/Checkbox/index.js`:
- Around line 139-150: Update the Checkbox input JSX so the {...rest} spread
cannot override the invariant type="checkbox" attribute; move the spread before
the fixed Checkbox attributes in the input render block, or explicitly exclude
type from forwarded props while preserving other passthrough properties.

---

Nitpick comments:
In `@packages/bruno-app/src/ui/Checkbox/Checkbox.stories.jsx`:
- Line 92: Replace the inline layout style objects on the story wrapper elements
in the Checkbox stories with equivalent Tailwind className values, including the
affected layouts at the referenced locations. Use classes such as flex,
items-center, gap-6, flex-col, gap-2, and pl-5 as appropriate, while preserving
the existing layout behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f7c7731f-43fc-4f5a-b0a4-663d79e8a197

📥 Commits

Reviewing files that changed from the base of the PR and between 1a70b70 and c4e3c81.

📒 Files selected for processing (4)
  • packages/bruno-app/src/ui/Checkbox/Checkbox.spec.jsx
  • packages/bruno-app/src/ui/Checkbox/Checkbox.stories.jsx
  • packages/bruno-app/src/ui/Checkbox/StyledWrapper.js
  • packages/bruno-app/src/ui/Checkbox/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-app/src/ui/Checkbox/StyledWrapper.js

Comment thread packages/bruno-app/src/ui/Checkbox/index.js
@sid-bruno sid-bruno changed the title chore(checkbox)/adds checkbox component in ui with story and unit tests chore(checkbox): adds checkbox component in ui with story and unit tests Aug 5, 2026
@sachin-thakur-bruno sachin-thakur-bruno changed the title chore(checkbox): adds checkbox component in ui with story and unit tests feat(checkbox): adds checkbox component in ui with story and unit tests Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants