ui/ Toggleable
Exports the ui/Toggleable.Toggleable Higher-order Component (HOC).
import Toggleable from '@enact/ui/Toggleable';
Members
ToggleableHigher-Order Component
ui/Toggleable.Toggleable is a Higher-order Component that applies a 'Toggleable' behavior to its wrapped component. Its default event and property can be configured when applied to a component.
By default, Toggleable applies the active
property on click events.
import Toggleable from '@enact/ui/Toggleable';
Configuration
- activate
Configures the event name that activates the component.
Note: When using
activate
/deactivate
instead oftoggle
, settoggle
tonull
to prevent passing the defaultonToggle
prop to the wrapped component.- deactivate
Configures the event name that deactivates the component.
Note: When using
activate
/deactivate
instead oftoggle
, settoggle
tonull
to prevent passing the defaultonToggle
prop to the wrapped component.- toggle
Configures the event name that toggles the component.
Default: 'onToggle'- prop
Configures the property that is passed to the wrapped component when toggled.
Default: 'active'
Properties added to wrapped component
- defaultPropKey
Default toggled state applied at construction when the toggled prop is
undefined
ornull
.Default: false- disabled
Whether or not the component is in a disabled state.
- prop
Current toggled state. When set at construction, the component is considered "controlled" and will only update its internal value when updated by new props. If undefined, the component is "uncontrolled" and
Toggleable
will manage the toggled state using callbacks defined by its configuration.- toggle
Event callback to notify that state should be toggled.