Skip to content

feat(ButtonGroup): add XDSButtonGroup component - #2202

Merged
czarandy merged 1 commit into
mainfrom
worktree-button-group
May 19, 2026
Merged

feat(ButtonGroup): add XDSButtonGroup component#2202
czarandy merged 1 commit into
mainfrom
worktree-button-group

Conversation

@czarandy

@czarandy czarandy commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds XDSButtonGroup container component that groups XDSButton / XDSIconButton with connected styling (shared borders, outer-only border-radius)
  • Uses a context-based approach: XDSButtonGroupContext provides orientation info, and XDSButton consumes it to apply position-aware styles via CSS :first-child / :last-child pseudo-classes
  • Supports horizontal and vertical orientation, size cascading, and variant-aware divider colors (--color-on-accent for primary/destructive)

Closes #210

Files

  • packages/core/src/ButtonGroup/ — component, context, tests, docs, index
  • packages/core/src/Button/XDSButton.tsx — group-aware styles via useXDSButtonGroup context
  • apps/storybook/stories/ButtonGroup.stories.tsx — 8 stories
  • packages/cli/templates/blocks/components/ButtonGroup/ — showcase block

Test plan

  • yarn build passes
  • yarn test — 8 new ButtonGroup tests pass, no regressions
  • yarn lint — 0 errors
  • Visual review in Storybook (Horizontal, Vertical, IconOnly, GhostPair, Sizes, PrimaryVariant, SplitButton, Mixed)

@vercel

vercel Bot commented May 18, 2026

Copy link
Copy Markdown

@czarandy must be a member of the Meta Open Source team on Vercel to deploy.
- Click here to add @czarandy to the team.
- If you initiated this build, request access.

Learn more about collaboration on Vercel and other options here.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label May 18, 2026
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 18.6KB 28.8KB 4.3KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang cixzhang 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.

Solid architecture — context-based composition over cloneElement is the right call. A few things:

  1. Add explicit ref prop — not currently declared on XDSButtonGroupProps.

  2. Consider aria-orientation on the group div — quick win for screen readers with vertical groups.

  3. No isDisabled on the group — XDSRadioList and XDSCheckboxList both have group-level disable. Worth adding for consistency, or documenting why it's omitted.

  4. Keyboard nav — roving tabindex (arrow keys between buttons) is nice-to-have for toolbar-like groups. Fine to ship without and add later, but worth tracking.

@vercel

vercel Bot commented May 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
xds-sandbox Error Error May 19, 2026 4:16am

Request Review

@czarandy

Copy link
Copy Markdown
Collaborator Author

Addressed comments, including adding the keyboard nav

@czarandy
czarandy enabled auto-merge (squash) May 19, 2026 04:15
Groups multiple buttons with connected styling using a context-based approach.
XDSButton consumes the group context and applies position-aware border-radius
and divider styles via CSS :first-child/:last-child pseudo-classes.

- ref prop forwarded to root element
- aria-orientation for screen readers
- isDisabled cascades to all child buttons via context
- Roving tabindex keyboard navigation via useListFocus
- Variant-aware divider color (--color-on-accent for primary/destructive)

@cixzhang cixzhang 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.

All addressed — ref, isDisabled, aria-orientation, and roving tabindex via useListFocus. Nice.

@czarandy
czarandy merged commit fda754e into main May 19, 2026
21 of 22 checks passed
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
Groups multiple buttons with connected styling using a context-based approach.
XDSButton consumes the group context and applies position-aware border-radius
and divider styles via CSS :first-child/:last-child pseudo-classes.

- ref prop forwarded to root element
- aria-orientation for screen readers
- isDisabled cascades to all child buttons via context
- Roving tabindex keyboard navigation via useListFocus
- Variant-aware divider color (--color-on-accent for primary/destructive)
cixzhang pushed a commit that referenced this pull request Jun 21, 2026
Groups multiple buttons with connected styling using a context-based approach.
XDSButton consumes the group context and applies position-aware border-radius
and divider styles via CSS :first-child/:last-child pseudo-classes.

- ref prop forwarded to root element
- aria-orientation for screen readers
- isDisabled cascades to all child buttons via context
- Roving tabindex keyboard navigation via useListFocus
- Variant-aware divider color (--color-on-accent for primary/destructive)
@cixzhang
cixzhang deleted the worktree-button-group branch June 21, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XDSButtonGroup

2 participants