Tooltip
A short description shown on hover and focus.
Example
<focsd-tooltip text="Copies a link anyone in the workspace can open"> <focsd-icon-button icon="copy" label="Copy link"></focsd-icon-button></focsd-tooltip>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-tooltip.js';</script>
<focsd-tooltip text="Copies a link anyone in the workspace can open">…</focsd-tooltip>import { Tooltip } from '@focsd-dev/react';
export function Example() { return <Tooltip text="Copies a link anyone in the workspace can open">…</Tooltip>;}<script setup>import '@focsd-dev/components/focsd-tooltip.js';</script>
<template> <focsd-tooltip text="Copies a link anyone in the workspace can open">…</focsd-tooltip></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-tooltip.js';
// template<focsd-tooltip text="Copies a link anyone in the workspace can open">…</focsd-tooltip><script> import '@focsd-dev/components/focsd-tooltip.js';</script>
<focsd-tooltip text="Copies a link anyone in the workspace can open">…</focsd-tooltip>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
text | text | string | — |
placement | placement | 'top' | 'bottom' | top |
delay | delay | number | 400 |
Methods
| Method | Description |
|---|---|
show() | Show the tooltip now, skipping delay. |
hide() | Hide the tooltip. |
Slots
| Slot | Description |
|---|---|
(default) | The element the tooltip describes. |
CSS parts
Style the inside of the component with ::part(), for example focsd-tooltip::part(tooltip).
| Part | Description |
|---|---|
tooltip | The tooltip element. |
Accessibility
- The trigger gets the text as
aria-description, so it is read with the control; the visual tooltip isaria-hiddento avoid double reading. - Stays open while hovered and dismisses on Escape (WCAG 1.4.13).
- Never put essential information or interactive content in a tooltip.
Keyboard
| Key | Action |
|---|---|
| Tab (to the trigger) | Show |
| Escape | Hide |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.