Igloo branding

Toggle

Toggle is a component used for binary choice for a given option.

Installation

To install @igloo-ui/toggle in your project, you will need to run the following command using npm:

npm install @igloo-ui/toggle

If you prefer Yarn, use the following command instead:

yarn add @igloo-ui/toggle

Usage

import Toggle from '@igloo-ui/toggle';

<Toggle htmlFor="toggle-id">Label</Toggle>;

API

PropTypeDescription
childrenReactNodeThe content to display inside the label
classNamestringAdd a specific class to the toggle
dataTeststringAdd a data-test tag for automated tests
htmlForstringIndicates the ID of the element that is controlled by the toggle
checkedbooleanModifies true/false value of the toggle
helperTextstringThe content to display to help users
onChange(e: ChangeEvent<HTMLInputElement>) => voidFunction called when the value changes