A gradient tooltip that swings down from a hinge under the button, like a flap folding forward in 3D. A perspective() inside the transform keeps the depth local to the tooltip.
Also known as: flip tooltip css, 3d tooltip animation, rotatex tooltip.
<span class="tip-flip-3d"> <button type="button" aria-describedby="tip-flip-3d-tip">Export</button> <span class="tip-flip-3d-tip" id="tip-flip-3d-tip" role="tooltip">Download as CSV or PDF</span> </span>
.tip-flip-3d {
--c: var(--tip-color, #3b82f6);
font-size: var(--tip-size, 16px);
position: relative;
display: inline-flex;
}
.tip-flip-3d button {
display: inline-flex;
align-items: center;
gap: 0.4em;
padding: 0.6em 1.2em;
border: 0;
border-radius: 0.5em;
background: var(--c);
color: #fff;
font: 600 1em system-ui, sans-serif;
cursor: pointer;
}
.tip-flip-3d button:focus-visible {
outline: 2px solid var(--c);
outline-offset: 2px;
}
.tip-flip-3d-tip {
position: absolute;
top: calc(100% + 0.75em);
left: 50%;
z-index: 10;
padding: 0.5em 0.85em;
border-radius: 0.5em;
background: linear-gradient(180deg, var(--c), color-mix(in srgb, var(--c) 60%, #7c3aed));
box-shadow: 0 0.5em 1em -0.4em color-mix(in srgb, var(--c) 80%, transparent);
color: #fff;
font: 600 0.85em/1.3 system-ui, sans-serif;
white-space: nowrap;
opacity: 0;
visibility: hidden;
pointer-events: none;
/* hinged on its top edge, folded back into the page */
transform-origin: 50% 0;
transform: translateX(-50%) perspective(18em) rotateX(-85deg);
transition: opacity 0.2s ease, transform 0.55s cubic-bezier(0.3, 1.45, 0.5, 1), visibility 0.55s;
}
/* the arrow sits where the gradient starts, so a flat accent matches it */
.tip-flip-3d-tip::before {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
width: 0.6em;
height: 0.6em;
background: var(--c);
transform: translate(-50%, 50%) rotate(45deg);
}
.tip-flip-3d:hover .tip-flip-3d-tip,
.tip-flip-3d:focus-within .tip-flip-3d-tip {
opacity: 1;
visibility: visible;
transform: translateX(-50%) perspective(18em) rotateX(0deg);
}
@media (prefers-reduced-motion: reduce) {
.tip-flip-3d, .tip-flip-3d *, .tip-flip-3d::before, .tip-flip-3d::after, .tip-flip-3d *::before, .tip-flip-3d *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--tip-color on the element or a parent.
Currently previewing #3b82f6.--tip-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.