Skip to content

Popover ​

A floating panel next to a button.

PW
Peter WolfeBoston, 14 orders worth $2,480

Put the button into the trigger slot and pass it the slot's attrs with v-bind.

Installation ​

ts
import { NuiPopover } from '@numior/kit';

Usage ​

Open the popover and change its side, arrow, padding and the way it opens.

  • Loft stool: 0 left
  • Malmo desk: 7 left
  • Vik shelving unit: 9 left
  • Fjord dresser: 4 left

Side of the trigger the popover opens on, such as bottom-start.

Distance from the trigger in pixels. Defaults to 4, and to 8 with an arrow, so the arrow touches the trigger.

padding
Inner padding: md for text and forms, sm for lists and buttons, none for content with its own frame.
size
Width: md keeps 8 to 20rem for text and forms, auto fits the content up to the screen width.
trigger
How the popover opens: click on a trigger press, hover on hover or focus.

Examples ​

Open on hover ​

Set trigger="hover".

Order 20401 is handled by
AT
Anna TurnerOrder manageranna@example.com

On the keyboard the panel opens when the trigger gets focus, and on a touch screen it opens on a tap. It stays open while the pointer is over it, so the user can click a link inside.

Behavior ​

When the panel does not fit on its side, it flips to the opposite side or shifts to stay on screen.

Accessibility ​

Esc and a click outside close the panel. Tab moves from the button into the panel and then on through the page.

The attrs give the button aria-expanded and aria-controls, so a screen reader announces whether the panel is open.

The panel stays in the markup next to the button, so it takes the theme and the text direction of that place. A parent with overflow: hidden does not clip it.

Keys
Action
↵
On the trigger, opens and closes the popover.
Space
On the trigger, opens and closes the popover.
Esc
Closes the popover.
⇥
From the trigger, moves focus into the popover, then on through the page.

API ​

Props

Name
Type
Default
Description
id
string
—
Id of the popover. Generated automatically by default.
placement
Placement
"bottom"
Side of the trigger the popover opens on, such as bottom-start.
offset
number
—
Distance from the trigger in pixels. Defaults to 4, and to 8 with an arrow, so the arrow touches the trigger.
arrow
boolean
false
Shows an arrow pointing at the trigger.
padding
NuiPopoverPadding
"md"
Inner padding: md for text and forms, sm for lists and buttons, none for content with its own frame.
size
NuiPopoverSize
"md"
Width: md keeps 8 to 20rem for text and forms, auto fits the content up to the screen width.
anchor
HTMLElement | null
—
Element the popover opens next to in place of the trigger, such as selected text.
mode
PopoverMode
"auto"
auto closes on an outside click and Escape, manual only through v-model:open.
trigger
NuiPopoverTrigger
—
How the popover opens: click on a trigger press, hover on hover or focus.
openDelay
number
400
Delay in milliseconds before the popover opens on hover.
closeDelay
number
200
Delay in milliseconds before the popover closes after the pointer leaves.
lazy
boolean
false
Creates the content on the first open and keeps it after closing. Suits rarely opened panels, not content the server must render.
fit
boolean
false
Keeps the popover within the screen height: the height is limited to the room at the anchor and the content scrolls. Does not combine with the arrow, which the scrolling clips.

Models

Name
Type
Default
Description
v-model:open
boolean
false
Whether the popover is open.

Slots

Name
Slot props
Description
trigger
NuiPopoverTriggerSlot
Button that opens the popover. Receives attrs for v-bind and open.
default
any
Panel content. With lazy, it is created on the first open.

Exposed

Name
Type
Description
triggerElement
HTMLElement | null
The trigger slot button element while the popover is mounted.

Edit this page

Search

Esc