Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Popover

    Non-modal floating panel built on the Popover API for small forms and extra details, anchored to a trigger button.

    <x-markas.popover label="Share">
        <div class="grid gap-3">
            <div class="grid gap-1">
                <p class="font-medium text-ink">Share project</p>
                <p class="text-muted">Anyone with the link can view this project.</p>
            </div>
            <x-markas.button size="sm">Copy link</x-markas.button>
        </div>
    </x-markas.popover>
    import { Button } from "@/components/markas/Button";
    import { Popover } from "@/components/markas/Popover";
    
    export default function PopoverExample() {
      return (
        <Popover label="Share">
          <div className="grid gap-3">
            <div className="grid gap-1">
              <p className="font-medium text-ink">Share project</p>
              <p className="text-muted">
                Anyone with the link can view this project.
              </p>
            </div>
            <Button size="sm">Copy link</Button>
          </div>
        </Popover>
      );
    }
    <script setup lang="ts">
    import Button from "@/components/markas/Button.vue";
    import Popover from "@/components/markas/Popover.vue";
    </script>
    
    <template>
      <Popover label="Share">
        <div class="grid gap-3">
          <div class="grid gap-1">
            <p class="font-medium text-ink">Share project</p>
            <p class="text-muted">Anyone with the link can view this project.</p>
          </div>
          <Button size="sm">Copy link</Button>
        </div>
      </Popover>
    </template>
    <script lang="ts">
      import Button from "$lib/components/markas/Button.svelte";
      import Popover from "$lib/components/markas/Popover.svelte";
    </script>
    
    <Popover label="Share">
      <div class="grid gap-3">
        <div class="grid gap-1">
          <p class="font-medium text-ink">Share project</p>
          <p class="text-muted">Anyone with the link can view this project.</p>
        </div>
        <Button size="sm">Copy link</Button>
      </div>
    </Popover>
    ---
    import Button from "@/components/markas/Button.astro";
    import Popover from "@/components/markas/Popover.astro";
    ---
    
    <Popover label="Share">
      <div class="grid gap-3">
        <div class="grid gap-1">
          <p class="font-medium text-ink">Share project</p>
          <p class="text-muted">Anyone with the link can view this project.</p>
        </div>
        <Button size="sm">Copy link</Button>
      </div>
    </Popover>
    import { Component } from "@angular/core";
    import { Button } from "./markas/button.component";
    import { Popover } from "./markas/popover.component";
    
    @Component({
      selector: "markas-example",
      imports: [Button, Popover],
      template: `
        <markas-popover label="Share">
          <div class="grid gap-3">
            <div class="grid gap-1">
              <p class="font-medium text-ink">Share project</p>
              <p class="text-muted">Anyone with the link can view this project.</p>
            </div>
            <button markas-button size="sm">Copy link</button>
          </div>
        </markas-popover>
      `,
    })
    export default class PopoverExample {}

    Examples

    With form

    Icon trigger aligned to end

    Inbox

    Inbox

    Inbox

    Inbox

    Inbox

    Above the trigger

    Installation

    npx markasui@latest add popover

    Usage

    <x-markas.popover label="Share">
        <div class="grid gap-3">
            <p class="text-muted">Anyone with the link can view this project.</p>
            <x-markas.button size="sm">Copy link</x-markas.button>
        </div>
    </x-markas.popover>

    Needs Alpine.js.

    import { Button } from "@/components/markas/Button";
    import { Popover } from "@/components/markas/Popover";
    
    <Popover label="Share" align="end">
      <div className="grid gap-3">
        <p className="text-muted">Anyone with the link can view this project.</p>
        <Button size="sm">Copy link</Button>
      </div>
    </Popover>;
    <template>
      <Popover label="Share" side="top">
        <div class="grid gap-3">
          <p class="text-muted">Anyone with the link can view this project.</p>
          <Button size="sm">Copy link</Button>
        </div>
      </Popover>
    </template>
    <script lang="ts">
      import Button from "$lib/components/markas/Button.svelte";
      import Popover from "$lib/components/markas/Popover.svelte";
    </script>
    
    <Popover label="Share" align="end">
      <div class="grid gap-3">
        <p class="text-muted">Anyone with the link can view this project.</p>
        <Button size="sm">Copy link</Button>
      </div>
    </Popover>
    ---
    import Button from "@/components/markas/Button.astro";
    import Popover from "@/components/markas/Popover.astro";
    ---
    
    <Popover label="Share" align="end">
      <div class="grid gap-3">
        <p class="text-muted">Anyone with the link can view this project.</p>
        <Button size="sm">Copy link</Button>
      </div>
    </Popover>

    A small bundled script places every popover on the page. It also works after view transitions.

    import { Component } from "@angular/core";
    import { Button } from "./markas/button.component";
    import { Popover } from "./markas/popover.component";
    
    @Component({
      selector: "app-share",
      imports: [Button, Popover],
      template: `
        <markas-popover label="Share" align="end">
          <div class="grid gap-3">
            <p class="text-muted">Anyone with the link can view this project.</p>
            <button markas-button size="sm">Copy link</button>
          </div>
        </markas-popover>
      `,
    })
    export class Share {}

    For an icon trigger, put the icon and sr-only text in an element with the trigger attribute, for example <ng-container trigger>.

    • The panel opens below the trigger aligned to its start edge. Change it with side (top, bottom) and align (start, center, end).
    • Use the trigger slot for an icon trigger and include sr-only text, for example <span class="sr-only">Notification settings</span>.
    • The trigger reads “Open” by default. Set label in the language of your site.

    Props

    NameTypeDefaultDescription
    labelstringOpenText of the trigger button.
    triggerslot / ReactNode / snippet-Custom trigger button content, replaces label. Add sr-only text when it only holds an icon. Angular: an element with the trigger attribute (an ng-container works).
    children / slotslot / ReactNode-Panel content, such as a short form or details.
    sidetop | bottombottomSide of the trigger to show the panel on. Flips to the other side when it does not fit on screen.
    alignstart | center | endstartHorizontal alignment of the panel against the trigger.
    idstringautoPanel id. The trigger button uses this id with a -trigger suffix.

    Accessibility

    • The trigger button uses aria-haspopup=dialog, aria-expanded, and aria-controls pointing to the role=dialog panel, which is labelled by the trigger.
    • Enter or Space on the trigger opens the panel and moves focus to its first focusable element.
    • Escape closes the panel and returns focus to the trigger.
    • Clicking outside closes the panel (Popover API light dismiss). Focus returns to the trigger unless it already moved to another element.

    Related components

    More overlay components with the same classes in every framework.