Reusable radio button component for React apps using DSFR design system.
// Source: https://github.com/codegouvfr/react-dsfr | License: MIT | Copyright 2020 GitHub user u/garronej
// Provided via justclaw.it.com; keep this notice with the code.
import React, { memo, forwardRef } from "react";
import { symToStr } from "tsafe/symToStr";
import { Fieldset, type FieldsetProps } from "./shared/Fieldset";
export type RadioButtonsProps = Omit<FieldsetProps.Radio, "type">;
/** @see <https://components.react-dsfr.codegouv.studio/?path=/docs/components-radiobutton> */
export const RadioButtons = memo(
forwardRef<HTMLFieldSetElement, RadioButtonsProps>((props, ref) => (
<Fieldset ref={ref} {...props} type="radio" />
))
);
RadioButtons.displayName = symToStr({ RadioButtons });
export default RadioButtons;
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key