Zubra UI
Code for
GitHub

popover-panel

A button that opens a small panel beside it: filters, a share menu, a colour picker, a few settings. On the native popover: a click outside or Escape closes it and focus returns to the button. It's placed below the button by CSS anchor positioning (flipping above when there's no room), or by script where that isn't supported. align is start or end. open is two-way.

Share this recipe

Copy link

Email it

Try it: events appear here (openchange).

Source: popover-panel.zb, and its registry item.

Install

Compiled (any project)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/popover-panel.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/popover-panel.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/popover-panel.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/popover-panel.json
One file, no dependencies (4.6 KB gzipped)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/popover-panel.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/popover-panel.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/popover-panel.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/popover-panel.json
.zb source (to edit it with Zubra)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/popover-panel.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/popover-panel.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/popover-panel.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/popover-panel.json
No build: a script tag, straight from this site
HTML
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/popover-panel.js"></script>

The compiled install writes src/components/zubra/popover-panel.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.

Usage

index.html
<popover-panel label="Share">
  <p><strong>Share this recipe</strong></p>
  <p><a href="#copy">Copy link</a></p>
  <p><a href="#email">Email it</a></p>
</popover-panel>

<script type="module">
  import './components/zubra/popover-panel.js';

  const element = document.querySelector('popover-panel');
  element.addEventListener('openchange', (event) => console.log('openchange', event.detail));
</script>
Example.jsx
import './components/zubra/popover-panel.js';

export function PopoverPanelExample() {
  return (
    <popover-panel
      label="Share"
      onopenchange={(event) => console.log('openchange', event.detail)}
    >
      <p><strong>Share this recipe</strong></p>
      <p><a href="#copy">Copy link</a></p>
      <p><a href="#email">Email it</a></p>
    </popover-panel>
  );
}
Example.vue
<script setup>
import './components/zubra/popover-panel.js';
const onOpenchange = (event) => console.log('openchange', event.detail);
</script>

<template>
  <popover-panel label="Share" @openchange="onOpenchange">
    <p><strong>Share this recipe</strong></p>
    <p><a href="#copy">Copy link</a></p>
    <p><a href="#email">Email it</a></p>
  </popover-panel>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/popover-panel.js';
</script>

<popover-panel
  label="Share"
  onopenchange={(event) => console.log('openchange', event.detail)}
>
  <p><strong>Share this recipe</strong></p>
  <p><a href="#copy">Copy link</a></p>
  <p><a href="#email">Email it</a></p>
</popover-panel>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/popover-panel.js';

@Component({
  selector: 'app-popover-panel-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <popover-panel label="Share" (openchange)="onOpenchange($event)">
      <p><strong>Share this recipe</strong></p>
      <p><a href="#copy">Copy link</a></p>
      <p><a href="#email">Email it</a></p>
    </popover-panel>
  `,
})
export class PopoverPanelExample {
  onOpenchange(event: Event) {
    console.log('openchange', (event as CustomEvent).detail);
  }
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
openbooleanfalse
labelstring"Options"
align"start" | "end""start"
Events
EventWhen
openchangeopen changed; detail is the new value.
Slots
SlotFor
(default)The panel's content.

Size

1.6 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 18.3 KB.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour