Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/light-colts-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': major
---

Remove support for `sx` from `ButtonGroup`
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 0 additions & 4 deletions e2e/components/ButtonGroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ const stories = [
title: 'Overrides',
id: 'components-buttongroup-dev--link-button-with-icon-buttons',
},
{
title: 'SX Prop',
id: 'components-buttongroup-dev--sx-prop',
},
] as const

test.describe('ButtonGroup', () => {
Expand Down
12 changes: 2 additions & 10 deletions packages/react/src/ButtonGroup/ButtonGroup.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const meta: Meta<typeof ButtonGroup> = {
export default meta

export const LinkAndButtonWithTooltip2 = () => (
<ButtonGroup sx={{pl: 2}}>
<ButtonGroup style={{paddingLeft: '8px'}}>
<Tooltip text="Additional info about the link">
<Button as="a" href="https://primer.style">
Link
Expand All @@ -35,7 +35,7 @@ export const LinkAndButtonWithTooltip2 = () => (
)

export const ButtonAndLinkWithTooltip2 = () => (
<ButtonGroup sx={{pl: 2}}>
<ButtonGroup style={{paddingLeft: '8px'}}>
<IconButton icon={CopilotIcon} aria-label="Open GitHub Copilot chat" />
<Tooltip text="Additional info about the link">
<Button as="a" href="https://primer.style">
Expand All @@ -62,11 +62,3 @@ export const LinkButtonWithIconButtons = () => (
<IconButton icon={CopilotIcon} aria-label="Open GitHub Copilot chat" />
</ButtonGroup>
)

export const SxProp = () => (
<ButtonGroup sx={{border: '1px solid red'}}>
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
</ButtonGroup>
)
5 changes: 0 additions & 5 deletions packages/react/src/ButtonGroup/ButtonGroup.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
],
"importPath": "@primer/react",
"props": [
{
"name": "sx",
"type": "SystemStyleObject",
"deprecated": true
},
{
"name": "ref",
"type": "React.RefObject<HTMLDivElement>"
Expand Down
15 changes: 6 additions & 9 deletions packages/react/src/ButtonGroup/ButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import React, {type PropsWithChildren} from 'react'
import {type SxProp} from '../sx'
import classes from './ButtonGroup.module.css'
import {clsx} from 'clsx'
import {FocusKeys, useFocusZone} from '../hooks/useFocusZone'
import {useProvidedRefOrCreate} from '../hooks'
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
import {BoxWithFallback} from '../internal/components/BoxWithFallback'

export type ButtonGroupProps = {
export type ButtonGroupProps = PropsWithChildren<{
/** The role of the group */
role?: string
/** className passed in for styling */
className?: string
} & PropsWithChildren &
SxProp
}>

const ButtonGroup = React.forwardRef<HTMLElement, ButtonGroupProps>(function ButtonGroup(
{children, className, role, ...rest},
const ButtonGroup = React.forwardRef(function ButtonGroup(
{as: BaseComponent = 'div', children, className, role, ...rest},
Comment on lines +15 to +16
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The as prop is destructured but not included in the ButtonGroupProps type definition. This creates a mismatch between the component's actual interface and its declared props type, which could confuse consumers and break TypeScript IntelliSense.

Copilot uses AI. Check for mistakes.
forwardRef,
) {
const buttons = React.Children.map(children, (child, index) => <div key={index}>{child}</div>)
Expand All @@ -30,9 +27,9 @@ const ButtonGroup = React.forwardRef<HTMLElement, ButtonGroupProps>(function But
})

return (
<BoxWithFallback ref={buttonRef} className={clsx(className, classes.ButtonGroup)} role={role} {...rest}>
<BaseComponent ref={buttonRef} className={clsx(className, classes.ButtonGroup)} role={role} {...rest}>
{buttons}
</BoxWithFallback>
</BaseComponent>
)
}) as PolymorphicForwardRefComponent<'div', ButtonGroupProps>

Expand Down
Loading