Skip to main content

ToggleInput Component

The <ToggleInput> component provides a unified interface for creating various toggleable input elements like checkboxes, radio buttons, and switches.

Basic Usage

A number of components in the library have a subcomponent feature witch is like a preset of the same component that is frequently used. This component can be used to render checkboxes, radio buttons, and switches by specifying the subcomponent.

note

The component does not have a parent element. That means you can use the component only like a subcomponent.

import { useState } from "react";
import { ToggleInput } from "react-better-html";

function App() {
const [isChecked, setIsChecked] = useState(false);

return (
<ToggleInput.checkbox
label="Remember me"
checked={isChecked}
onChange={setIsChecked}
/>
);
}

Common Props

All standard <input> attributes are valid props for this component.