import * as React from "react"; import * as System from "~/components/system"; import * as Constants from "~/common/constants"; import Group from "~/components/system/Group"; import SystemPage from "~/components/system/SystemPage"; import ViewSourceLink from "~/components/system/ViewSourceLink"; import CodeBlock from "~/components/system/CodeBlock"; export default class SystemPageToggles extends React.Component { state = { three: true, four: false, }; _handleChange = (e) => { this.setState({ [e.target.name]: e.target.value }); }; render() { return ( Toggles

The Toggle component is used to switch between two states.


Imports

Import React and the Toggle Component.

{`import * as React from "react"; import { Toggle } from "slate-react-system";`}

Usage

Declare the Toggle component.
{`class ExampleOne extends React.Component { state = { exampleOne: true }; _handleChange = (e) => this.setState({ [e.target.name]: e.target.value }); render() { return ( ); } } class ExampleTwo extends React.Component { state = { exampleTwo: false }; _handleChange = (e) => this.setState({ [e.target.name]: e.target.value }); render() { return ( ); } } `}

Output






Accepted React Properties

onChange ), b: "function", c: "null", d: "Function called upon an onChange event", }, { id: 2, a: ( active ), b: "boolean", c: "false", d: "The value that the dropdown takes. Can be used to assign default values as well.", }, { id: 3, a: "name", b: "string", c: "null", d: "Input name", }, { id: 4, a: "label", b: "string", c: "null", d: "Label text", }, { id: 5, a: "description", b: "string", c: "null", d: "Description text", }, { id: 6, a: "tooltip", b: "string", c: "null", d: "Tooltip text", }, ], }} />
); } }