Skip to content
Draft
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/tasty-cheetahs-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': major
---

Update Checkbox component to no longer support sx
7 changes: 1 addition & 6 deletions packages/react/src/Checkbox/Checkbox.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,7 @@
"name": "as",
"type": "React.ElementType",
"defaultValue": "\"input\""
},
{
"name": "sx",
"type": "SystemStyleObject",
"deprecated": true
}
],
"subcomponents": []
}
}
2 changes: 1 addition & 1 deletion packages/react/src/Checkbox/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import FormControl from '../FormControl'
import type {FormControlArgs} from '../utils/form-story-helpers'
import {formControlArgTypesWithoutValidation, getFormControlArgsByChildComponent} from '../utils/form-story-helpers'

const excludedControlKeys = ['required', 'value', 'validationStatus', 'sx']
const excludedControlKeys = ['required', 'value', 'validationStatus']

export default {
title: 'Components/Checkbox',
Expand Down
29 changes: 2 additions & 27 deletions packages/react/src/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {clsx} from 'clsx'
import {useProvidedRefOrCreate} from '../hooks'
import React, {useContext, useEffect, type ChangeEventHandler, type InputHTMLAttributes, type ReactElement} from 'react'
import {type SxProp} from '../sx'
import useLayoutEffect from '../utils/useIsomorphicLayoutEffect'
import type {FormValidationStatus} from '../utils/types/FormValidationStatus'
import {CheckboxGroupContext} from '../CheckboxGroup/CheckboxGroupContext'
import classes from './Checkbox.module.css'
import sharedClasses from './shared.module.css'
import Box from '../Box'

export type CheckboxProps = {
/**
Expand Down Expand Up @@ -35,27 +33,14 @@ export type CheckboxProps = {
* Used during form submission and to identify which checkbox inputs are selected
*/
value?: string
} & Exclude<InputHTMLAttributes<HTMLInputElement>, 'value'> &
SxProp
} & Exclude<InputHTMLAttributes<HTMLInputElement>, 'value'>

/**
* An accessible, native checkbox component
*/
const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
(
{
checked,
className,
defaultChecked,
indeterminate,
disabled,
onChange,
sx: sxProp,
required,
validationStatus,
value,
...rest
},
{checked, className, defaultChecked, indeterminate, disabled, onChange, required, validationStatus, value, ...rest},
ref,
): ReactElement => {
const checkboxRef = useProvidedRefOrCreate(ref as React.RefObject<HTMLInputElement>)
Expand Down Expand Up @@ -99,16 +84,6 @@ const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
}
})

if (sxProp) {
return (
<Box
as="input"
{...inputProps}
className={clsx(className, sharedClasses.Input, classes.Checkbox)}
sx={sxProp}
/>
)
}
return <input {...inputProps} className={clsx(className, sharedClasses.Input, classes.Checkbox)} />
},
)
Expand Down
Loading