ControlBar
A responsive control bar that groups multiple controls and moves overflowed controls into a menu.
import { ControlBar } from "@schukai/monster/source/components/form/control-bar.mjs";Introduction
The Monster ControlBar groups controls, keeps them aligned and moves overflowed controls into a popper when space is limited. It is useful for dense application surfaces where buttons, filters and secondary actions need to stay in one command row.
When to use ControlBar
- Use it for responsive command surfaces: Toolbars, list controls, editor headers and filter rows can keep their primary controls visible while secondary controls move into overflow.
- Use it with mixed controls: The bar accepts Monster buttons, select controls, native inputs and grouped child elements.
- Use
monster-control-bar-spacerfor groups: The spacer is non-interactive and turns into a horizontal separator inside the overflow popper. - Do not use it as page layout: It is a control grouping component, not a replacement for panel, board or split layout components.
Responsive layout contract
Layout options can be set as HTML attributes or through setOption(). Use layout.stackedBreakpoint when the bar should change alignment below a measured width and layout.stackedBreakpointContainer when that width should come from a surrounding element.
<monster-control-bar
data-monster-option-layout-alignment="left"
data-monster-option-layout-stacked-breakpoint="360px"
data-monster-option-layout-stacked-alignment="center">
...
</monster-control-bar>Events
The component emits monster-control-bar-layout-changed when its responsive layout state changes. The event detail reports the effective alignment, configured alignment, stacked state and configured breakpoint values.
Typical mistakes
Do not hide overflow actions with page CSS. Let the control move items into the popper. Do not rely on internal slot order; use documented options and events when reacting to layout changes.
Control Bar
This example shows monster-control-bar with grouped actions, a native input and monster-control-bar-spacer. Resize the available width to see controls move into overflow and watch the layout event update the status text.
Javascript
import "@schukai/monster/source/components/form/button.mjs";
import "@schukai/monster/source/components/form/control-bar.mjs";
import "@schukai/monster/source/components/form/control-bar-spacer.mjs";
await customElements.whenDefined("monster-control-bar");
const widthInput = document.getElementById("control-bar-width");
const frame = document.getElementById("control-bar-frame");
const controlBar = document.getElementById("workflow-control-bar");
const status = document.getElementById("control-bar-status");
let layoutSummary = "waiting for first layout event";
const updateStatus = () => {
status.textContent =
"Width: " + widthInput.value + "px. Layout: " + layoutSummary + ".";
};
const updateWidth = () => {
frame.style.maxWidth = widthInput.value + "px";
updateStatus();
};
controlBar.addEventListener("monster-control-bar-layout-changed", (event) => {
const detail = event.detail;
layoutSummary =
(detail.stacked ? "stacked" : "inline") +
", alignment " +
detail.alignment;
updateStatus();
});
widthInput.addEventListener("input", updateWidth);
updateWidth();HTML
<section class="control-bar-example">
<label class="control-bar-width-control" for="control-bar-width">
Available width
<input id="control-bar-width" type="range" min="260" max="760" step="10" value="420" />
</label>
<div id="control-bar-frame" class="control-bar-frame">
<monster-control-bar
id="workflow-control-bar"
data-monster-option-layout-alignment="left"
data-monster-option-layout-stacked-breakpoint="340px"
data-monster-option-layout-stacked-alignment="center"
data-monster-option-layout-stacked-breakpoint-container="#control-bar-frame"
>
<monster-button>Save</monster-button>
<monster-button>Preview</monster-button>
<monster-control-bar-spacer></monster-control-bar-spacer>
<input aria-label="Filter records" placeholder="Filter records" />
<monster-button>Export</monster-button>
<monster-button>Archive</monster-button>
</monster-control-bar>
</div>
<p id="control-bar-status" class="control-bar-status">
Width: 420px. Layout changes are reported by monster-control-bar-layout-changed.
</p>
</section>Stylesheet
.control-bar-example {
display: grid;
gap: var(--monster-space-4);
}
.control-bar-width-control {
color: var(--monster-color-primary-1);
display: grid;
gap: var(--monster-space-2);
}
.control-bar-frame {
background: var(--monster-bg-color-primary-1);
border-color: var(--monster-color-border-primary-2);
border-radius: var(--monster-border-radius);
border-style: var(--monster-border-style);
border-width: var(--monster-border-width);
max-width: 420px;
padding: var(--monster-space-3);
}
.control-bar-frame input {
min-width: 10rem;
}
.control-bar-status {
color: var(--monster-color-primary-1);
margin: 0;
}Component Design
ControlBar uses Shadow DOM to measure available space, keep visible controls in the main row and move overflowed controls into a popper slot. Slotted controls remain the source of truth; the component changes placement, not the public control contract.
Public styling surface
Use Monster tokens and exposed parts for styling. Avoid selectors that depend on the internal measurement structure or temporary slot assignment.
Available Part Attributes
control: The outer control container.popper-nav: The navigation area that contains the overflow trigger.popper-switch: The button that opens the overflow popper.separator: Exposed bymonster-control-bar-spacer.
Useful custom properties
--monster-control-bar-height: Shared control height for the bar.--monster-control-bar-select-min-inline-size: Minimum width for slotted select controls.--monster-control-bar-spacer-line-color: Separator color for spacers.
monster-control-bar {
--monster-control-bar-height: 2.75rem;
}
monster-control-bar::part(popper-switch) {
border-radius: var(--monster-border-radius);
}Accessibility
Controls keep their own accessible names and behavior while the bar manages overflow placement. The spacer is decorative and sets aria-hidden="true".
HTML Structure
<monster-control-bar></monster-control-bar>JavaScript Initialization
const element = document.createElement('monster-control-bar');
document.body.appendChild(element);Exported
ControlBarDerived from
CustomElementOptions
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 CustomElement.
- 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 CustomElement.
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 CustomElement.
Behavioral methods
hideDialog()- {ControlBar}
showDialog()- {ControlBar}
toggleDialog()- {ControlBar}
Structural methods
setOption(path,value)path{string}: pathvalue{*}: value
- {ControlBar}
Static methods
[instanceSymbol]()- {symbol}
instanceof operator.getCSSStyleSheet()- {CSSStyleSheet[]}
getTag()- {string}
observedAttributes()- {string[]}
attributeChangedCallback().Lifecycle methods
Lifecycle methods are called by the environment and are usually not intended to be called directly.
[assembleMethodSymbol]()connectedCallback()- {void}
disconnectedCallback()- {void}
Events
The component emits the following events:
monster-control-bar-layout-changed
For more information on how to handle events, see the mdn documentation.