Popover
A Duostrap anchored non-modal popover for lightweight interactive content.
Duostrap Popover displays rich non-modal content anchored to a trigger with classic header framing and a 150ms linear fade transition, without locking background scroll or trapping Tab navigation.
Preview
Section titled “Preview”<duostrap-popover-root>
<duostrap-popover-trigger>
Click to toggle popover
</duostrap-popover-trigger>
<duostrap-popover-content>
<duostrap-popover-title>Dimensions</duostrap-popover-title>
<duostrap-popover-description>
Set the dimensions for the layer.
</duostrap-popover-description>
<div class="grid gap-2 px-[14px] pb-[10px]">
<label>
Width
<input value="100%" />
</label>
<label>
Height
<input value="25px" />
</label>
<duostrap-popover-close>Close</duostrap-popover-close>
</div>
</duostrap-popover-content>
</duostrap-popover-root>Installation
Section titled “Installation”Duostrap Popover will be available starting in 0.3.0-rc.1 and later releases (currently available from workspace source). Import the prototypes directly from @proto.ui/prototypes-duostrap/popover and adapt them for your target runtime:
import { popoverRoot, popoverTrigger, popoverContent, popoverTitle, popoverDescription, popoverClose,} from '@proto.ui/prototypes-duostrap/popover';<BootstrapPopover> <BootstrapPopoverTrigger>Open Popover</BootstrapPopoverTrigger> <BootstrapPopoverContent> <BootstrapPopoverTitle>Popover title</BootstrapPopoverTitle> <BootstrapPopoverDescription> And here is some helpful contextual information anchored to the right. </BootstrapPopoverDescription> </BootstrapPopoverContent></BootstrapPopover>Composition
Section titled “Composition”BootstrapPopoverRoot├── BootstrapPopoverTrigger└── BootstrapPopoverContent ├── BootstrapPopoverTitle ├── BootstrapPopoverDescription └── BootstrapPopoverClose- Classic defaults: Preserves Duostrap defaults with
side="right",sideOffset={10}, a276pxmax-width shell,6pxradius,#ebebebtitle divider, and a150mslinear fade transition. - Dismissal & focus: Outside clicks, focus leaving
TriggerandContent,Escape, andCloseall request dismissal. When dismissed by focus moving outside, focus stays on that external control.
Examples
Section titled “Examples”Default right-anchored Duostrap popover with title and body description.
<duostrap-popover-root>
<duostrap-popover-trigger>Open Popover</duostrap-popover-trigger>
<duostrap-popover-content>
<duostrap-popover-title>Popover title</duostrap-popover-title>
<duostrap-popover-description>
And here is some helpful contextual information anchored to
the right.
</duostrap-popover-description>
</duostrap-popover-content>
</duostrap-popover-root>Four Directions
Section titled “Four Directions”Place the popover on top, right, bottom, or left using side.
<div id="bs2-sides" class="flex flex-wrap gap-3">
<duostrap-popover-root>
<duostrap-popover-trigger>
Popover on top
</duostrap-popover-trigger>
<duostrap-popover-content data-side="top">
<duostrap-popover-title>
Popover on top
</duostrap-popover-title>
<duostrap-popover-description>
Anchored to the top edge.
</duostrap-popover-description>
</duostrap-popover-content>
</duostrap-popover-root>
<duostrap-popover-root>
<duostrap-popover-trigger>
Popover on right
</duostrap-popover-trigger>
<duostrap-popover-content data-side="right">
<duostrap-popover-title>
Popover on right
</duostrap-popover-title>
<duostrap-popover-description>
Anchored to the right edge.
</duostrap-popover-description>
</duostrap-popover-content>
</duostrap-popover-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
document
.querySelectorAll('#bs2-sides duostrap-popover-content')
.forEach((el) => {
setElementProps(el, { side: el.getAttribute('data-side') });
});
</script>Controlled
Section titled “Controlled”Pass open and handle openChange to synchronize open state with parent state.
<duostrap-popover-root id="bs2-ctrl-root">
<duostrap-popover-trigger>Quick info</duostrap-popover-trigger>
<duostrap-popover-content>
<duostrap-popover-title>
Controlled state
</duostrap-popover-title>
<duostrap-popover-description>
Open and close state is owned by parent props.
</duostrap-popover-description>
<duostrap-popover-close>Close</duostrap-popover-close>
</duostrap-popover-content>
</duostrap-popover-root>
<duostrap-button id="bs2-ctrl-open">
Open externally
</duostrap-button>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#bs2-ctrl-root');
const sync = (open) => setElementProps(root, { open });
sync(false);
root.addEventListener('openChange', (e) => sync(e.detail.open));
document
.querySelector('#bs2-ctrl-open')
.addEventListener('click', () => sync(true));
</script>Root exposes read-only state open, methods openPopover, close, and toggle, and the openChange event.
| Prop | Type | Default |
|---|---|---|
open (Root) | boolean undefined | uncontrolled |
defaultOpen (Root) | boolean | false |
disabled (Root / Trigger / Close) | boolean | false |
a11yLabel (Root) | string | '' |
side (Content) | 'top' 'right' 'bottom' 'left' | 'right' |
align (Content) | 'start' 'center' 'end' | 'center' |
sideOffset (Content) | number | 10 |
alignOffset (Content) | number | 0 |
collisionPadding (Content) | number | 8 |
enterDuration / leaveDuration (Content) | number | 150 |