Tooltip & popover
A tooltip is a short label that appears on hover, keyboard focus or a long press. A popover is a small floating panel you open with a click, for filters, details or quick edits.
Tooltip
Add data-momo-tooltip="Text" to any element. Icon-only buttons without a label get the tooltip text as their name. data-momo-placement picks the side (it flips when there's no room); data-momo-kbd adds a shortcut.
<button class="btn btn-icon" type="button" data-momo-tooltip="Edit"><i class="mi mi-pencil"></i></button>
<button class="btn btn-icon" type="button" data-momo-tooltip="Delete" data-momo-placement="bottom"><i class="mi mi-trash-2"></i></button>
<button class="btn btn-icon" type="button" data-momo-tooltip="Share" data-momo-placement="right"><i class="mi mi-share-2"></i></button>
<button class="btn" type="button" data-momo-tooltip="Search everything" data-momo-kbd="Ctrl K"><i class="mi mi-search"></i> Search</button>
<span class="badge" tabindex="0" data-momo-tooltip="Synced 2 minutes ago">Saved</span>Keep tooltips short and never put the only copy of important information in one: touch users only see it with a long press.
Popover
Give a button data-momo-popover="id" and add a .popover with that id. It opens next to the button and focuses the first field. Esc or a button with data-momo-close closes it. Like dialogs, it stays open on an outside click unless it has data-momo-close-outside.
Filter tasks
Working on the website redesign. Usually replies within an hour.
<button class="btn" type="button" data-momo-popover="pop-filter"><i class="mi mi-sliders-horizontal"></i> Filter</button>
<div class="popover" id="pop-filter" aria-label="Filter tasks">
<h3 class="popover-title">Filter tasks</h3>
<div class="form-field">
<label class="form-label" for="pf-who">Assignee</label>
<select class="form-select form-control-sm" id="pf-who"><option>Anyone</option><option>Me</option><option>Henry R.</option></select>
</div>
<label class="check"><input type="checkbox" checked> Show completed</label>
<div class="popover-footer">
<button class="btn btn-sm btn-ghost" type="button" data-momo-close>Cancel</button>
<button class="btn btn-sm btn-brand" type="button" data-momo-close>Apply</button>
</div>
</div>
<button class="btn btn-ghost" type="button" data-momo-popover="pop-person" data-momo-align="start"><span class="avatar avatar-xs bg-pink">SW</span> Sallie Wade</button>
<div class="popover" id="pop-person" data-momo-close-outside aria-label="Sallie Wade">
<div class="person"><span class="avatar avatar-lg bg-pink">SW</span><span class="person-text"><span class="person-name">Sallie Wade</span><span class="person-sub">Product designer · Toronto</span></span></div>
<p class="text-muted">Working on the website redesign. Usually replies within an hour.</p>
<button class="btn btn-sm btn-brand" type="button" data-momo-close><i class="mi mi-message-square"></i> Message</button>
</div>Accessibility
- Tooltips are linked to their element with
aria-describedbywhile shown, and Esc hides them. - Popovers are dialogs: name them with
aria-label(otherwise the button's text is used).