Toggletip
An info button that opens a short note on click, tap or Enter. The note can hold links.
Example
Storage used
Retention
<p> Storage used <focsd-toggletip >Includes files in the trash. <a href="#billing">See billing</a></focsd-toggletip ></p><p> Retention <focsd-toggletip label="About retention" placement="bottom" >Deleted items are kept for 30 days.</focsd-toggletip ></p>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-toggletip.js';</script>
<focsd-toggletip>…</focsd-toggletip>import { Toggletip } from '@focsd-dev/react';
export function Example() { return <Toggletip onClose={(e) => console.log(e.target)}>…</Toggletip>;}<script setup>import '@focsd-dev/components/focsd-toggletip.js';</script>
<template> <focsd-toggletip @close="onChange">…</focsd-toggletip></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-toggletip.js';
// template<focsd-toggletip (close)="onChange($event)">…</focsd-toggletip><script> import '@focsd-dev/components/focsd-toggletip.js';</script>
<focsd-toggletip onclose={(e) => console.log(e.target)}>…</focsd-toggletip>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
label | label | string | — |
placement | placement | 'top' | 'bottom' | 'left' | 'right' | top |
Events
| Event | Description |
|---|---|
close | Fired when the toggletip closes. |
Slots
| Slot | Description |
|---|---|
(default) | The information shown in the popover. |
CSS parts
Style the inside of the component with ::part(), for example focsd-toggletip::part(button).
| Part | Description |
|---|---|
button | The info button. |
panel | The popover holding the content. |
status | The visually hidden status region that announces the content. |
Accessibility
- Unlike
focsd-tooltip, a toggletip opens on click, so it works on touch screens, and its note may hold links: they follow the button in Tab order. - The button is named "More information" unless you set
label; name it after what it explains when a page has several. It reportsaria-expandedand is at least 24 by 24 pixels. - Opening it leaves focus on the button and copies the note’s text into a polite status region, so a screen reader reads it without moving there.
- Escape, clicking the button again or clicking anywhere else closes it. If focus was on a link inside, it returns to the button.
- The element fires
focsd-openwhen the note opens andclosewhen it closes.
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Open or close the note |
| Tab | Move to a link inside the open note |
| Escape | Close the note; focus stays on the button |
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.