Non-modal floating panel built on the Popover API for small forms and extra details, anchored to a trigger button.
Share project
Anyone with the link can view this project.
Share project
Anyone with the link can view this project.
Share project
Anyone with the link can view this project.
Share project
Anyone with the link can view this project.
Share project
Anyone with the link can view this project.
<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
<div class="flex justify-center">
<x-markas.popover label="Dimensions" align="center">
<form class="grid gap-3">
<p class="font-medium text-ink">Image size</p>
<div class="grid grid-cols-2 gap-3">
<x-markas.input name="width" label="Width" placeholder="1200" inputmode="numeric" />
<x-markas.input name="height" label="Height" placeholder="630" inputmode="numeric" />
</div>
<x-markas.button type="submit" size="sm">Apply</x-markas.button>
</form>
</x-markas.popover>
</div>import { Button } from "@/components/markas/Button";
import { Input } from "@/components/markas/Input";
import { Popover } from "@/components/markas/Popover";
export default function Example() {
return (
<div className="flex justify-center">
<Popover label="Dimensions" align="center">
<form className="grid gap-3">
<p className="font-medium text-ink">Image size</p>
<div className="grid grid-cols-2 gap-3">
<Input
name="width"
label="Width"
placeholder="1200"
inputMode="numeric"
/>
<Input
name="height"
label="Height"
placeholder="630"
inputMode="numeric"
/>
</div>
<Button type="submit" size="sm">
Apply
</Button>
</form>
</Popover>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Input from "@/components/markas/Input.vue";
import Popover from "@/components/markas/Popover.vue";
</script>
<template>
<div class="flex justify-center">
<Popover label="Dimensions" align="center">
<form class="grid gap-3">
<p class="font-medium text-ink">Image size</p>
<div class="grid grid-cols-2 gap-3">
<Input
name="width"
label="Width"
placeholder="1200"
inputmode="numeric"
/>
<Input
name="height"
label="Height"
placeholder="630"
inputmode="numeric"
/>
</div>
<Button type="submit" size="sm">Apply</Button>
</form>
</Popover>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Input from "$lib/components/markas/Input.svelte";
import Popover from "$lib/components/markas/Popover.svelte";
</script>
<div class="flex justify-center">
<Popover label="Dimensions" align="center">
<form class="grid gap-3">
<p class="font-medium text-ink">Image size</p>
<div class="grid grid-cols-2 gap-3">
<Input
name="width"
label="Width"
placeholder="1200"
inputmode="numeric"
/>
<Input
name="height"
label="Height"
placeholder="630"
inputmode="numeric"
/>
</div>
<Button type="submit" size="sm">Apply</Button>
</form>
</Popover>
</div>---
import Button from "@/components/markas/Button.astro";
import Input from "@/components/markas/Input.astro";
import Popover from "@/components/markas/Popover.astro";
---
<div class="flex justify-center">
<Popover label="Dimensions" align="center">
<form class="grid gap-3">
<p class="font-medium text-ink">Image size</p>
<div class="grid grid-cols-2 gap-3">
<Input name="width" label="Width" placeholder="1200" inputmode="numeric" />
<Input name="height" label="Height" placeholder="630" inputmode="numeric" />
</div>
<Button type="submit" size="sm">Apply</Button>
</form>
</Popover>
</div>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Input } from "./markas/input.component";
import { Popover } from "./markas/popover.component";
@Component({
selector: "markas-example",
imports: [Button, Input, Popover],
template: `
<div class="flex justify-center">
<markas-popover label="Dimensions" align="center">
<form class="grid gap-3">
<p class="font-medium text-ink">Image size</p>
<div class="grid grid-cols-2 gap-3">
<markas-input name="width" label="Width" placeholder="1200" />
<markas-input name="height" label="Height" placeholder="630" />
</div>
<button markas-button type="submit" size="sm">Apply</button>
</form>
</markas-popover>
</div>
`,
})
export default class PopoverFormExample {}Icon trigger aligned to end
Inbox
Notify me about
Inbox
Notify me about
Inbox
Notify me about
Inbox
Notify me about
Inbox
Notify me about
<div class="flex items-center justify-between rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-medium text-ink">Inbox</p>
<x-markas.popover align="end">
<x-slot:trigger>
<span class="sr-only">Notification settings</span>
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 8a6 6 0 1 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0" /></svg>
</x-slot:trigger>
<div class="grid gap-3">
<p class="font-medium text-ink">Notify me about</p>
<x-markas.checkbox name="mentions" label="Mentions" checked />
<x-markas.checkbox name="replies" label="Replies to my comments" />
</div>
</x-markas.popover>
</div>import { Checkbox } from "@/components/markas/Checkbox";
import { Popover } from "@/components/markas/Popover";
export default function Example() {
return (
<div className="flex items-center justify-between rounded-lg border border-line bg-surface p-3">
<p className="text-sm font-medium text-ink">Inbox</p>
<Popover
align="end"
trigger={
<>
<span className="sr-only">Notification settings</span>
<svg
className="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<path d="M6 8a6 6 0 1 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0" />
</svg>
</>
}
>
<div className="grid gap-3">
<p className="font-medium text-ink">Notify me about</p>
<Checkbox name="mentions" label="Mentions" defaultChecked />
<Checkbox name="replies" label="Replies to my comments" />
</div>
</Popover>
</div>
);
}<script setup lang="ts">
import { ref } from "vue";
import Checkbox from "@/components/markas/Checkbox.vue";
import Popover from "@/components/markas/Popover.vue";
const mentions = ref(true);
</script>
<template>
<div
class="flex items-center justify-between rounded-lg border border-line bg-surface p-3"
>
<p class="text-sm font-medium text-ink">Inbox</p>
<Popover align="end">
<template #trigger>
<span class="sr-only">Notification settings</span>
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path
d="M6 8a6 6 0 1 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0"
/>
</svg>
</template>
<div class="grid gap-3">
<p class="font-medium text-ink">Notify me about</p>
<Checkbox v-model="mentions" name="mentions" label="Mentions" />
<Checkbox name="replies" label="Replies to my comments" />
</div>
</Popover>
</div>
</template><script lang="ts">
import Checkbox from "$lib/components/markas/Checkbox.svelte";
import Popover from "$lib/components/markas/Popover.svelte";
</script>
<div
class="flex items-center justify-between rounded-lg border border-line bg-surface p-3"
>
<p class="text-sm font-medium text-ink">Inbox</p>
<Popover align="end">
{#snippet trigger()}
<span class="sr-only">Notification settings</span>
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path
d="M6 8a6 6 0 1 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0"
/>
</svg>
{/snippet}
<div class="grid gap-3">
<p class="font-medium text-ink">Notify me about</p>
<Checkbox name="mentions" label="Mentions" checked />
<Checkbox name="replies" label="Replies to my comments" />
</div>
</Popover>
</div>---
import Checkbox from "@/components/markas/Checkbox.astro";
import Popover from "@/components/markas/Popover.astro";
---
<div class="flex items-center justify-between rounded-lg border border-line bg-surface p-3">
<p class="text-sm font-medium text-ink">Inbox</p>
<Popover align="end">
<Fragment slot="trigger">
<span class="sr-only">Notification settings</span>
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path d="M6 8a6 6 0 1 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0"></path>
</svg>
</Fragment>
<div class="grid gap-3">
<p class="font-medium text-ink">Notify me about</p>
<Checkbox name="mentions" label="Mentions" checked />
<Checkbox name="replies" label="Replies to my comments" />
</div>
</Popover>
</div>import { Component } from "@angular/core";
import { Checkbox } from "./markas/checkbox.component";
import { Popover } from "./markas/popover.component";
@Component({
selector: "markas-example",
imports: [Checkbox, Popover],
template: `
<div [class]="row">
<p class="text-sm font-medium text-ink">Inbox</p>
<markas-popover align="end">
<ng-container trigger>
<span class="sr-only">Notification settings</span>
<svg
class="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
<path
d="M6 8a6 6 0 1 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0"
/>
</svg>
</ng-container>
<div class="grid gap-3">
<p class="font-medium text-ink">Notify me about</p>
<markas-checkbox name="mentions" label="Mentions" checked />
<markas-checkbox name="replies" label="Replies to my comments" />
</div>
</markas-popover>
</div>
`,
})
export default class PopoverIconTriggerExample {
protected readonly row =
"flex items-center justify-between rounded-lg border border-line bg-surface p-3";
}Above the trigger
Your status
Teammates see your status next to your name.
Your status
Teammates see your status next to your name.
Your status
Teammates see your status next to your name.
Your status
Teammates see your status next to your name.
Your status
Teammates see your status next to your name.
<div class="flex justify-center pt-40">
<x-markas.popover label="Set status" side="top" align="center">
<div class="grid gap-2">
<p class="font-medium text-ink">Your status</p>
<p class="text-muted">Teammates see your status next to your name.</p>
<div class="flex gap-2">
<x-markas.button size="sm" variant="secondary">Busy</x-markas.button>
<x-markas.button size="sm" variant="secondary">Away</x-markas.button>
</div>
</div>
</x-markas.popover>
</div>import { Button } from "@/components/markas/Button";
import { Popover } from "@/components/markas/Popover";
export default function Example() {
return (
<div className="flex justify-center pt-40">
<Popover label="Set status" side="top" align="center">
<div className="grid gap-2">
<p className="font-medium text-ink">Your status</p>
<p className="text-muted">
Teammates see your status next to your name.
</p>
<div className="flex gap-2">
<Button size="sm" variant="secondary">
Busy
</Button>
<Button size="sm" variant="secondary">
Away
</Button>
</div>
</div>
</Popover>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Popover from "@/components/markas/Popover.vue";
</script>
<template>
<div class="flex justify-center pt-40">
<Popover label="Set status" side="top" align="center">
<div class="grid gap-2">
<p class="font-medium text-ink">Your status</p>
<p class="text-muted">Teammates see your status next to your name.</p>
<div class="flex gap-2">
<Button size="sm" variant="secondary">Busy</Button>
<Button size="sm" variant="secondary">Away</Button>
</div>
</div>
</Popover>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Popover from "$lib/components/markas/Popover.svelte";
</script>
<div class="flex justify-center pt-40">
<Popover label="Set status" side="top" align="center">
<div class="grid gap-2">
<p class="font-medium text-ink">Your status</p>
<p class="text-muted">Teammates see your status next to your name.</p>
<div class="flex gap-2">
<Button size="sm" variant="secondary">Busy</Button>
<Button size="sm" variant="secondary">Away</Button>
</div>
</div>
</Popover>
</div>---
import Button from "@/components/markas/Button.astro";
import Popover from "@/components/markas/Popover.astro";
---
<div class="flex justify-center pt-40">
<Popover label="Set status" side="top" align="center">
<div class="grid gap-2">
<p class="font-medium text-ink">Your status</p>
<p class="text-muted">Teammates see your status next to your name.</p>
<div class="flex gap-2">
<Button size="sm" variant="secondary">Busy</Button>
<Button size="sm" variant="secondary">Away</Button>
</div>
</div>
</Popover>
</div>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: `
<div class="flex justify-center pt-40">
<markas-popover label="Set status" side="top" align="center">
<div class="grid gap-2">
<p class="font-medium text-ink">Your status</p>
<p class="text-muted">Teammates see your status next to your name.</p>
<div class="flex gap-2">
<button markas-button size="sm" variant="secondary">Busy</button>
<button markas-button size="sm" variant="secondary">Away</button>
</div>
</div>
</markas-popover>
</div>
`,
})
export default class PopoverTopExample {}Installation
npx markasui@latest add popoverpnpm dlx markasui@latest add popoveryarn dlx markasui@latest add popoverbunx --bun markasui@latest add popover- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Install the dependency:
npm install alpinejs - Copy the component source below to
resources/views/components/markas/popover.blade.php.
@props([
'label' => 'Open',
'side' => 'bottom',
'align' => 'start',
])
@php
$root = 'inline-block';
$triggerClass = 'inline-flex h-10 items-center justify-center gap-2 rounded-lg border border-line bg-surface px-4 text-sm font-medium whitespace-nowrap text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=open]:bg-subtle motion-reduce:transition-none';
$panel = 'inset-auto m-0 w-72 max-w-[calc(100vw-16px)] rounded-xl border border-line bg-surface p-4 text-sm text-ink shadow-overlay';
// Same id on every render, so Livewire's morph (which matches elements by id) keeps the element. Pass `id` to set it.
$idKey = 'markas-popover|'.(isset($this) && $this instanceof \Livewire\Component ? $this->getId() : '').'|'.($attributes->get('wire:key') ?? $attributes->whereStartsWith('wire:model')->first() ?? $attributes->get('name')).'|';
for ($idIndex = 0; $__env->hasRenderedOnce($idKey.$idIndex); $idIndex++);
$__env->markAsRenderedOnce($idKey.$idIndex);
$id = $attributes->get('id') ?? 'markas-popover-'.hash('xxh32', $idKey.$idIndex);
@endphp
<div
x-data="{
open: false,
{{-- Letakkan panel di sisi pilihan dengan perataan pilihan, pindah sisi kalau tidak muat. --}}
place() {
const gap = 4;
const anchor = this.$refs.trigger.getBoundingClientRect();
const { width, height } = this.$refs.panel.getBoundingClientRect();
const above = anchor.top - gap - height;
const below = anchor.bottom + gap;
const fitsAbove = above >= 0;
const fitsBelow = below + height <= window.innerHeight;
const onTop = @js($side) === 'top' ? fitsAbove || ! fitsBelow : ! fitsBelow && fitsAbove;
const starts = { start: anchor.left, center: anchor.left + anchor.width / 2 - width / 2, end: anchor.right - width };
const start = starts[@js($align)] ?? starts.start;
this.$refs.panel.style.top = (onTop ? above : below) + 'px';
this.$refs.panel.style.left = Math.max(gap, Math.min(start, window.innerWidth - width - gap)) + 'px';
},
unfollow: null,
{{-- Jalankan ulang penempatan saat halaman digulir atau jendela berubah ukuran. --}}
follow() {
this.unfollow?.();
const update = () => this.place();
const scrollOptions = { capture: true, passive: true };
window.addEventListener('scroll', update, scrollOptions);
window.addEventListener('resize', update, { passive: true });
this.unfollow = () => {
window.removeEventListener('scroll', update, scrollOptions);
window.removeEventListener('resize', update);
this.unfollow = null;
};
},
destroy() {
this.unfollow?.();
},
{{-- beforetoggle berjalan sinkron, jadi status selalu terbaru untuk klik berikutnya. --}}
onBeforeToggle(event) {
this.open = event.newState === 'open';
},
onToggle(event) {
if (event.newState === 'open') {
this.place();
this.follow();
this.$refs.panel.querySelector('a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\'-1\'])')?.focus();
return;
}
this.unfollow?.();
{{-- Fokus kembali ke pemicu, kecuali user sudah memindahkannya ke elemen lain di luar panel. --}}
const active = document.activeElement;
if (active === document.body || this.$refs.panel.contains(active)) this.$refs.trigger.focus();
},
onKeydown(event) {
if (event.key !== 'Escape') return;
event.preventDefault();
this.$refs.panel.hidePopover();
this.$refs.trigger.focus();
},
}"
{{ $attributes->except('id')->class([$root]) }}
>
<button
x-ref="trigger"
type="button"
id="{{ $id }}-trigger"
popovertarget="{{ $id }}"
aria-haspopup="dialog"
aria-expanded="false"
aria-controls="{{ $id }}"
data-state="closed"
:aria-expanded="open ? 'true' : 'false'"
:data-state="open ? 'open' : 'closed'"
class="{{ $triggerClass }}"
>{{ $trigger ?? $label }}</button>
<div
x-ref="panel"
id="{{ $id }}"
popover="auto"
wire:ignore.self
role="dialog"
aria-labelledby="{{ $id }}-trigger"
data-state="closed"
:data-state="open ? 'open' : 'closed'"
@beforetoggle="onBeforeToggle($event)"
@toggle="onToggle($event)"
@keydown="onKeydown($event)"
class="{{ $panel }}"
>{{ $slot }}</div>
</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Popover.tsx.
"use client";
import {
useEffect,
useId,
useRef,
useState,
type ComponentProps,
type KeyboardEvent,
type ReactNode,
type ToggleEvent,
} from "react";
const root = "inline-block";
const triggerClass =
"inline-flex h-10 items-center justify-center gap-2 rounded-lg border border-line bg-surface px-4 text-sm font-medium whitespace-nowrap text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=open]:bg-subtle motion-reduce:transition-none";
const panel =
"inset-auto m-0 w-72 max-w-[calc(100vw-16px)] rounded-xl border border-line bg-surface p-4 text-sm text-ink shadow-overlay";
const cx = (...c: (string | false | null | undefined)[]) =>
c.filter(Boolean).join(" ");
const GAP = 4;
const FOCUSABLE =
"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])";
type Side = "top" | "bottom";
type Align = "start" | "center" | "end";
/** Letakkan panel di sisi pilihan dengan perataan pilihan, pindah sisi kalau tidak muat. */
function placePanel(
trigger: HTMLElement,
target: HTMLElement,
side: Side,
align: Align,
) {
const anchor = trigger.getBoundingClientRect();
const { width, height } = target.getBoundingClientRect();
const above = anchor.top - GAP - height;
const below = anchor.bottom + GAP;
const fitsAbove = above >= 0;
const fitsBelow = below + height <= window.innerHeight;
const onTop =
side === "top" ? fitsAbove || !fitsBelow : !fitsBelow && fitsAbove;
const starts: Record<Align, number> = {
start: anchor.left,
center: anchor.left + anchor.width / 2 - width / 2,
end: anchor.right - width,
};
const start = starts[align] ?? starts.start;
const left = Math.max(GAP, Math.min(start, window.innerWidth - width - GAP));
target.style.top = `${onTop ? above : below}px`;
target.style.left = `${left}px`;
}
/** Jalankan ulang penempatan saat halaman digulir atau jendela berubah ukuran. Mengembalikan fungsi pelepas. */
function followViewport(update: () => void) {
const scrollOptions = { capture: true, passive: true };
window.addEventListener("scroll", update, scrollOptions);
window.addEventListener("resize", update, { passive: true });
return () => {
window.removeEventListener("scroll", update, scrollOptions);
window.removeEventListener("resize", update);
};
}
export type PopoverProps = ComponentProps<"div"> & {
/** Teks tombol pemicu. */
label?: string;
/** Isi tombol pemicu kustom, menggantikan label. */
trigger?: ReactNode;
side?: Side;
align?: Align;
};
export function Popover({
label = "Open",
trigger,
side = "bottom",
align = "start",
id,
className,
children,
...props
}: PopoverProps) {
const generatedId = useId();
const panelId = id ?? generatedId;
const triggerRef = useRef<HTMLButtonElement>(null);
const panelRef = useRef<HTMLDivElement>(null);
const [open, setOpen] = useState(false);
const state = open ? "open" : "closed";
const place = () => {
if (triggerRef.current && panelRef.current)
placePanel(triggerRef.current, panelRef.current, side, align);
};
useEffect(() => {
if (!open) return;
return followViewport(() => {
if (triggerRef.current && panelRef.current)
placePanel(triggerRef.current, panelRef.current, side, align);
});
}, [open, side, align]);
// beforetoggle berjalan sinkron, jadi status selalu terbaru untuk klik berikutnya.
const handleBeforeToggle = (event: ToggleEvent<HTMLDivElement>) =>
setOpen(event.newState === "open");
const handleToggle = (event: ToggleEvent<HTMLDivElement>) => {
const target = panelRef.current;
if (!target) return;
if (event.newState === "open") {
place();
target.querySelector<HTMLElement>(FOCUSABLE)?.focus();
return;
}
// Fokus kembali ke pemicu, kecuali user sudah memindahkannya ke elemen lain di luar panel.
const active = document.activeElement;
if (active === document.body || target.contains(active))
triggerRef.current?.focus();
};
const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
if (event.key !== "Escape") return;
event.preventDefault();
panelRef.current?.hidePopover();
triggerRef.current?.focus();
};
return (
<div className={cx(root, className)} {...props}>
<button
ref={triggerRef}
type="button"
id={`${panelId}-trigger`}
popoverTarget={panelId}
aria-haspopup="dialog"
aria-expanded={open}
aria-controls={panelId}
data-state={state}
className={triggerClass}
>
{trigger ?? label}
</button>
<div
ref={panelRef}
id={panelId}
popover="auto"
role="dialog"
aria-labelledby={`${panelId}-trigger`}
data-state={state}
className={panel}
onBeforeToggle={handleBeforeToggle}
onToggle={handleToggle}
onKeyDown={handleKeyDown}
>
{children}
</div>
</div>
);
}- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Popover.vue.
<script setup lang="ts">
import { computed, onBeforeUnmount, ref, useId, useTemplateRef } from "vue";
type Side = "top" | "bottom";
type Align = "start" | "center" | "end";
const props = withDefaults(
defineProps<{
label?: string;
side?: Side;
align?: Align;
id?: string;
}>(),
{ label: "Open", side: "bottom", align: "start", id: undefined },
);
const root = "inline-block";
const triggerClass =
"inline-flex h-10 items-center justify-center gap-2 rounded-lg border border-line bg-surface px-4 text-sm font-medium whitespace-nowrap text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=open]:bg-subtle motion-reduce:transition-none";
const panel =
"inset-auto m-0 w-72 max-w-[calc(100vw-16px)] rounded-xl border border-line bg-surface p-4 text-sm text-ink shadow-overlay";
const GAP = 4;
const FOCUSABLE =
"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])";
/** Letakkan panel di sisi pilihan dengan perataan pilihan, pindah sisi kalau tidak muat. */
function placePanel(
trigger: HTMLElement,
target: HTMLElement,
side: Side,
align: Align,
) {
const anchor = trigger.getBoundingClientRect();
const { width, height } = target.getBoundingClientRect();
const above = anchor.top - GAP - height;
const below = anchor.bottom + GAP;
const fitsAbove = above >= 0;
const fitsBelow = below + height <= window.innerHeight;
const onTop =
side === "top" ? fitsAbove || !fitsBelow : !fitsBelow && fitsAbove;
const starts: Record<Align, number> = {
start: anchor.left,
center: anchor.left + anchor.width / 2 - width / 2,
end: anchor.right - width,
};
const start = starts[align] ?? starts.start;
const left = Math.max(GAP, Math.min(start, window.innerWidth - width - GAP));
target.style.top = `${onTop ? above : below}px`;
target.style.left = `${left}px`;
}
/** Jalankan ulang penempatan saat halaman digulir atau jendela berubah ukuran. Mengembalikan fungsi pelepas. */
function followViewport(update: () => void) {
const scrollOptions = { capture: true, passive: true };
window.addEventListener("scroll", update, scrollOptions);
window.addEventListener("resize", update, { passive: true });
return () => {
window.removeEventListener("scroll", update, scrollOptions);
window.removeEventListener("resize", update);
};
}
const generatedId = useId();
const panelId = computed(() => props.id ?? generatedId);
const triggerEl = useTemplateRef<HTMLButtonElement>("trigger");
const panelEl = useTemplateRef<HTMLDivElement>("panelRef");
const open = ref(false);
const state = computed(() => (open.value ? "open" : "closed"));
let unfollow: (() => void) | undefined;
function stopFollowing() {
unfollow?.();
unfollow = undefined;
}
function place() {
if (triggerEl.value && panelEl.value)
placePanel(triggerEl.value, panelEl.value, props.side, props.align);
}
// beforetoggle berjalan sinkron, jadi status selalu terbaru untuk klik berikutnya.
function onBeforeToggle(event: Event) {
open.value = (event as ToggleEvent).newState === "open";
}
function onToggle(event: Event) {
stopFollowing();
const target = panelEl.value;
if (!target) return;
if ((event as ToggleEvent).newState === "open") {
place();
unfollow = followViewport(place);
target.querySelector<HTMLElement>(FOCUSABLE)?.focus();
return;
}
// Fokus kembali ke pemicu, kecuali user sudah memindahkannya ke elemen lain di luar panel.
const active = document.activeElement;
if (active === document.body || target.contains(active))
triggerEl.value?.focus();
}
function onKeydown(event: KeyboardEvent) {
if (event.key !== "Escape") return;
event.preventDefault();
panelEl.value?.hidePopover();
triggerEl.value?.focus();
}
onBeforeUnmount(stopFollowing);
</script>
<template>
<div :class="root">
<button
:id="`${panelId}-trigger`"
ref="trigger"
type="button"
:popovertarget="panelId"
aria-haspopup="dialog"
:aria-expanded="open ? 'true' : 'false'"
:aria-controls="panelId"
:data-state="state"
:class="triggerClass"
>
<slot name="trigger">{{ props.label }}</slot>
</button>
<div
:id="panelId"
ref="panelRef"
popover="auto"
role="dialog"
:aria-labelledby="`${panelId}-trigger`"
:data-state="state"
:class="panel"
@beforetoggle="onBeforeToggle"
@toggle="onToggle"
@keydown="onKeydown"
>
<slot />
</div>
</div>
</template>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/Popover.svelte.
<script lang="ts">
import type { Snippet } from "svelte";
import type { HTMLAttributes } from "svelte/elements";
const root = "inline-block";
const triggerClass =
"inline-flex h-10 items-center justify-center gap-2 rounded-lg border border-line bg-surface px-4 text-sm font-medium whitespace-nowrap text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=open]:bg-subtle motion-reduce:transition-none";
const panel =
"inset-auto m-0 w-72 max-w-[calc(100vw-16px)] rounded-xl border border-line bg-surface p-4 text-sm text-ink shadow-overlay";
const GAP = 4;
const FOCUSABLE =
"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])";
type Side = "top" | "bottom";
type Align = "start" | "center" | "end";
type Props = HTMLAttributes<HTMLDivElement> & {
/** Text of the trigger button. */
label?: string;
/** Custom trigger button content, replaces label. */
trigger?: Snippet;
side?: Side;
align?: Align;
children?: Snippet;
};
let {
label = "Open",
trigger,
side = "bottom",
align = "start",
id,
class: className,
children,
...rest
}: Props = $props();
const generatedId = $props.id();
const panelId = $derived(id ?? generatedId);
let triggerEl = $state<HTMLButtonElement>();
let panelEl = $state<HTMLDivElement>();
let open = $state(false);
const dataState = $derived(open ? "open" : "closed");
/** Place the panel on the chosen side with the chosen alignment, flip when it does not fit. */
function place() {
if (!triggerEl || !panelEl) return;
const anchor = triggerEl.getBoundingClientRect();
const { width, height } = panelEl.getBoundingClientRect();
const above = anchor.top - GAP - height;
const below = anchor.bottom + GAP;
const fitsAbove = above >= 0;
const fitsBelow = below + height <= window.innerHeight;
const onTop =
side === "top" ? fitsAbove || !fitsBelow : !fitsBelow && fitsAbove;
const starts: Record<Align, number> = {
start: anchor.left,
center: anchor.left + anchor.width / 2 - width / 2,
end: anchor.right - width,
};
const start = starts[align] ?? starts.start;
const left = Math.max(
GAP,
Math.min(start, window.innerWidth - width - GAP),
);
panelEl.style.top = `${onTop ? above : below}px`;
panelEl.style.left = `${left}px`;
}
// Re-place while open when the page scrolls or the window resizes.
$effect(() => {
if (!open) return;
const scrollOptions = { capture: true, passive: true };
window.addEventListener("scroll", place, scrollOptions);
window.addEventListener("resize", place, { passive: true });
return () => {
window.removeEventListener("scroll", place, scrollOptions);
window.removeEventListener("resize", place);
};
});
// beforetoggle runs synchronously, so the state is current for the next click.
function handleBeforeToggle(event: ToggleEvent) {
open = event.newState === "open";
}
function handleToggle(event: ToggleEvent) {
if (!panelEl) return;
if (event.newState === "open") {
place();
panelEl.querySelector<HTMLElement>(FOCUSABLE)?.focus();
return;
}
// Focus returns to the trigger, unless the user already moved it outside the panel.
const active = document.activeElement;
if (active === document.body || panelEl.contains(active))
triggerEl?.focus();
}
function handleKeydown(event: KeyboardEvent) {
if (event.key !== "Escape") return;
event.preventDefault();
panelEl?.hidePopover();
triggerEl?.focus();
}
</script>
<div class={[root, className]} {...rest}>
<button
bind:this={triggerEl}
type="button"
id={`${panelId}-trigger`}
popovertarget={panelId}
aria-haspopup="dialog"
aria-expanded={open}
aria-controls={panelId}
data-state={dataState}
class={triggerClass}
>
{#if trigger}{@render trigger()}{:else}{label}{/if}
</button>
<!-- svelte-ignore a11y_interactive_supports_focus -->
<div
bind:this={panelEl}
id={panelId}
popover="auto"
role="dialog"
aria-labelledby={`${panelId}-trigger`}
data-state={dataState}
class={panel}
onbeforetoggle={handleBeforeToggle}
ontoggle={handleToggle}
onkeydown={handleKeydown}
>
{@render children?.()}
</div>
</div>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/Popover.astro.
---
import type { HTMLAttributes } from "astro/types";
const root = "inline-block";
const triggerClass =
"inline-flex h-10 items-center justify-center gap-2 rounded-lg border border-line bg-surface px-4 text-sm font-medium whitespace-nowrap text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=open]:bg-subtle motion-reduce:transition-none";
const panel =
"inset-auto m-0 w-72 max-w-[calc(100vw-16px)] rounded-xl border border-line bg-surface p-4 text-sm text-ink shadow-overlay";
type Props = HTMLAttributes<"div"> & {
/** Text of the trigger button. */
label?: string;
side?: "top" | "bottom";
align?: "start" | "center" | "end";
};
const {
label = "Open",
side = "bottom",
align = "start",
id,
class: className,
...rest
} = Astro.props;
const panelId = id ?? `markas-popover-${crypto.randomUUID().slice(0, 8)}`;
---
<div class:list={[root, className]} {...rest}>
<button
type="button"
id={`${panelId}-trigger`}
popovertarget={panelId}
aria-haspopup="dialog"
aria-expanded="false"
aria-controls={panelId}
data-state="closed"
class={triggerClass}
>
{Astro.slots.has("trigger") ? <slot name="trigger" /> : label}
</button>
<div
id={panelId}
popover="auto"
role="dialog"
aria-labelledby={`${panelId}-trigger`}
data-state="closed"
data-markas-popover
data-side={side}
data-align={align}
class={panel}
>
<slot />
</div>
</div>
<script>
// One set of listeners per page serves every popover, including markup added later and
// pages reached through view transitions.
const GAP = 4;
const FOCUSABLE =
"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])";
const open = new Set<HTMLElement>();
const isPopover = (node: EventTarget | null): node is HTMLElement =>
node instanceof HTMLElement && node.hasAttribute("data-markas-popover");
const triggerOf = (panel: HTMLElement) =>
document.getElementById(`${panel.id}-trigger`);
/** Place the panel on the chosen side with the chosen alignment, flip when it does not fit. */
function place(panel: HTMLElement) {
const trigger = triggerOf(panel);
if (!trigger) return;
const anchor = trigger.getBoundingClientRect();
const { width, height } = panel.getBoundingClientRect();
const above = anchor.top - GAP - height;
const below = anchor.bottom + GAP;
const fitsAbove = above >= 0;
const fitsBelow = below + height <= window.innerHeight;
const onTop =
panel.dataset.side === "top"
? fitsAbove || !fitsBelow
: !fitsBelow && fitsAbove;
const starts: Record<string, number> = {
start: anchor.left,
center: anchor.left + anchor.width / 2 - width / 2,
end: anchor.right - width,
};
const start = starts[panel.dataset.align ?? ""] ?? anchor.left;
const left = Math.max(GAP, Math.min(start, window.innerWidth - width - GAP));
panel.style.top = `${onTop ? above : below}px`;
panel.style.left = `${left}px`;
}
// beforetoggle and toggle do not bubble, so listen in the capture phase.
document.addEventListener(
"beforetoggle",
(event) => {
if (!isPopover(event.target)) return;
const state = (event as ToggleEvent).newState;
const trigger = triggerOf(event.target);
event.target.dataset.state = state;
trigger?.setAttribute("data-state", state);
trigger?.setAttribute("aria-expanded", String(state === "open"));
},
true,
);
document.addEventListener(
"toggle",
(event) => {
const panel = event.target;
if (!isPopover(panel)) return;
if ((event as ToggleEvent).newState === "open") {
open.add(panel);
place(panel);
panel.querySelector<HTMLElement>(FOCUSABLE)?.focus();
return;
}
open.delete(panel);
// Focus returns to the trigger, unless the user already moved it outside the panel.
const active = document.activeElement;
if (active === document.body || panel.contains(active))
triggerOf(panel)?.focus();
},
true,
);
document.addEventListener("keydown", (event) => {
if (event.key !== "Escape") return;
const panel = (event.target as Element).closest?.(
"[data-markas-popover]",
);
if (!isPopover(panel)) return;
event.preventDefault();
panel.hidePopover();
triggerOf(panel)?.focus();
});
// Re-place open panels when the page scrolls or the window resizes.
const update = () =>
open.forEach((panel) =>
panel.isConnected ? place(panel) : open.delete(panel),
);
window.addEventListener("scroll", update, { capture: true, passive: true });
window.addEventListener("resize", update, { passive: true });
</script>- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/popover.component.ts.
import {
ChangeDetectionStrategy,
Component,
computed,
DestroyRef,
type ElementRef,
inject,
input,
signal,
viewChild,
} from "@angular/core";
const root = "inline-block";
const triggerClass =
"inline-flex h-10 items-center justify-center gap-2 rounded-lg border border-line bg-surface px-4 text-sm font-medium whitespace-nowrap text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary data-[state=open]:bg-subtle motion-reduce:transition-none";
const panel =
"inset-auto m-0 w-72 max-w-[calc(100vw-16px)] rounded-xl border border-line bg-surface p-4 text-sm text-ink shadow-overlay";
const GAP = 4;
const FOCUSABLE =
"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])";
type Side = "top" | "bottom";
type Align = "start" | "center" | "end";
let nextId = 0;
/**
* Slots: an element with the `trigger` attribute (an ng-container works) replaces the label
* inside the trigger button, everything else is the panel content.
* Host stays out of layout; id and class move to the root element and the panel.
*/
@Component({
selector: "markas-popover",
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: "contents", "[attr.id]": "null" },
template: `
<div [class]="rootClasses()">
<button
#trigger
type="button"
[id]="panelId() + '-trigger'"
[attr.popovertarget]="panelId()"
aria-haspopup="dialog"
[attr.aria-expanded]="open() ? 'true' : 'false'"
[attr.aria-controls]="panelId()"
[attr.data-state]="dataState()"
[class]="triggerClass"
>
<ng-content select="[trigger]">{{ label() }}</ng-content>
</button>
<div
#panelEl
[id]="panelId()"
popover="auto"
role="dialog"
[attr.aria-labelledby]="panelId() + '-trigger'"
[attr.data-state]="dataState()"
[class]="panel"
(beforetoggle)="handleBeforeToggle($event)"
(toggle)="handleToggle($event)"
(keydown)="handleKeydown($event)"
>
<ng-content />
</div>
</div>
`,
})
export class Popover {
/** Text of the trigger button. */
readonly label = input("Open");
readonly side = input<Side>("bottom");
readonly align = input<Align>("start");
readonly id = input<string>();
readonly userClass = input("", { alias: "class" });
protected readonly triggerClass = triggerClass;
protected readonly panel = panel;
protected readonly open = signal(false);
protected readonly dataState = computed(() =>
this.open() ? "open" : "closed",
);
private readonly generatedId = `markas-popover-${nextId++}`;
protected readonly panelId = computed(() => this.id() ?? this.generatedId);
protected readonly rootClasses = computed(() =>
[root, this.userClass()].filter(Boolean).join(" "),
);
private readonly triggerRef =
viewChild.required<ElementRef<HTMLButtonElement>>("trigger");
private readonly panelRef =
viewChild.required<ElementRef<HTMLDivElement>>("panelEl");
private readonly update = () => this.place();
private readonly scrollOptions = { capture: true, passive: true };
constructor() {
inject(DestroyRef).onDestroy(() => this.stopFollowing());
}
/** Place the panel on the chosen side with the chosen alignment, flip when it does not fit. */
private place() {
const target = this.panelRef().nativeElement;
const anchor = this.triggerRef().nativeElement.getBoundingClientRect();
const { width, height } = target.getBoundingClientRect();
const above = anchor.top - GAP - height;
const below = anchor.bottom + GAP;
const fitsAbove = above >= 0;
const fitsBelow = below + height <= window.innerHeight;
const onTop =
this.side() === "top" ? fitsAbove || !fitsBelow : !fitsBelow && fitsAbove;
const starts: Record<Align, number> = {
start: anchor.left,
center: anchor.left + anchor.width / 2 - width / 2,
end: anchor.right - width,
};
const start = starts[this.align()] ?? starts.start;
const left = Math.max(
GAP,
Math.min(start, window.innerWidth - width - GAP),
);
target.style.top = `${onTop ? above : below}px`;
target.style.left = `${left}px`;
}
private stopFollowing() {
window.removeEventListener("scroll", this.update, this.scrollOptions);
window.removeEventListener("resize", this.update);
}
// beforetoggle runs synchronously, so the state is current for the next click.
protected handleBeforeToggle(event: Event) {
this.open.set((event as ToggleEvent).newState === "open");
}
protected handleToggle(event: Event) {
this.stopFollowing();
const target = this.panelRef().nativeElement;
if ((event as ToggleEvent).newState === "open") {
this.place();
// Re-place while open when the page scrolls or the window resizes.
window.addEventListener("scroll", this.update, this.scrollOptions);
window.addEventListener("resize", this.update, { passive: true });
target.querySelector<HTMLElement>(FOCUSABLE)?.focus();
return;
}
// Focus returns to the trigger, unless the user already moved it outside the panel.
const active = document.activeElement;
if (active === document.body || target.contains(active))
this.triggerRef().nativeElement.focus();
}
protected handleKeydown(event: KeyboardEvent) {
if (event.key !== "Escape") return;
event.preventDefault();
this.panelRef().nativeElement.hidePopover();
this.triggerRef().nativeElement.focus();
}
}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) andalign(start,center,end). - Use the
triggerslot 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
labelin the language of your site.
Props
| Name | Type | Default | Description |
|---|---|---|---|
label | string | Open | Text of the trigger button. |
trigger | slot / 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 / slot | slot / ReactNode | - | Panel content, such as a short form or details. |
side | top | bottom | bottom | Side of the trigger to show the panel on. Flips to the other side when it does not fit on screen. |
align | start | center | end | start | Horizontal alignment of the panel against the trigger. |
id | string | auto | Panel 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.
- Alert DialogModal confirmation built on the native dialog element. It needs an explicit cancel or action choice and never closes on a backdrop click.
- Command PaletteSearchable list of commands in a modal dialog, filtered as you type, with arrow key navigation and an optional Ctrl+K or Cmd+K shortcut.
- Context MenuMenu opened by right-clicking an area or pressing Shift+F10, shown at the pointer through the Popover API with WAI-ARIA Menu keyboard support.
- DrawerFull-height side panel built on the native dialog element, sliding in from the right or left.
- Dropdown MenuAction menu built on the Popover API, with keyboard navigation following the WAI-ARIA Menu Button pattern.
- Hover CardPreview card built on the Popover API, shown when a link is hovered or focused, for profiles, repositories, and other previews.