Overlays¶
Because every plugin page runs inside an iframe, HTML dropdowns and popovers rendered inside the page clip at the iframe's edges, especially in compact widgets. Curio provides host-rendered overlays drawn directly over the Curio window.
Host dialogs¶
With the ui permission, any plugin page can invoke Curio's native dialogs and pickers in the user's theme and language against the live library:
ui.notify: Non-blocking toast (infoorerror).ui.confirm/ui.prompt: Confirmation and single-line text input dialogs.ui.pickTags/ui.pickFolders/ui.pickField/ui.pickColor: Native Curio pickers.ui.menu: Native context menu anchored at the last pointer position, or beneath a viewer toolbar button when triggered fromplugin.toolwithmenu: true.dialog.openFile/dialog.openFolder/dialog.saveFile: Native OS file and folder choosers.
ui.choose¶
ui.choose requires no extra permission (covered by library.read) and renders a native Curio dropdown menu anchored under any button or .curio-select-btn in your page:
const btn = document.querySelector('#status-btn')
btn.addEventListener('click', async () => {
const r = btn.getBoundingClientRect()
const res = await curio.ui.choose({
at: { x: r.left, y: r.top, w: r.width, h: r.height },
value: currentStatus,
search: false,
options: [
{ value: 'unread', label: 'Unread' },
{ value: 'reading', label: 'Reading', icon: 'book' },
{ value: 'finished', label: 'Finished', icon: 'check' },
],
})
if (res.chosen) await saveStatus(res.value)
})
- Options: Supports up to 1,000 options (
string | numberor{ label, value, icon?, hint?, heading?, disabled? }) plus optional live search (search: true). - Focus restoration: After closing, Curio returns keyboard focus to your plugin iframe.
ui.popover¶
ui.popover requires no extra permission and opens another HTML page from your plugin folder inside a floating Curio popover anchored to an element in your calling page:
const r = triggerBtn.getBoundingClientRect()
const { result } = await curio.ui.popover({
page: 'picker-popover.html',
width: 320, // 160 to 640 px (default 300)
at: { x: r.left, y: r.top, w: r.width, h: r.height },
data: { itemId: currentItem.id, initialColor: '#3b9160' },
})
if (result) applyChoice(result)
Only one popover can be open at a time.
Popover data¶
Inside picker-popover.html:
const curio = Curio.connect()
curio.on('plugin.run', ({ data }) => {
renderPicker(data.itemId, data.initialColor)
})
applyBtn.addEventListener('click', () => {
curio.plugin.close({ result: { color: selectedColor } })
})
- Auto-sizing:
curio.jsobservesdocument.bodyheight so the popover resizes to fit its contents (up to 4,000 px). - Returning data: Calling
curio.plugin.close({ result })closes the popover and resolves the caller'sui.popoverpromise with{ result }.
Dismissal¶
- Dismiss triggers: Clicking outside a
ui.choosemenu orui.popoverframe, or pressing Esc, dismisses the overlay. - Return values:
ui.chooseresolves to{ chosen: false }when dismissed;ui.popoverresolves to{ result: null }when dismissed without callingplugin.close({ result }). - Focus: Keyboard focus returns to the calling plugin frame so arrow keys and shortcuts keep working.