Skip to content

Instantly share code, notes, and snippets.

@EduardoAC
Last active March 29, 2025 15:40
Show Gist options
  • Save EduardoAC/220b3510ee05b585f8ac2524becdb24c to your computer and use it in GitHub Desktop.
Save EduardoAC/220b3510ee05b585f8ac2524becdb24c to your computer and use it in GitHub Desktop.
Using ReactNode as a Prop - The simplest way to customize the label is to pass a ReactNode (JSX element) instead of a string.
export function RadioButtonGroup({ optionList, selected }: RadioButtonGroupProps) {
return (
<div className="radio-button-group">
{optionList.map((option) => (
<div
key={option.value}
disabled={option.disabled}
className={selected === type.value && 'option--active' || ''}
>
{option.icon && <span className={`icon-${option.icon}`} />}
{option.label} {/* ReactNode allows full flexibility here */}
</div>
))}
</div>
);
};
// Usage in Parent Component
<RadioButtonGroup optionList={suggestDepositAmounts} />;
const suggestDepositAmounts = [
{
value: "100",
label: <CustomElement labelText="100 RSD" />,
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment