Skip to main content

Radio

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

'use client';

import { Radio } from 'rizzui/radio';

Default

The default style of Radio component.

'use client';

import { Radio } from 'rizzui/radio';

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

Variants

You can change the style of Radio using variant property.

'use client';

import { Radio } from 'rizzui/radio';

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.

'use client';

import { Radio } from 'rizzui/radio';

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" />
</>
);
}

Label Placement

You can set label on the two different sides using labelPlacement property.

'use client';

import { Radio } from 'rizzui/radio';

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.

'use client';

import { Radio } from 'rizzui/radio';

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

With Helper Text

You can add helper text to Radio.

Hi! My name is John Doe.
'use client';

import { Radio } from 'rizzui/radio';

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.

'use client';

import { Radio } from 'rizzui/radio';

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. Can be a string or a React component__
labelClassNamestringUse labelClassName prop to apply some additional style for the field label__
inputClassNamestringAdd custom classes for the input field 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';