A toggle component to use wherever boolean based form fields are needed.

Parameters:
NameTypeDescription
propsobject

Component props.

Properties
NameTypeDescription
ariaLabelstring

The aria-label text for the toggle.

childrenJSX.Element

React element children.

customAttributesobject

Custom attributes for the component.

customClassesstring | Array | object

Custom classes for the component.

disabledboolean

If toggle is disabled.

externalCheckedboolean

If toggle is checked or not, can change current checked state if changed.

externalControlboolean

If toggle can be controlled externally.

helpTextAttributesobject

Attributes for the help text component.

helpTextWidthstring

Width of the help text, one of auto or full.

iconsboolean

Do we use the checkmark and x icons for this instance.

iconPrefixstring

The icon prefix to use for the icons.

iconBeforestring

The icon to use when the toggle is unchecked.

iconAfterstring

The icon to use when the toggle is checked.

idstring

Id for the toggle, auto generated if not passed.

initialCheckedboolean

Is it checked on render?

labelAttributesobject

Attributes for the label component.

labelPositionstring

Position of the label, one of left or right.

namestring

Name for the input.

onBlurfunction

On blur function handler.

onChangefunction

On change function handler.

onFocusfunction

On focus function handler.

sizestring

Size for the toggle. Small (size-s), medium (size-m), or large (size-l).

spacingstring | number | Array | object

The spacing for the component, as a string, number, array, or object.

themestring

Theme for the toggle, one of primary or cosmos.

widthstring

Width for the toggle, one of auto or full.

wrapperAttributesobject

Custom attributes for the wrapper element.

wrapperClassesstring | Array | object

Custom classes for the wrapper element.

wrapperTagNameobject

Tag to use for the toggle wrapper. Defaults to div.

refobject | null

Ref to the component.

Since
  • 1.1.15
Returns:

The toggle component.

Type: 
JSX.Element
Example
import Toggle from '@gravityforms/components/react/admin/elements/Toggle';

return <Toggle disabled={ true } initialChecked={ true } onChange={ () => {} } />;