Update styles and types on Checkbox

Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
This commit is contained in:
Charles de Dreuille
2026-03-12 16:11:56 +00:00
parent 269b85ef0d
commit 9d5f3baf1e
7 changed files with 36 additions and 14 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/ui': minor
---
Removed redundant `selected` and `indeterminate` props from the `Checkbox` component. Use the `isSelected` and `isIndeterminate` props instead, which are the standard React Aria props and already handle both the checkbox behaviour and the corresponding CSS data attributes.
**Affected components:** Checkbox
-8
View File
@@ -830,12 +830,6 @@ export const CheckboxDefinition: {
readonly indicator: 'bui-CheckboxIndicator';
};
readonly propDefs: {
readonly selected: {
readonly dataAttribute: true;
};
readonly indeterminate: {
readonly dataAttribute: true;
};
readonly children: {};
readonly className: {};
};
@@ -843,8 +837,6 @@ export const CheckboxDefinition: {
// @public (undocumented)
export type CheckboxOwnProps = {
selected?: boolean;
indeterminate?: boolean;
children: React.ReactNode;
className?: string;
};
@@ -20,7 +20,7 @@
.bui-Checkbox {
display: flex;
flex-direction: row;
align-items: center;
align-items: flex-start;
gap: var(--bui-space-2);
font-size: var(--bui-font-size-3);
font-family: var(--bui-font-regular);
@@ -16,6 +16,8 @@
import preview from '../../../../../.storybook/preview';
import { Checkbox } from './Checkbox';
import { Flex } from '../Flex';
import { Link } from '../Link';
import { MemoryRouter } from 'react-router-dom';
const meta = preview.meta({
title: 'Backstage UI/Checkbox',
@@ -28,6 +30,12 @@ export const Default = meta.story({
},
});
export const Selected = Default.extend({
args: {
isSelected: true,
},
});
export const Indeterminate = meta.story({
args: {
children: 'Select all',
@@ -35,6 +43,25 @@ export const Indeterminate = meta.story({
},
});
export const WithLongText = Default.extend({
args: {
children: (
<>
I agree to receive future communication from Spotify. You may
unsubscribe from these communications at any time. Please review our{' '}
<Link href="#">Privacy Policy</Link>
</>
),
},
decorators: [
Story => (
<MemoryRouter>
<Story />
</MemoryRouter>
),
],
});
export const AllVariants = meta.story({
...Default.input,
render: () => (
@@ -46,7 +46,7 @@ export const Checkbox = forwardRef<HTMLLabelElement, CheckboxProps>(
<RiCheckLine size={12} />
)}
</div>
{children}
<span>{children}</span>
</>
)}
</RACheckbox>
@@ -29,8 +29,6 @@ export const CheckboxDefinition = defineComponent<CheckboxOwnProps>()({
indicator: 'bui-CheckboxIndicator',
},
propDefs: {
selected: { dataAttribute: true },
indeterminate: { dataAttribute: true },
children: {},
className: {},
},
@@ -17,8 +17,6 @@ import type { CheckboxProps as RACheckboxProps } from 'react-aria-components';
/** @public */
export type CheckboxOwnProps = {
selected?: boolean;
indeterminate?: boolean;
children: React.ReactNode;
className?: string;
};