Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Tooltip

    Short helper text built on the Popover API, shown when the trigger is hovered or focused.

    Copy link to clipboard
    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 {}

    Examples

    On icon buttons

    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)
    Bold (Ctrl+B)Italic (Ctrl+I)Insert link (Ctrl+K)

    Top and bottom

    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
    Shown above the buttonShown below the button

    Help icon

    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.

    Installation

    npx markasui@latest add tooltip

    Usage

    <x-markas.tooltip content="Copy link to clipboard">
        <x-markas.button variant="secondary">Copy link</x-markas.button>
    </x-markas.tooltip>

    Needs Alpine.js.

    import { Button } from "@/components/markas/Button";
    import { Tooltip } from "@/components/markas/Tooltip";
    
    <Tooltip content="Copy link to clipboard">
      <Button variant="secondary">Copy link</Button>
    </Tooltip>;
    <template>
      <Tooltip content="Copy link to clipboard">
        <Button variant="secondary">Copy link</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="Copy link to clipboard">
      <Button variant="secondary">Copy link</Button>
    </Tooltip>
    ---
    import Button from "@/components/markas/Button.astro";
    import Tooltip from "@/components/markas/Tooltip.astro";
    ---
    
    <Tooltip content="Copy link to clipboard">
      <Button variant="secondary">Copy link</Button>
    </Tooltip>

    Each tooltip is wrapped in a markas-tooltip custom element with display: contents, so it also works for markup added later and after view transitions.

    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="Copy link to clipboard">
          <button markas-button variant="secondary">Copy link</button>
        </markas-tooltip>
      `,
    })
    export class Share {}
    • The first element inside Tooltip automatically gets aria-describedby pointing to the tooltip.
    • Use side="bottom" to show the tooltip below the trigger.
    • Tooltip has no built-in text. Write content in the language of your site.

    Props

    NameTypeDefaultDescription
    contentstring-Tooltip text.
    sidetop | bottomtopSide of the trigger to show the tooltip on. Flips to the other side when it does not fit on screen.
    children / slotslot / ReactNode / snippet-A single focusable trigger element, such as a button.
    idstringautoTooltip element id, used for the trigger aria-describedby.

    Accessibility

    • Uses role=tooltip, and the trigger automatically gets aria-describedby pointing to the tooltip.
    • Shows when the trigger receives keyboard focus and on hover (300ms delay).
    • Escape, blur, or moving the mouse away hides the tooltip.

    Related components

    More overlay components with the same classes in every framework.