Skip to content

Commit

Permalink
chore: spread className and style on internal Field (#2880)
Browse files Browse the repository at this point in the history
resolves #2772

---------

Co-authored-by: Michael Marszalek <[email protected]>
  • Loading branch information
Barsnes and mimarz authored Dec 11, 2024
1 parent 68a8c3d commit c9c77f7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-monkeys-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@digdir/designsystemet-react": patch
---

Radio, Checkbox: Spread `className` and `style` on outermost element
13 changes: 11 additions & 2 deletions packages/react/src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ export type CheckboxProps = MergeRight<
*/
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
function Checkbox(
{ 'data-size': size, children, label, description, validation, ...rest },
{
'data-size': size,
className,
style,
children,
label,
description,
validation,
...rest
},
ref,
) {
return (
<Field data-size={size}>
<Field data-size={size} className={className} style={style}>
<Input type='checkbox' ref={ref} {...rest} />
{!!label && <Label weight='regular'>{label}</Label>}
{!!description && <div data-field='description'>{description}</div>}
Expand Down
13 changes: 11 additions & 2 deletions packages/react/src/components/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,20 @@ export type RadioProps = MergeRight<
* <Radio label="I agree" value="agree" />
*/
export const Radio = forwardRef<HTMLInputElement, RadioProps>(function Radio(
{ 'data-size': size, children, label, description, validation, ...rest },
{
'data-size': size,
className,
style,
children,
label,
description,
validation,
...rest
},
ref,
) {
return (
<Field data-size={size}>
<Field data-size={size} className={className} style={style}>
<Input type='radio' ref={ref} {...rest} />
{!!label && <Label weight='regular'>{label}</Label>}
{!!description && <div data-field='description'>{description}</div>}
Expand Down

0 comments on commit c9c77f7

Please sign in to comment.