From a15f8e1083aa4105fcbf5eb51f1eb022ed9dcf7a Mon Sep 17 00:00:00 2001 From: kemuru <102478601+kemuru@users.noreply.github.com> Date: Tue, 26 May 2026 21:23:21 +0200 Subject: [PATCH 1/2] feat: custom-radio --- src/lib/form/custom-radio.tsx | 115 ++++++++++++++++++++++++++++ src/lib/form/radio-group.tsx | 28 ++----- src/lib/form/radio-indicator.tsx | 56 ++++++++++++++ src/lib/index.ts | 5 ++ src/stories/customRadio.stories.tsx | 103 +++++++++++++++++++++++++ 5 files changed, 285 insertions(+), 22 deletions(-) create mode 100644 src/lib/form/custom-radio.tsx create mode 100644 src/lib/form/radio-indicator.tsx create mode 100644 src/stories/customRadio.stories.tsx diff --git a/src/lib/form/custom-radio.tsx b/src/lib/form/custom-radio.tsx new file mode 100644 index 0000000..433b768 --- /dev/null +++ b/src/lib/form/custom-radio.tsx @@ -0,0 +1,115 @@ +import React, { ReactNode } from "react"; +import { + Radio as AriaRadio, + RadioGroup as AriaRadioGroup, + FieldError, + type FieldErrorProps, + Label, + type RadioGroupProps as AriaRadioGroupProps, + type RadioProps as AriaRadioProps, + type RadioRenderProps, +} from "react-aria-components"; +import { cn } from "../../utils"; +import { RadioIndicator } from "./radio-indicator"; + +export { RadioIndicator }; + +interface CustomRadioItemProps extends Omit { + className?: string; +} + +/** A single radio whose content is fully owned by the caller. Use the render-prop + * `children` to receive `{ isSelected, isHovered, isFocusVisible, ... }` and compose your + * own UI (cards, labels, ...), placing a `` where you want it. Renders a + * `