Skip to main content

RadioGroup

The RadioGroup component is a form control that allows users to select a single option from a set of choices, with support for various styles and states.

Basic Usage

import { RadioGroup, ThemeProvider } from "@carton-org/react-neumorphism";
import { useState } from "react";

const MyComponent = () => {
const [value, setValue] = useState("option1");

const items = [
{ label: "Option 1", value: "option1" },
{ label: "Option 2", value: "option2" },
{ label: "Option 3", value: "option3" },
];

return (
<RadioGroup
items={items}
name="options"
value={value}
onChange={setValue}
/>
);
};

Live Example

Props

NameTypeDescriptionRequiredDefault Value
idstringUnique identifier for the radio groupNo-
size"xs" | "sm" | "md" | "lg" | "xl"Size of the radio buttonsNo"sm"
itemsArray<{ id?: string, label: string, value: string, disabled?: boolean }>Array of radio options to displayYes-
namestringName attribute for the radio groupYes-
valuestringCurrently selected valueYes-
onChange(value: string) => voidCallback function when selection changesNo-
disabledbooleanWhether the entire radio group is disabledNofalse
radioGroupContainerStyleReact.CSSPropertiesCustom styles for the radio group containerNo-
radioContainerStyleReact.CSSPropertiesCustom styles for individual radio containersNo-
radioLabelStyleReact.CSSPropertiesCustom styles for radio labelsNo-

Examples

Different Sizes

Small Size

Medium Size

Large Size

With Disabled Options

Disabled Group