Guide
Form Elements
Radio

Radio Component

Radio is a React component designed to create customizable input fields with options such as color, label, name, and more. It supports different sizes and colors along with disabled and checked states.

Example Preview

Radio Example

Usage

import { Radio } from "@/@core";
 
// ...
 
const MyComponent = () => {
  return (
    <Fragment>
      <Radio
        defaultChecked
        name="radio-1"
        color="primary"
        label="Primary Radio"
      />
      <Radio
        checked
        name="radio-1"
        color="error"
        size="lg"
        label="Large Error Radio"
      />
      <Radio disabled label="Disabled Radio" />
    </Fragment>
  );
};
 
export default MyComponent;

Props

Prop nameTypeDefault valueRequiredDescription
checkedboolean-NoBoolean indicating whether the checkbox is checked.
namestring-YesString representing the name of the radio button.
defaultCheckedboolean-NoBoolean indicating the default checked state.
colorprimary, secondary, error, success, warning, info, accent-NoString representing the color theme of the checkbox.
labelstring-NoString representing the label text for the checkbox.
disabledboolean-NoBoolean indicating whether the checkbox is disabled.
sizexs, sm, md, lg-NoString representing the size of the checkbox.
classNamestring-NoAdditional class names for styling purposes.
propsHTMLAttributes<HTMLInputElement>-NoAdditional HTML attributes can be passed as well.

Styling

The component provides various styling options based on the color and size props. The label text size and color can be customized accordingly.

Customizing Example

import { Radio } from "@/@core";
 
const MyComponent = () => {
  const [checked, setChecked] = useState(false);
 
  return (
    <Fragment>
      <Radio
        checked={checked}
        color="primary"
        label="Primary Radio"
        name="radio-1"
        className="checked:border-indigo-800 [--chkbg:theme(colors.indigo.600)] [--chkfg:orange]"
        onChange={() => setChecked(!checked)}
      />
      <Radio
        defaultChecked
        color="primary"
        label="Primary Radio"
        name="radio-1"
        className="[--chkbg:oklch(var(--a))] [--chkfg:oklch(var(--p))]"
      />
    </Fragment>
  );
};
 
export default MyComponent;

All Available Props

import { Radio } from '@/@core';
 
// ...
 
const AllAvailableProps = () => {
   return (
      <Fragment>
         <Radio
            checked={/* boolean */}
            defaultChecked={/* boolean */}
            color={/* 'primary' | 'secondary' | 'error' | 'success' | 'warning' | 'info' | 'accent' */}
            label={/* string */}
            disabled={/* boolean */}
            size={/* 'xs' | 'sm' | 'md' | 'lg' */}
            name={/* string */}
            className={/* string */}
            /* Other HTML attributes for the input element */
          />
      </Fragment>
   );
};
 
export default AllAvailableProps;
ℹ️

Note: The Radio component is inspired by the DaisyUI (opens in a new tab) framework. Check it out for more awesome components. But our Radio component is dynamic and easy to use. It is also fully customizable.