ToggleButton
A specialized call button that triggers toggle behavior on a referenced target element.
import { ToggleButton } from "@schukai/monster/source/components/host/toggle-button.mjs";Introduction
The Monster ToggleButton is a focused variant of CallButton that invokes toggle() on a referenced element. Use it when an overlay, collapse or similar component should be opened and closed from one trigger.
When to use ToggleButton
- Use it for binary open-close interactions: Especially useful for overlays, drawers and collapsible sections.
- Use it when the target already exposes
toggle(): The button stays declarative and concise. - Do not use it when behavior is not truly toggle-based: Explicit open or close actions may be clearer.
Toggle Button
A toggle button that calls toggle() on a collapse element.
Javascript
import '@schukai/monster/source/components/host/toggle-button.mjs';
import '@schukai/monster/source/components/layout/collapse.mjs';<script type="module">import '@schukai/monster/source/components/host/toggle-button.mjs';
import '@schukai/monster/source/components/layout/collapse.mjs';</script>HTML
<monster-collapse class="toggle-target" data-monster-option-labels-title="Section">
<div slot="content">Collapsible content</div>
</monster-collapse>
<monster-toggle-button data-monster-reference=".toggle-target">
Toggle section
</monster-toggle-button>Stylesheet
/** no additional stylesheet is defined **/Component Design
The toggle button inherits the call button structure and exposes the same part for styling.
control: Wrapper around the toggle button.
monster-toggle-button::part(control) {
display: inline-flex;
}
HTML Structure
<monster-toggle-button></monster-toggle-button>JavaScript Initialization
const element = document.createElement('monster-toggle-button');
document.body.appendChild(element);Exported
ToggleButtonDerived from
CallButtonOptions
The Options listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the CallButton.
- since
- deprecated
Properties and Attributes
The Properties and Attributes listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits Properties and Attributes from these parent classes. If you cannot find a specific Properties and Attributes in this list, we recommend consulting the documentation of the CallButton.
data-monster-options: Sets the configuration options for the collapse component when used as an HTML attribute.data-monster-option-[name]: Sets the value of the configuration option[name]for the collapse component when used as an HTML attribute.
Methods
The methods listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the CallButton.
Static methods
[instanceSymbol]()- {symbol}
instanceof operator.getTag()- {string}
Events
This component does not fire any public events. It may fire events that are inherited from its parent classes.