Free pack

Tooltip <mv-tooltip>

Tooltip na camada superior (Popover API), posicionamento automático com inversão, seta, atraso agrupado.

Como funciona

Tooltip na top layer (Popover API), posicionamento automático com flip, seta, atraso agrupado. Para uma barra de ferramentas, Tooltip Group compartilha uma única superfície que desliza de um botão para o outro.

CategoriaSobreposições
TipoWeb Component (<mv-tooltip>)
Statusestável
Keywordstooltip, hint, popover, morphic-tooltip

When to use

  • An icon-only button needs its label shown on hover and keyboard focus
  • A short supplementary hint clarifies a control without cluttering the layout

Avoid when

  • The content is interactive or must be reachable on touch devices → use Popover instead
  • Many adjacent toolbar buttons should share one gliding tooltip surface → use Tooltip Group instead
  • The preview is rich, such as a profile card with an avatar and details → use Hover Card instead

Instalação

node scripts/add.mjs tooltip --out ./src/marvelous

Agente de IA com o servidor MCP do Marvelous UI: install_components({ slugs: ["tooltip"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).

Arquivos copiados (dependências incluídas): tokens/tokens.css, core/base.css, core/dom.js, core/element.js, core/i18n.js, core/position.js, components/tooltip/tooltip.js, components/tooltip/tooltip.css.

Uso

Marcação de referência, para usar como ponto de partida e personalizar com atributos, data-* e variáveis CSS:

<div style="display:flex;gap:.75rem;flex-wrap:wrap;justify-content:center">
  <mv-tooltip text="Above" placement="top"><button class="mv-button" data-variant="outline">Top</button></mv-tooltip>
  <mv-tooltip text="Below" placement="bottom"><button class="mv-button" data-variant="outline">Bottom</button></mv-tooltip>
  <mv-tooltip text="To the left" placement="left"><button class="mv-button" data-variant="outline">Left</button></mv-tooltip>
  <mv-tooltip text="To the right" placement="right"><button class="mv-button" data-variant="outline">Right</button></mv-tooltip>
  <mv-tooltip placement="top" delay="0">
    <button class="mv-button" data-variant="secondary">Rich</button>
    <div data-content><strong>⌘ K</strong>: open the palette</div>
  </mv-tooltip>
</div>

API

Attributes

NameTipoPadrãoDescrição
textstringPlain text (otherwise a [data-content] child).
placementtop | bottom | left | right[-start|-end]topPreferred side, flipped when there’s no room.
delaynumber500Show delay (ms). Skipped if another tooltip just closed.
offsetnumber8Distance from the trigger (px).
openbooleanOpens/closes programmatically.
disabledbooleanDisables the tooltip.

Events

NameDescrição
mv-openAfter opening.
mv-closeAfter closing.

Content structure

NameDescrição
first childTrigger (button, link, focusable icon).
[data-content]Optional rich content.

CSS variables

NameDescrição
--mv-tooltip-bgBackground.
--mv-tooltip-fgText.

Accessibility

role=tooltip + aria-describedby on the trigger; opens on keyboard focus, closes on Escape. Doesn’t open on touch (use a Popover).

Esta página foi traduzida com IA. Informar um problema de tradução