Skip to the page
TACTILE UI

Kit part · Popovers

Popover

A card hung from the key that opened it, with a printed leader running back to the key. Not modal: the page stays live around it.

Element
[popover]
Needs
kit.css + kit.mjs
Rules
popover.rules.md · 4
Finishes
Aluminium · Graphite · Porcelain · Black
Volumes
Tactile · Quiet
On this page
  1. Variants
  2. Every state, at once
  3. API
  4. Markup
  5. Accessibility
  6. How it’s built
  7. Rules
  8. Related parts
01

Variants

Reserve

Kept for a power cut.

Hung below its key

Reserve

Kept for a power cut.

Above, when the page runs out

Reserve

Kept for a power cut.

Beside, data-side="right"
With a key · live
02

Every state, at once

Both finishes, side by side. Hover, pressed and focus are forced with .is-hover, .is-down and .is-focus; checked and disabled are real.

Aluminium

PartKeyCard out, belowAboveFocus in the card
Popover

Reserve

Kept for a power cut.

Reserve

Kept for a power cut.

Reserve

Graphite

PartKeyCard out, belowAboveFocus in the card
Popover

Reserve

Kept for a power cut.

Reserve

Kept for a power cut.

Reserve

03

API

NameKindValuesWhat it does
.tui-popoverclasson [popover]The card: a raised plate, 12px corners, 16px inside, up to 300px wide.
popoverattributenativeTop layer, light dismiss, Escape. Leave it off for a card that sits in the page.
popovertargetattributeon the keyNative: the key opens and closes the card; the browser links them for assistive tech.
.tui-popover__triggerclasson a .tui-keyStays latched while its card is out.
data-sideattribute"bottom" · "top" · "right" · "left"Where the card prefers to hang. It flips to the opposite side when there is no room.
data-alignattribute"center" · "start" · "end"Where along that side. It slides to stay 8px inside the window.
role="dialog" · aria-labelledbyattribute—For a card with keys or fields in it. A card of words alone can be role="note".
.tui-popover__title · .tui-popover__actionsclass—A bold first line; keys at the foot, right-aligned.
.tui-popover--plainclass—No leader.
--tui-leaderCSS propertyset by scriptWhere the leader meets the card, in px from its edge: under the key’s centre.
data-placedattributeset by scriptThe side it was placed on; the leader and the slide follow it.
placePopover(card, anchor, options)functionkit.mjsPlace any fixed card beside an element or a point; the menu and the notification centre use it.
Enter · Space · Escape · Tabkeyboard—Open and close from the key; Escape closes and returns focus; Tab walks into the card after the key.
04

Markup

<button class="tui-key tui-popover__trigger" popovertarget="tariff">Tariff</button>

<div class="tui-popover" id="tariff" popover role="dialog" aria-labelledby="tariff-t">
  <p class="tui-popover__title" id="tariff-t">Flux, three rates</p>
  <p>Cheapest 00:00–02:00, dearest 16:00–19:00.</p>
  <div class="tui-popover__actions">
    <button class="tui-key tui-key--flat tui-key--sm" popovertarget="tariff" popovertargetaction="hide">Close</button>
    <button class="tui-key tui-key--primary tui-key--sm">Change tariff</button>
  </div>
</div>
import '/kit/kit.mjs';   // places every .tui-popover as it opens

// Prefer a side: data-side="top" on the card; data-align="start" | "end".
// For your own floating parts:
import { placePopover } from '/kit/kit.mjs';
placePopover(card, key, { side: 'bottom', align: 'center', gap: 14 });

Needs kit.css and kit.mjs. How to install the kit.

05

Accessibility

  • The native popover with popovertarget: the key is announced as expanded or collapsed, and Tab goes from the key straight into the card.
  • Not modal: focus is not trapped, and the rest of the page keeps working. For a decision that must be made now, use a dialog.
  • Escape closes it and focus returns to the key; a click outside closes it too.
  • The leader is drawn with ::before and ::after: nothing to announce.
06

How it’s built

Opening and closing are the browser’s; popover.mjs answers the toggle event, measures the key and the card, and places the card below it (or above, or beside), sliding it to stay inside the window. It writes --tui-leader, and the card’s ::before draws a hairline across the 14px gap to that point while its ::after puts a dot on the key’s edge: a callout from a manual. The arithmetic is a pure function with its own tests. The card hangs down 5px in 160ms.

07

Rules

popover.rules.mdIn the brain

For a closer look at something beside it, never for a decision that must be made now; that is a dialog.

4 rules in this file, with the foundations they rest on and the anti-patterns that break them. Full rules ship in the brain with the Pass.

08

Menu

A card of actions and options that slides out from under its key. The key stays down while the card is out; an option that is on lights its lamp.

Tooltip

A one-line name for an icon key, printed on a small dark plate above it on hover and on keyboard focus.

Confirm

Erase reel 3?

KeepErase

Dialog

A decision that must be made now: a native dialog with a question, one sentence of consequence, a way back and the act.

Docs
Finish
Volume