Skip to main content

Radio

A basic widget for getting the user input. used for selecting single value from a list of options.

import { Radio } from "rizzui";

Default

The default style of Radio component.

import { Radio } from "rizzui";

export default function App() {
return <Radio label="Default" />;
}

Variants

You can change the style of Radio using variant property.

import { Radio } from "rizzui";

export default function App() {
return (
<>
<Radio className="m-2" label="Outline" />
<Radio className="m-2" label="Flat" variant="flat" />
</>
);
}

Sizes

You can change the sizes of Radio using size property.

import { Radio } from "rizzui";

export default function App() {
return (
<>
<Radio className="m-2" label="Small" size="sm" />
<Radio className="m-2" label="Default" />
<Radio className="m-2" label="Large" size="lg" />
<Radio className="m-2" label="Extra Large" size="xl" />
</>
);
}

Label Placement

You can set label on the two diffrient side using labelPlacement property.

import { Radio } from "rizzui";

export default function App() {
return (
<>
<Radio className="m-2" label="Left Placement" labelPlacement="left" />
<Radio className="m-2" label="Right Placement" labelPlacement="right" />
</>
);
}

Disabled

You can change style of Radio using disabled property.

import { Radio } from "rizzui";

export default function App() {
return <Radio className="m-2" label="Remember Me" disabled />;
}

With Helper Text

You can add helper text to Radio.

import { Radio } from "rizzui";

export default function App() {
return (
<Radio
className="m-2"
helperText="Hi! My name is John Doe."
label="John"
value="john"
/>
);
}

With Error Message

You can show the validation error message using error property.

import { Radio } from "rizzui";

export default function App() {
return (
<Radio
className="m-2"
error="This field is required"
label="Yes"
value="yes"
/>
);
}

API Reference


Radio Props

Here is the API documentation of the radio component. And the rest of the props of radio are the same as the original html input field.

PropsTypeDescriptionDefault
labelReactNodeSet field label__
labelWeightLabelWeightSet label font weight"medium"
labelPlacementleft rightAvailable directions of the label are:"right"
variantRadioVariantsThe variants of the component are:"outline"
sizeRadioSizesThe size of the component.
"sm" is equivalent to the dense radio styling.
"md"
disabledbooleanWhether the radio is disabled__
errorstringShow error message using this prop__
helperTextReactNodeAdd helper text. It could be string or a React component__
labelClassNamestringUse labelClassName prop to apply some addition style for the field label__
inputClassNamestringAdd custom classes for the input filed extra style__
helperClassNamestringThis prop allows you to customize the helper message style__
errorClassNamestringThis prop allows you to customize the error message style__
classNamestringAdd custom classes to the root of the component__
refRef<HTMLInputElement>__
...InputHTMLAttributesnative props like value, onChange, onFocus, onBlur ...__

Radio Variants

type RadioVariants = "outline" | "flat";

Label Weight

type LabelWeight = "normal" | "medium" | "semibold" | "bold";

Radio Sizes

type RadioSizes = "sm" | "md" | "lg" | "xl";