Help Hint¶
A small help icon button for next to a label, with a bubble that explains the field. The bubble shows on hover and focus, and a click or tap toggles it.
Decision¶
| When | Use |
|---|---|
A long explanation that would crowd a fieldDescription |
Help Hint |
| Inserting tokens into a field | Placeholder Hint |
Usage¶
import { createHelpHint } from './configurationpage?name=myplugin_stolon.js';
label.appendChild(createHelpHint({ text: 'Seconds between checks.' }).element);
Classes: stolon-help, stolon-help-button, stolon-help-tip. The handle is { element, getValue, setValue, show, hide, destroy }.
States and Modifiers¶
textis the plain text explanation and is required. Without itcreateHelpHintthrows.label("Help") names the button.icondefaults tohelp_outline.- The button is a Row Button,
stolon-row-btn stolon-help-button. - The bubble shows on hover, focus within, and the
stolon-openmodifier. The button is described by the bubble througharia-describedby. - Hover and focus show it while they last. A click pins it open until a second click, Escape, or a click outside.
show()andhide()pin and unpin it from code. getValue()returns the text andsetValuereplaces it.
Reference¶
Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.
createHelpHint¶
function createHelpHint(options: HelpHintOptions): HelpHintHandle
A small help icon button for next to a label, with a bubble that explains the field. The bubble shows on hover and focus, and a click or tap toggles it. The button is described by the bubble through aria-describedby, and Escape or a click outside closes it.
| Option | Type | What it does |
|---|---|---|
text (required) |
string |
the explanation, plain text [required] |
label |
string |
aria-label of the button (default 'Help') |
icon |
string |
Material icon name (default 'help_outline') |
| Handle member | Type |
|---|---|
getValue |
(): string |
setValue |
(text: string): void |
show |
(): void |
hide |
(): void |
destroy |
(): void |
| Class | What it looks like |
|---|---|
stolon-help |
Inline wrapper for a help icon button and its bubble, which shows on hover, focus, and a tap |
stolon-help-tip |
Bubble on the stolon-float surface, fixed to the viewport, that explains the field, placed by the hint beside its icon, and hidden until the hint is hovered, focused, or open |
Example¶
Example Code¶
<!-- title: Help Hint -->
<!-- min-height: 160 -->
<div id="mount"></div>
<script type="module">
const base = await window.__baseReady;
const view = document.getElementById('view');
const mount = document.getElementById('mount');
mount.innerHTML = '<div class="inputContainer"><label for="interval">Check interval <span id="slot"></span></label><input id="interval" type="text" value="30"></div>';
document.getElementById('slot').appendChild(base.createHelpHint({ text: 'Seconds between checks. A low value adds load on the server.' }).element);
</script>