Skip to content

Commit 6908968

Browse files
committed
use children for label content in checkbox/radio cmp
1 parent 668a3e3 commit 6908968

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/scripts/Checkbox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const Checkbox: FC<CheckboxProps> = (props) => {
3232
cols,
3333
elementRef,
3434
inputRef,
35+
children,
3536
...rprops
3637
} = props;
3738
const { grouped } = useContext(CheckboxGroupContext);
@@ -41,7 +42,7 @@ export const Checkbox: FC<CheckboxProps> = (props) => {
4142
<label className={checkClassNames}>
4243
<input ref={inputRef} type='checkbox' {...rprops} />
4344
<span className='slds-checkbox_faux' />
44-
<span className='slds-form-element__label'>{label}</span>
45+
<span className='slds-form-element__label'>{label || children}</span>
4546
</label>
4647
);
4748
return grouped ? (

src/scripts/Radio.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const Radio: FC<RadioProps> = ({
2323
value,
2424
inputRef,
2525
onChange: onChange_,
26+
children,
2627
...props
2728
}) => {
2829
const { name: grpName, onValueChange } = useContext(RadioGroupContext);
@@ -46,7 +47,7 @@ export const Radio: FC<RadioProps> = ({
4647
{...props}
4748
/>
4849
<span className='slds-radio_faux' />
49-
<span className='slds-form-element__label'>{label}</span>
50+
<span className='slds-form-element__label'>{label || children}</span>
5051
</label>
5152
);
5253
};

0 commit comments

Comments
 (0)