Skip to content

Radio

The ERadio allow users to choose one option from a set. Demo Here

Usage

The ERadio and ERadioGroup components are used together as below:

jsx

// Index Value

const RadioExample = () => {
  const [value, SetValue] = useState(0);

  const handleChange = (event, index) => {
      SetValue(index); //* Zero based
  };

  return (
      <ERadioGroup value={value}>
          <ERadio>Radio 1</ERadio>
          <ERadio>Radio 2</ERadio>
          <ERadio>Radio 3</ERadio>
          <ERadio>Radio 4</ERadio>
      </ERadioGroup>
  );
};

export default RadioExample;
jsx

// User Custom Value

const RadioExample = () => {
  const [value, SetValue] = useState("second");

  const handleChange = (event, value) => {
      SetValue(value);
  };

  return (
      <ERadioGroup value="value">
          <ERadio value="first">Radio 1</ERadio>
          <ERadio value="second">Radio 2</ERadio>
          <ERadio value="third">Radio 3</ERadio>
          <ERadio value="fourth">Radio 4</ERadio>
      </ERadioGroup>
  );
};

export default RadioExample;

Props

For ERadioGroup component, the following props are available:

PropTypeDefaultNote
value[String, Number]falseValue of the selected radio button.
disabledBooleanfalseDisables the radio buttons.
labelString-Component's label
messageString-Adds a message below the element.
verticalBooleanfalseIt organizes your radios vertically.
classNameString-Overrides or extends the component's styles.
rulesArray-Validation rules. For more info refer to Form Validation.
validateOnString"input"Triggers validation on @values: submit, input.
stateString-Validates the user-provided data against established criteria and performs display validation. States can be none if no validation is necessary, danger if the selected is valid, or success if it is acceptable.
nameString-HTML name attribute..
sizeString"md"The ERadioGroup element has three predefined sizes: sm, md, lg.
alignStringstartSpecifies how the pagination buttons are distributed along the cross axis in a container.
colorString"primary"The given color is applied to the element - utility colors are supported (e.g primary or danger). you'll find a list of built-in classes on the src/styles/_vars.scsspage.

For ERadio component, the following props are available:

PropTypeDefaultNote
idString-HTML id attribute.
disabledBooleanfalseDisables the ERadio.
classNameString-Overrides or extends the component's styles.
sizeString"md"The ERadio element has three predefined sizes: sm, md, lg.
value[String, Number]falseYou can Add your own value. If not, we will default to the index of the child position.
colorString"primary"The given color is applied to the element - utility colors are supported (e.g primary or danger). you'll find a list of built-in classes on the src/styles/_vars.scsspage.
stateString-Validates the user-provided data against established criteria and performs display validation. States can be none if no validation is necessary, danger if the selected is valid, or success if it is acceptable.

Callback Functions

The ERadio component contains following callback functions.

FunctionDescription
onChangeControls the value of the element.function(event: React.SyntheticEvent, value: String) => void 👇

event: The event source of the callback.
value: selected radio value.

COPYRIGHT