Teks bantuan singkat berbasis Popover API yang muncul saat pemicu di-hover atau difokus.
Copy link to clipboard
Copy link to clipboard
Copy link to clipboard
Copy link to clipboard
<div class="flex justify-center py-10">
<x-markas.tooltip content="Copy link to clipboard">
<x-markas.button variant="secondary">Copy link</x-markas.button>
</x-markas.tooltip>
</div>import { Button } from "@/components/markas/Button";
import { Tooltip } from "@/components/markas/Tooltip";
export default function TooltipExample() {
return (
<div className="flex justify-center py-10">
<Tooltip content="Copy link to clipboard">
<Button variant="secondary">Copy link</Button>
</Tooltip>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Tooltip from "@/components/markas/Tooltip.vue";
</script>
<template>
<div class="flex justify-center py-10">
<Tooltip content="Copy link to clipboard">
<Button variant="secondary">Copy link</Button>
</Tooltip>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Tooltip from "$lib/components/markas/Tooltip.svelte";
</script>
<div class="flex justify-center py-10">
<Tooltip content="Copy link to clipboard">
<Button variant="secondary">Copy link</Button>
</Tooltip>
</div>---
import Button from "@/components/markas/Button.astro";
import Tooltip from "@/components/markas/Tooltip.astro";
---
<div class="flex justify-center py-10">
<Tooltip content="Copy link to clipboard">
<Button variant="secondary">Copy link</Button>
</Tooltip>
</div>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Tooltip } from "./markas/tooltip.component";
@Component({
selector: "markas-example",
imports: [Button, Tooltip],
template: `
<div class="flex justify-center py-10">
<markas-tooltip content="Copy link to clipboard">
<button markas-button variant="secondary">Copy link</button>
</markas-tooltip>
</div>
`,
})
export default class TooltipExample {}Contoh
Pada tombol ikon
Bold (Ctrl+B)
Italic (Ctrl+I)
Insert link (Ctrl+K)
Bold (Ctrl+B)Italic (Ctrl+I)Insert link (Ctrl+K)
Bold (Ctrl+B)Italic (Ctrl+I)Insert link (Ctrl+K)
Bold (Ctrl+B) Italic (Ctrl+I) Insert link (Ctrl+K)
<div class="flex justify-center py-10">
<div class="flex items-center gap-1 rounded-lg border border-line bg-surface p-1">
<x-markas.tooltip content="Bold (Ctrl+B)">
<x-markas.button variant="ghost" size="sm" aria-label="Bold" class="size-8 px-0">
<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="M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z" /></svg>
</x-markas.button>
</x-markas.tooltip>
<x-markas.tooltip content="Italic (Ctrl+I)">
<x-markas.button variant="ghost" size="sm" aria-label="Italic" class="size-8 px-0">
<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="M19 4h-9M14 20H5M15 4 9 20" /></svg>
</x-markas.button>
</x-markas.tooltip>
<x-markas.tooltip content="Insert link (Ctrl+K)">
<x-markas.button variant="ghost" size="sm" aria-label="Insert link" class="size-8 px-0">
<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="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" /></svg>
</x-markas.button>
</x-markas.tooltip>
</div>
</div>import { Button } from "@/components/markas/Button";
import { Tooltip } from "@/components/markas/Tooltip";
export default function Example() {
return (
<div className="flex justify-center py-10">
<div className="flex items-center gap-1 rounded-lg border border-line bg-surface p-1">
<Tooltip content="Bold (Ctrl+B)">
<Button
variant="ghost"
size="sm"
aria-label="Bold"
className="size-8 px-0"
>
<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="M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z" />
</svg>
</Button>
</Tooltip>
<Tooltip content="Italic (Ctrl+I)">
<Button
variant="ghost"
size="sm"
aria-label="Italic"
className="size-8 px-0"
>
<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="M19 4h-9M14 20H5M15 4 9 20" />
</svg>
</Button>
</Tooltip>
<Tooltip content="Insert link (Ctrl+K)">
<Button
variant="ghost"
size="sm"
aria-label="Insert link"
className="size-8 px-0"
>
<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="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />
</svg>
</Button>
</Tooltip>
</div>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Tooltip from "@/components/markas/Tooltip.vue";
</script>
<template>
<div class="flex justify-center py-10">
<div
class="flex items-center gap-1 rounded-lg border border-line bg-surface p-1"
>
<Tooltip content="Bold (Ctrl+B)">
<Button variant="ghost" size="sm" aria-label="Bold" class="size-8 px-0">
<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="M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z" />
</svg>
</Button>
</Tooltip>
<Tooltip content="Italic (Ctrl+I)">
<Button
variant="ghost"
size="sm"
aria-label="Italic"
class="size-8 px-0"
>
<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="M19 4h-9M14 20H5M15 4 9 20" />
</svg>
</Button>
</Tooltip>
<Tooltip content="Insert link (Ctrl+K)">
<Button
variant="ghost"
size="sm"
aria-label="Insert link"
class="size-8 px-0"
>
<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="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
/>
</svg>
</Button>
</Tooltip>
</div>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Tooltip from "$lib/components/markas/Tooltip.svelte";
</script>
<div class="flex justify-center py-10">
<div
class="flex items-center gap-1 rounded-lg border border-line bg-surface p-1"
>
<Tooltip content="Bold (Ctrl+B)">
<Button variant="ghost" size="sm" aria-label="Bold" class="size-8 px-0">
<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="M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z" />
</svg>
</Button>
</Tooltip>
<Tooltip content="Italic (Ctrl+I)">
<Button variant="ghost" size="sm" aria-label="Italic" class="size-8 px-0">
<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="M19 4h-9M14 20H5M15 4 9 20" />
</svg>
</Button>
</Tooltip>
<Tooltip content="Insert link (Ctrl+K)">
<Button
variant="ghost"
size="sm"
aria-label="Insert link"
class="size-8 px-0"
>
<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="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
/>
</svg>
</Button>
</Tooltip>
</div>
</div>---
import Button from "@/components/markas/Button.astro";
import Tooltip from "@/components/markas/Tooltip.astro";
---
<div class="flex justify-center py-10">
<div class="flex items-center gap-1 rounded-lg border border-line bg-surface p-1">
<Tooltip content="Bold (Ctrl+B)">
<Button variant="ghost" size="sm" aria-label="Bold" class="size-8 px-0">
<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="M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z"></path>
</svg>
</Button>
</Tooltip>
<Tooltip content="Italic (Ctrl+I)">
<Button variant="ghost" size="sm" aria-label="Italic" class="size-8 px-0">
<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="M19 4h-9M14 20H5M15 4 9 20"></path>
</svg>
</Button>
</Tooltip>
<Tooltip content="Insert link (Ctrl+K)">
<Button variant="ghost" size="sm" aria-label="Insert link" class="size-8 px-0">
<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="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
</svg>
</Button>
</Tooltip>
</div>
</div>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Tooltip } from "./markas/tooltip.component";
@Component({
selector: "markas-example",
imports: [Button, Tooltip],
template: `
<div class="flex justify-center py-10">
<div
class="flex items-center gap-1 rounded-lg border border-line bg-surface p-1"
>
<markas-tooltip content="Bold (Ctrl+B)">
<button
markas-button
variant="ghost"
size="sm"
aria-label="Bold"
class="size-8 px-0"
>
<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="M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z"
/>
</svg>
</button>
</markas-tooltip>
<markas-tooltip content="Italic (Ctrl+I)">
<button
markas-button
variant="ghost"
size="sm"
aria-label="Italic"
class="size-8 px-0"
>
<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="M19 4h-9M14 20H5M15 4 9 20" />
</svg>
</button>
</markas-tooltip>
<markas-tooltip content="Insert link (Ctrl+K)">
<button
markas-button
variant="ghost"
size="sm"
aria-label="Insert link"
class="size-8 px-0"
>
<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="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
/>
</svg>
</button>
</markas-tooltip>
</div>
</div>
`,
})
export default class TooltipIconButtonsExample {}Atas dan bawah
Shown above the button
Shown below the button
Shown above the buttonShown below the button
Shown above the buttonShown below the button
Shown above the button Shown below the button
<div class="flex flex-wrap items-center justify-center gap-3 py-10">
<x-markas.tooltip content="Shown above the button">
<x-markas.button variant="secondary">Top</x-markas.button>
</x-markas.tooltip>
<x-markas.tooltip content="Shown below the button" side="bottom">
<x-markas.button variant="secondary">Bottom</x-markas.button>
</x-markas.tooltip>
</div>import { Button } from "@/components/markas/Button";
import { Tooltip } from "@/components/markas/Tooltip";
export default function Example() {
return (
<div className="flex flex-wrap items-center justify-center gap-3 py-10">
<Tooltip content="Shown above the button">
<Button variant="secondary">Top</Button>
</Tooltip>
<Tooltip content="Shown below the button" side="bottom">
<Button variant="secondary">Bottom</Button>
</Tooltip>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Tooltip from "@/components/markas/Tooltip.vue";
</script>
<template>
<div class="flex flex-wrap items-center justify-center gap-3 py-10">
<Tooltip content="Shown above the button">
<Button variant="secondary">Top</Button>
</Tooltip>
<Tooltip content="Shown below the button" side="bottom">
<Button variant="secondary">Bottom</Button>
</Tooltip>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Tooltip from "$lib/components/markas/Tooltip.svelte";
</script>
<div class="flex flex-wrap items-center justify-center gap-3 py-10">
<Tooltip content="Shown above the button">
<Button variant="secondary">Top</Button>
</Tooltip>
<Tooltip content="Shown below the button" side="bottom">
<Button variant="secondary">Bottom</Button>
</Tooltip>
</div>---
import Button from "@/components/markas/Button.astro";
import Tooltip from "@/components/markas/Tooltip.astro";
---
<div class="flex flex-wrap items-center justify-center gap-3 py-10">
<Tooltip content="Shown above the button">
<Button variant="secondary">Top</Button>
</Tooltip>
<Tooltip content="Shown below the button" side="bottom">
<Button variant="secondary">Bottom</Button>
</Tooltip>
</div>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Tooltip } from "./markas/tooltip.component";
@Component({
selector: "markas-example",
imports: [Button, Tooltip],
template: `
<div class="flex flex-wrap items-center justify-center gap-3 py-10">
<markas-tooltip content="Shown above the button">
<button markas-button variant="secondary">Top</button>
</markas-tooltip>
<markas-tooltip content="Shown below the button" side="bottom">
<button markas-button variant="secondary">Bottom</button>
</markas-tooltip>
</div>
`,
})
export default class TooltipSidesExample {}Ikon bantuan
Tax ID
Your 15 digit tax number. It appears on every invoice we send you.
Tax IDYour 15 digit tax number. It appears on every invoice we send you.
Tax IDYour 15 digit tax number. It appears on every invoice we send you.
Tax ID Your 15 digit tax number. It appears on every invoice we send you.
Tax IDYour 15 digit tax number. It appears on every invoice we send you.
<div class="flex items-center justify-center gap-1 py-10">
<span class="text-sm font-medium text-ink">Tax ID</span>
<x-markas.tooltip content="Your 15 digit tax number. It appears on every invoice we send you.">
<x-markas.button variant="ghost" size="sm" aria-label="About tax ID" class="size-8 px-0">
<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"><circle cx="12" cy="12" r="9" /><path d="M12 16v-4M12 8h.01" /></svg>
</x-markas.button>
</x-markas.tooltip>
</div>import { Button } from "@/components/markas/Button";
import { Tooltip } from "@/components/markas/Tooltip";
export default function Example() {
return (
<div className="flex items-center justify-center gap-1 py-10">
<span className="text-sm font-medium text-ink">Tax ID</span>
<Tooltip content="Your 15 digit tax number. It appears on every invoice we send you.">
<Button
variant="ghost"
size="sm"
aria-label="About tax ID"
className="size-8 px-0"
>
<svg
className="size-4"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<circle cx="12" cy="12" r="9" />
<path d="M12 16v-4M12 8h.01" />
</svg>
</Button>
</Tooltip>
</div>
);
}<script setup lang="ts">
import Button from "@/components/markas/Button.vue";
import Tooltip from "@/components/markas/Tooltip.vue";
</script>
<template>
<div class="flex items-center justify-center gap-1 py-10">
<span class="text-sm font-medium text-ink">Tax ID</span>
<Tooltip
content="Your 15 digit tax number. It appears on every invoice we send you."
>
<Button
variant="ghost"
size="sm"
aria-label="About tax ID"
class="size-8 px-0"
>
<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"
>
<circle cx="12" cy="12" r="9" />
<path d="M12 16v-4M12 8h.01" />
</svg>
</Button>
</Tooltip>
</div>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Tooltip from "$lib/components/markas/Tooltip.svelte";
</script>
<div class="flex items-center justify-center gap-1 py-10">
<span class="text-sm font-medium text-ink">Tax ID</span>
<Tooltip
content="Your 15 digit tax number. It appears on every invoice we send you."
>
<Button
variant="ghost"
size="sm"
aria-label="About tax ID"
class="size-8 px-0"
>
<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"
>
<circle cx="12" cy="12" r="9" />
<path d="M12 16v-4M12 8h.01" />
</svg>
</Button>
</Tooltip>
</div>---
import Button from "@/components/markas/Button.astro";
import Tooltip from "@/components/markas/Tooltip.astro";
---
<div class="flex items-center justify-center gap-1 py-10">
<span class="text-sm font-medium text-ink">Tax ID</span>
<Tooltip
content="Your 15 digit tax number. It appears on every invoice we send you."
>
<Button variant="ghost" size="sm" aria-label="About tax ID" class="size-8 px-0">
<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"
>
<circle cx="12" cy="12" r="9"></circle>
<path d="M12 16v-4M12 8h.01"></path>
</svg>
</Button>
</Tooltip>
</div>import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Tooltip } from "./markas/tooltip.component";
@Component({
selector: "markas-example",
imports: [Button, Tooltip],
template: `
<div class="flex items-center justify-center gap-1 py-10">
<span class="text-sm font-medium text-ink">Tax ID</span>
<markas-tooltip
content="Your 15 digit tax number. It appears on every invoice we send you."
>
<button
markas-button
variant="ghost"
size="sm"
aria-label="About tax ID"
class="size-8 px-0"
>
<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"
>
<circle cx="12" cy="12" r="9" />
<path d="M12 16v-4M12 8h.01" />
</svg>
</button>
</markas-tooltip>
</div>
`,
})
export default class TooltipHelpIconExample {}Instalasi
npx markasui@latest add tooltippnpm dlx markasui@latest add tooltipyarn dlx markasui@latest add tooltipbunx --bun markasui@latest add tooltip- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Pasang dependensi:
npm install alpinejs - Salin source komponen di bawah ini ke
resources/views/components/markas/tooltip.blade.php.
resources/views/components/markas/tooltip.blade.php
@props([
'content',
'side' => 'top',
])
@php
$root = 'inline-flex';
$tooltip = 'inset-auto m-0 max-w-64 rounded-md bg-ink px-2 py-1 text-xs font-medium text-canvas 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-tooltip|'.(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-tooltip-'.hash('xxh32', $idKey.$idIndex);
@endphp
<span
x-data="{
open: false,
timer: null,
show() {
clearTimeout(this.timer);
{{-- Link again in case a re-render (Livewire morph) dropped aria-describedby from the trigger. --}}
this.describe();
this.$refs.tip.showPopover();
},
showLater() {
clearTimeout(this.timer);
this.timer = setTimeout(() => this.show(), 300);
},
hide() {
clearTimeout(this.timer);
this.$refs.tip.hidePopover();
},
describe() {
const trigger = this.$root.firstElementChild;
const described = trigger?.getAttribute('aria-describedby') ?? '';
if (trigger && trigger !== this.$refs.tip && !described.split(' ').includes(@js($id))) {
trigger.setAttribute('aria-describedby', [described, @js($id)].filter(Boolean).join(' '));
}
},
{{-- Letakkan tooltip di tengah pemicu pada sisi yang dipilih, pindah sisi kalau tidak muat. --}}
place() {
const gap = 6;
const anchor = this.$root.getBoundingClientRect();
const { width, height } = this.$refs.tip.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;
this.$refs.tip.style.top = (onTop ? above : below) + 'px';
this.$refs.tip.style.left = Math.max(gap, Math.min(anchor.left + anchor.width / 2 - width / 2, 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?.();
},
onToggle(event) {
this.open = event.newState === 'open';
if (! this.open) return this.unfollow?.();
this.place();
this.follow();
},
}"
x-init="describe()"
@mouseenter="showLater()"
@mouseleave="hide()"
@focusin="show()"
@focusout="hide()"
@keydown.escape.window="hide()"
{{ $attributes->except('id')->class([$root]) }}
>{{ $slot }}<span
x-ref="tip"
id="{{ $id }}"
popover="manual"
wire:ignore.self
role="tooltip"
data-state="closed"
:data-state="open ? 'open' : 'closed'"
@toggle="onToggle($event)"
class="{{ $tooltip }}"
>{{ $content }}</span></span>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/Tooltip.tsx.
src/components/markas/Tooltip.tsx
"use client";
import {
useEffect,
useId,
useRef,
useState,
type ComponentProps,
type ToggleEvent,
} from "react";
const root = "inline-flex";
const tooltip =
"inset-auto m-0 max-w-64 rounded-md bg-ink px-2 py-1 text-xs font-medium text-canvas shadow-overlay";
const cx = (...c: (string | false | null | undefined)[]) =>
c.filter(Boolean).join(" ");
const GAP = 6;
const SHOW_DELAY = 300;
type Side = "top" | "bottom";
/** Letakkan tooltip di tengah pemicu pada sisi yang dipilih, pindah sisi kalau tidak muat. */
function placeTooltip(trigger: HTMLElement, tip: HTMLElement, side: Side) {
const anchor = trigger.getBoundingClientRect();
const { width, height } = tip.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 left = Math.max(
GAP,
Math.min(
anchor.left + anchor.width / 2 - width / 2,
window.innerWidth - width - GAP,
),
);
tip.style.top = `${onTop ? above : below}px`;
tip.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 TooltipProps = ComponentProps<"span"> & {
content: string;
side?: Side;
};
export function Tooltip({
content,
side = "top",
id,
className,
children,
...props
}: TooltipProps) {
const generatedId = useId();
const tooltipId = id ?? generatedId;
const rootRef = useRef<HTMLSpanElement>(null);
const tipRef = useRef<HTMLSpanElement>(null);
const timer = useRef<ReturnType<typeof setTimeout>>(undefined);
const [open, setOpen] = useState(false);
const show = () => {
clearTimeout(timer.current);
tipRef.current?.showPopover();
};
const showLater = () => {
clearTimeout(timer.current);
timer.current = setTimeout(show, SHOW_DELAY);
};
const hide = () => {
clearTimeout(timer.current);
tipRef.current?.hidePopover();
};
useEffect(() => {
const trigger = rootRef.current?.firstElementChild;
const described = trigger?.getAttribute("aria-describedby") ?? "";
if (trigger && !described.split(" ").includes(tooltipId))
trigger.setAttribute(
"aria-describedby",
[described, tooltipId].filter(Boolean).join(" "),
);
const onKeyDown = (event: KeyboardEvent) => {
if (event.key !== "Escape") return;
clearTimeout(timer.current);
tipRef.current?.hidePopover();
};
document.addEventListener("keydown", onKeyDown);
return () => {
document.removeEventListener("keydown", onKeyDown);
clearTimeout(timer.current);
};
}, [tooltipId]);
useEffect(() => {
if (!open) return;
return followViewport(() => {
if (rootRef.current && tipRef.current)
placeTooltip(rootRef.current, tipRef.current, side);
});
}, [open, side]);
const handleToggle = (event: ToggleEvent<HTMLSpanElement>) => {
const isOpen = event.newState === "open";
setOpen(isOpen);
if (isOpen && rootRef.current && tipRef.current)
placeTooltip(rootRef.current, tipRef.current, side);
};
return (
<span
ref={rootRef}
{...props}
className={cx(root, className)}
onMouseEnter={showLater}
onMouseLeave={hide}
onFocus={show}
onBlur={hide}
>
{children}
<span
ref={tipRef}
id={tooltipId}
popover="manual"
role="tooltip"
data-state={open ? "open" : "closed"}
className={tooltip}
onToggle={handleToggle}
>
{content}
</span>
</span>
);
}- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/Tooltip.vue.
src/components/markas/Tooltip.vue
<script setup lang="ts">
import {
computed,
onBeforeUnmount,
onMounted,
ref,
useId,
useTemplateRef,
} from "vue";
type Side = "top" | "bottom";
const props = withDefaults(
defineProps<{
content: string;
side?: Side;
id?: string;
}>(),
{ side: "top", id: undefined },
);
const root = "inline-flex";
const tooltip =
"inset-auto m-0 max-w-64 rounded-md bg-ink px-2 py-1 text-xs font-medium text-canvas shadow-overlay";
const GAP = 6;
const SHOW_DELAY = 300;
/** Letakkan tooltip di tengah pemicu pada sisi yang dipilih, pindah sisi kalau tidak muat. */
function placeTooltip(trigger: HTMLElement, tip: HTMLElement, side: Side) {
const anchor = trigger.getBoundingClientRect();
const { width, height } = tip.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 left = Math.max(
GAP,
Math.min(
anchor.left + anchor.width / 2 - width / 2,
window.innerWidth - width - GAP,
),
);
tip.style.top = `${onTop ? above : below}px`;
tip.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 tooltipId = computed(() => props.id ?? generatedId);
const rootEl = useTemplateRef<HTMLSpanElement>("rootRef");
const tipEl = useTemplateRef<HTMLSpanElement>("tip");
const open = ref(false);
let timer: ReturnType<typeof setTimeout> | undefined;
let unfollow: (() => void) | undefined;
function show() {
clearTimeout(timer);
tipEl.value?.showPopover();
}
function showLater() {
clearTimeout(timer);
timer = setTimeout(show, SHOW_DELAY);
}
function hide() {
clearTimeout(timer);
tipEl.value?.hidePopover();
}
function onKeydown(event: KeyboardEvent) {
if (event.key === "Escape") hide();
}
function stopFollowing() {
unfollow?.();
unfollow = undefined;
}
function place() {
if (rootEl.value && tipEl.value)
placeTooltip(rootEl.value, tipEl.value, props.side);
}
function onToggle(event: Event) {
stopFollowing();
open.value = (event as ToggleEvent).newState === "open";
if (!open.value) return;
place();
unfollow = followViewport(place);
}
onMounted(() => {
const trigger = rootEl.value?.firstElementChild;
const described = trigger?.getAttribute("aria-describedby") ?? "";
if (trigger && !described.split(" ").includes(tooltipId.value))
trigger.setAttribute(
"aria-describedby",
[described, tooltipId.value].filter(Boolean).join(" "),
);
document.addEventListener("keydown", onKeydown);
});
onBeforeUnmount(() => {
document.removeEventListener("keydown", onKeydown);
clearTimeout(timer);
stopFollowing();
});
</script>
<template>
<span
ref="rootRef"
:class="root"
@mouseenter="showLater"
@mouseleave="hide"
@focusin="show"
@focusout="hide"
>
<slot />
<span
:id="tooltipId"
ref="tip"
popover="manual"
role="tooltip"
:data-state="open ? 'open' : 'closed'"
:class="tooltip"
@toggle="onToggle"
>{{ props.content }}</span
>
</span>
</template>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/lib/components/markas/Tooltip.svelte.
src/lib/components/markas/Tooltip.svelte
<script lang="ts">
import type { Snippet } from "svelte";
import type { HTMLAttributes } from "svelte/elements";
const root = "inline-flex";
const tooltip =
"inset-auto m-0 max-w-64 rounded-md bg-ink px-2 py-1 text-xs font-medium text-canvas shadow-overlay";
const GAP = 6;
const SHOW_DELAY = 300;
type Side = "top" | "bottom";
/** Places the tooltip centered on the trigger on the chosen side, flipping when it does not fit. */
function placeTooltip(trigger: HTMLElement, tip: HTMLElement, side: Side) {
const anchor = trigger.getBoundingClientRect();
const { width, height } = tip.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 left = Math.max(
GAP,
Math.min(
anchor.left + anchor.width / 2 - width / 2,
window.innerWidth - width - GAP,
),
);
tip.style.top = `${onTop ? above : below}px`;
tip.style.left = `${left}px`;
}
/** Re-runs placement on scroll and resize. Returns the cleanup function. */
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);
};
}
type Props = HTMLAttributes<HTMLSpanElement> & {
content: string;
side?: Side;
children?: Snippet;
};
let {
content,
side = "top",
id,
class: className,
children,
...rest
}: Props = $props();
const generatedId = $props.id();
const tooltipId = $derived(id ?? generatedId);
let rootEl = $state<HTMLSpanElement>();
let tip = $state<HTMLSpanElement>();
let open = $state(false);
let timer: ReturnType<typeof setTimeout> | undefined;
function show() {
clearTimeout(timer);
tip?.showPopover();
}
function showLater() {
clearTimeout(timer);
timer = setTimeout(show, SHOW_DELAY);
}
function hide() {
clearTimeout(timer);
tip?.hidePopover();
}
function place() {
if (rootEl && tip) placeTooltip(rootEl, tip, side);
}
function handleToggle(event: ToggleEvent) {
open = event.newState === "open";
if (open) place();
}
$effect(() => {
const trigger = rootEl?.firstElementChild;
const described = trigger?.getAttribute("aria-describedby") ?? "";
if (trigger && trigger !== tip && !described.split(" ").includes(tooltipId))
trigger.setAttribute(
"aria-describedby",
[described, tooltipId].filter(Boolean).join(" "),
);
const onKeydown = (event: KeyboardEvent) => {
if (event.key === "Escape") hide();
};
document.addEventListener("keydown", onKeydown);
return () => {
document.removeEventListener("keydown", onKeydown);
clearTimeout(timer);
};
});
$effect(() => {
if (open) return followViewport(place);
});
</script>
<!-- svelte-ignore a11y_no_static_element_interactions -->
<span
bind:this={rootEl}
{...rest}
class={[root, className]}
onmouseenter={showLater}
onmouseleave={hide}
onfocusin={show}
onfocusout={hide}
>
{@render children?.()}<span
bind:this={tip}
id={tooltipId}
popover="manual"
role="tooltip"
data-state={open ? "open" : "closed"}
class={tooltip}
ontoggle={handleToggle}>{content}</span
>
</span>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/Tooltip.astro.
src/components/markas/Tooltip.astro
---
import type { HTMLAttributes } from "astro/types";
const root = "inline-flex";
const tooltip =
"inset-auto m-0 max-w-64 rounded-md bg-ink px-2 py-1 text-xs font-medium text-canvas shadow-overlay";
type Props = HTMLAttributes<"span"> & {
content: string;
side?: "top" | "bottom";
};
const { content, side = "top", id, class: className, ...rest } = Astro.props;
const tooltipId = id ?? `markas-tooltip-${crypto.randomUUID().slice(0, 8)}`;
---
<markas-tooltip class="contents" data-side={side}>
<span class:list={[root, className]} {...rest}
><slot /><span
id={tooltipId}
popover="manual"
role="tooltip"
data-state="closed"
class={tooltip}>{content}</span
></span
>
</markas-tooltip>
<script>
const GAP = 6;
const SHOW_DELAY = 300;
/** Places the tooltip centered on the trigger on the chosen side, flipping when it does not fit. */
function placeTooltip(trigger: HTMLElement, tip: HTMLElement, side: string) {
const anchor = trigger.getBoundingClientRect();
const { width, height } = tip.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 left = Math.max(
GAP,
Math.min(
anchor.left + anchor.width / 2 - width / 2,
window.innerWidth - width - GAP,
),
);
tip.style.top = `${onTop ? above : below}px`;
tip.style.left = `${left}px`;
}
// One element per tooltip: setup runs for markup added later and after view transitions.
class MarkasTooltip extends HTMLElement {
private timer: ReturnType<typeof setTimeout> | undefined;
private cleanup: (() => void) | undefined;
connectedCallback() {
const root = this.firstElementChild as HTMLElement | null;
const tip = root?.querySelector<HTMLElement>(":scope > [role=tooltip]");
if (!root || !tip) return;
const trigger = root.firstElementChild;
const described = trigger?.getAttribute("aria-describedby") ?? "";
if (trigger && trigger !== tip && !described.split(" ").includes(tip.id))
trigger.setAttribute(
"aria-describedby",
[described, tip.id].filter(Boolean).join(" "),
);
const show = () => {
clearTimeout(this.timer);
tip.showPopover();
};
const showLater = () => {
clearTimeout(this.timer);
this.timer = setTimeout(show, SHOW_DELAY);
};
const hide = () => {
clearTimeout(this.timer);
if (tip.matches(":popover-open")) tip.hidePopover();
};
const onKeydown = (event: KeyboardEvent) => {
if (event.key === "Escape") hide();
};
const place = () => placeTooltip(root, tip, this.dataset.side ?? "top");
const scrollOptions = { capture: true, passive: true };
const follow = (on: boolean) => {
const method = on ? "addEventListener" : "removeEventListener";
window[method]("scroll", place, scrollOptions);
window[method]("resize", place, { passive: true });
};
const onToggle = (event: Event) => {
const open = (event as ToggleEvent).newState === "open";
tip.dataset.state = open ? "open" : "closed";
follow(open);
if (open) place();
};
root.addEventListener("mouseenter", showLater);
root.addEventListener("mouseleave", hide);
root.addEventListener("focusin", show);
root.addEventListener("focusout", hide);
tip.addEventListener("toggle", onToggle);
document.addEventListener("keydown", onKeydown);
this.cleanup = () => {
clearTimeout(this.timer);
follow(false);
root.removeEventListener("mouseenter", showLater);
root.removeEventListener("mouseleave", hide);
root.removeEventListener("focusin", show);
root.removeEventListener("focusout", hide);
tip.removeEventListener("toggle", onToggle);
document.removeEventListener("keydown", onKeydown);
};
}
disconnectedCallback() {
this.cleanup?.();
}
}
if (!customElements.get("markas-tooltip"))
customElements.define("markas-tooltip", MarkasTooltip);
</script>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/app/markas/tooltip.component.ts.
src/app/markas/tooltip.component.ts
import {
afterNextRender,
ChangeDetectionStrategy,
Component,
computed,
DestroyRef,
ElementRef,
inject,
input,
signal,
viewChild,
} from "@angular/core";
const root = "inline-flex";
const tooltip =
"inset-auto m-0 max-w-64 rounded-md bg-ink px-2 py-1 text-xs font-medium text-canvas shadow-overlay";
const GAP = 6;
const SHOW_DELAY = 300;
export type TooltipSide = "top" | "bottom";
/** Places the tooltip centered on the trigger on the chosen side, flipping when it does not fit. */
function placeTooltip(
trigger: HTMLElement,
tip: HTMLElement,
side: TooltipSide,
) {
const anchor = trigger.getBoundingClientRect();
const { width, height } = tip.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 left = Math.max(
GAP,
Math.min(
anchor.left + anchor.width / 2 - width / 2,
window.innerWidth - width - GAP,
),
);
tip.style.top = `${onTop ? above : below}px`;
tip.style.left = `${left}px`;
}
/** Re-runs placement on scroll and resize. Returns the cleanup function. */
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);
};
}
let nextId = 0;
/**
* The host is the inline-flex wrapper (the span in other frameworks), so class and other
* attributes stay on it. The first projected element is the trigger; id moves to the tooltip.
*/
@Component({
selector: "markas-tooltip",
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: root,
"[attr.id]": "null",
"(mouseenter)": "showLater()",
"(mouseleave)": "hide()",
"(focusin)": "show()",
"(focusout)": "hide()",
"(document:keydown.escape)": "hide()",
},
template: `<ng-content /><span
#tip
[id]="tooltipId()"
popover="manual"
role="tooltip"
[attr.data-state]="open() ? 'open' : 'closed'"
[class]="tooltip"
(toggle)="handleToggle($event)"
>{{ content() }}</span
>`,
})
export class Tooltip {
readonly content = input.required<string>();
readonly side = input<TooltipSide>("top");
readonly id = input<string>();
protected readonly tooltip = tooltip;
protected readonly open = signal(false);
private readonly generatedId = `markas-tooltip-${nextId++}`;
protected readonly tooltipId = computed(() => this.id() ?? this.generatedId);
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
private readonly tip = viewChild.required<ElementRef<HTMLElement>>("tip");
private timer: ReturnType<typeof setTimeout> | undefined;
private unfollow: (() => void) | undefined;
constructor() {
afterNextRender(() => {
const tip = this.tip().nativeElement;
const trigger = this.host.nativeElement.firstElementChild;
const id = this.tooltipId();
const described = trigger?.getAttribute("aria-describedby") ?? "";
if (trigger && trigger !== tip && !described.split(" ").includes(id))
trigger.setAttribute(
"aria-describedby",
[described, id].filter(Boolean).join(" "),
);
});
inject(DestroyRef).onDestroy(() => {
clearTimeout(this.timer);
this.unfollow?.();
});
}
protected show() {
clearTimeout(this.timer);
this.tip().nativeElement.showPopover();
}
protected showLater() {
clearTimeout(this.timer);
this.timer = setTimeout(() => this.show(), SHOW_DELAY);
}
protected hide() {
clearTimeout(this.timer);
this.tip().nativeElement.hidePopover();
}
private place() {
placeTooltip(
this.host.nativeElement,
this.tip().nativeElement,
this.side(),
);
}
protected handleToggle(event: Event) {
this.unfollow?.();
this.unfollow = undefined;
const isOpen = (event as ToggleEvent).newState === "open";
this.open.set(isOpen);
if (!isOpen) return;
this.place();
this.unfollow = followViewport(() => this.place());
}
}Pemakaian
<x-markas.tooltip content="Salin tautan ke papan klip">
<x-markas.button variant="secondary">Salin tautan</x-markas.button>
</x-markas.tooltip>Butuh Alpine.js.
import { Button } from "@/components/markas/Button";
import { Tooltip } from "@/components/markas/Tooltip";
<Tooltip content="Salin tautan ke papan klip">
<Button variant="secondary">Salin tautan</Button>
</Tooltip>;<template>
<Tooltip content="Salin tautan ke papan klip">
<Button variant="secondary">Salin tautan</Button>
</Tooltip>
</template><script lang="ts">
import Button from "$lib/components/markas/Button.svelte";
import Tooltip from "$lib/components/markas/Tooltip.svelte";
</script>
<Tooltip content="Salin tautan ke papan klip">
<Button variant="secondary">Salin tautan</Button>
</Tooltip>---
import Button from "@/components/markas/Button.astro";
import Tooltip from "@/components/markas/Tooltip.astro";
---
<Tooltip content="Salin tautan ke papan klip">
<Button variant="secondary">Salin tautan</Button>
</Tooltip>Setiap tooltip dibungkus custom element markas-tooltip dengan display: contents, jadi tetap jalan untuk markup yang ditambahkan belakangan dan setelah view transition.
import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { Tooltip } from "./markas/tooltip.component";
@Component({
selector: "app-share",
imports: [Button, Tooltip],
template: `
<markas-tooltip content="Salin tautan ke papan klip">
<button markas-button variant="secondary">Salin tautan</button>
</markas-tooltip>
`,
})
export class Bagikan {}- Elemen pertama di dalam Tooltip otomatis diberi
aria-describedbyke tooltip. - Pakai
side="bottom"untuk menampilkan tooltip di bawah pemicu. - Tooltip tidak punya teks bawaan. Tulis
contentlangsung dalam Bahasa Indonesia.
Props
| Nama | Tipe | Default | Keterangan |
|---|---|---|---|
content | string | - | Teks tooltip. |
side | top | bottom | top | Sisi tooltip terhadap pemicu. Pindah ke sisi lain kalau tidak muat di layar. |
children / slot | slot / ReactNode / snippet | - | Satu elemen pemicu yang bisa difokus, misalnya tombol. |
id | string | auto | Id elemen tooltip, dipakai untuk aria-describedby pemicu. |
Aksesibilitas
- Memakai role=tooltip dan pemicu otomatis diberi aria-describedby ke tooltip.
- Muncul saat pemicu difokus dengan keyboard dan saat di-hover (jeda 300ms).
- Escape, blur, atau mouse keluar menyembunyikan tooltip.
Komponen terkait
Komponen overlay lain dengan class yang sama di setiap framework.
- Alert DialogKonfirmasi modal berbasis elemen dialog native. Wajib memilih batal atau aksi, tidak tertutup saat backdrop diklik.
- Command PaletteDaftar perintah yang bisa dicari di dalam dialog modal, tersaring saat mengetik, dengan navigasi panah dan pintasan Ctrl+K atau Cmd+K opsional.
- Context MenuMenu yang terbuka saat area diklik kanan atau Shift+F10 ditekan, tampil di posisi kursor lewat Popover API dengan keyboard sesuai WAI-ARIA Menu.
- DrawerPanel samping setinggi layar berbasis elemen dialog native, muncul dari kanan atau kiri.
- Dropdown MenuMenu aksi berbasis Popover API dengan navigasi keyboard sesuai pola WAI-ARIA Menu Button.
- Hover CardKartu pratinjau berbasis Popover API yang muncul saat link di-hover atau difokus, untuk profil, repositori, dan pratinjau lain.