Radio
The Radio component is designed for selecting a single option from a set of mutually exclusive choices. It features a clear and intuitive interface, displaying radio buttons that users can select with a simple click.
Installation
Install the package
npm i @start-base/react-form-elementsAdd the styles
To use the React form elements styles in a Next.js project, import the styles in your layout.tsx file.
app/layout.tsx
import "@start-base/react-form-elements/styles.css";Import the component
import Radio from '@start-base/react-form-elements/Radio';Usages
Radio Component Checked
Radio Component Disabled
Radio Component Error
API
A basic radio input component.
| Name | Type | Default | Description |
|---|---|---|---|
| name | string | Name of the input | |
| label | string | null | Label of the input |
| onChange | function | Callback function that is fired when the value changes. | |
| inputClassName | string | null | Classname for input element |
| labelClassName | string | null | Classname for label element |
| errorClassName | string | null | Classname for error element |
| disabled | boolean | false | Disable the input |
| error | string or boolean or object | null | Error message to display below the input. if value is a boolean input border will be change. Also you can pass schema validator error objects. |
| checked | boolean | false | Checked state of the radio |