Skip to content

Pure CSS Tooltip

A copy-paste css-only interactions component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

CSS-Only InteractionsHTMLCSSany framework

Copy into your project

HTML
<!-- Pure CSS Tooltip — shows on hover/focus, zero JS -->
<span class="nuda-css-tooltip">
  <button class="nuda-css-tooltip__trigger" type="button"
          aria-describedby="nuda-css-tt-1">Hover me</button>
  <span class="nuda-css-tooltip__bubble" role="tooltip" id="nuda-css-tt-1">
    Pure CSS tooltip on hover or focus.
  </span>
</span>
CSS
/* Pure CSS Tooltip
   Reveals on :hover and :focus-visible (keyboard accessible).
   No JS. Customize: --nuda-css-tt-accent */

.nuda-css-tooltip {
  --nuda-css-tt-accent: #e4ff54;
  position: relative;
  display: inline-flex;
}

.nuda-css-tooltip__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: help;
}

.nuda-css-tooltip__trigger:focus-visible {
  outline: 2px solid var(--nuda-css-tt-accent);
  outline-offset: 2px;
}

.nuda-css-tooltip__bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: 220px;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  line-height: 1.3;
  color: #09090b;
  background: var(--nuda-css-tt-accent);
  border-radius: 7px;
  opacity: 0;
  transform: translateX(-50%) translateY(4px) scale(0.96);
  transform-origin: bottom center;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}

.nuda-css-tooltip__bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--nuda-css-tt-accent);
}

.nuda-css-tooltip__trigger:hover + .nuda-css-tooltip__bubble,
.nuda-css-tooltip__trigger:focus-visible + .nuda-css-tooltip__bubble {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .nuda-css-tooltip__bubble { transition: none; }
}

How to use Pure CSS Tooltip

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More css-only interactions components

← Browse all NudaUI components