13 / 28
All 28 in 28 Tailwind CSS Close Buttons
- 01Tailwind Modal Close Button (Top-Right Corner X)
- 02Accessible Tailwind Close Button with Focus Ring (WCAG)
- 03iOS-Style Tailwind Tab Close Button
- 04Tailwind Floating Chat Widget Close Button
- 05Tailwind Cookie Consent Banner Dismiss Button
- 06Tailwind Mobile Ad Banner Close Button (48px Tap Target)
- 07Neumorphic Tailwind Close Button (Soft UI)
- 08Tailwind Hamburger to X Menu Button Animation
- 09Tailwind Video Player Overlay Close Button
- 10Tailwind Drawer Close Button with Native Dialog
- 11Origami Fold Tailwind Close Button
- 12Lock Tumbler Tailwind Close Button (@property)
- 13Rotate on Hover Tailwind Close Button
- 14Magnetic Cursor Tailwind Close Button
- 15Liquid Goo Tailwind Close Button (SVG Filter)
- 16Glitch Effect Tailwind Close Button
- 17Trash Compactor Tailwind Close Button
- 18Material Ripple Tailwind Close Button
- 19Particle Burst Tailwind Close Button
- 20Spring Snap Tailwind Close Button
- 21Neon Glow Tailwind Close Button
- 22Corner Ribbon Tailwind Close Button
- 233D Fold Away Tailwind Close Button
- 24Hold to Confirm Tailwind Close Button
- 25Tailwind Toast Notification Dismiss Button
- 26Tailwind Lightbox Image Close Button
- 27Brutalist Tailwind Close Button
- 28Galaxy Vortex Tailwind Close Button
Rotate on Hover Tailwind Close Button
The most-searched close-button animation, done cleanly: a 180° group-hover:rotate-180 on the glyph with an ease-out-expo curve, the ring and bars shifting to the accent. grid place-items-center kills the sub-pixel wobble that plagues spinning icons, and v4's hover: is already gated behind @media (hover:hover) — the original's hand-written media query simply disappears.
Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time
Untitled UI React · Affiliate link
The code
<section class="tcb-13 w-full min-h-svh grid place-items-center bg-[linear-gradient(180deg,var(--color-tcb13-bg),var(--color-tcb13-bg2))] px-6 py-12 font-tcb13-sans" aria-label="Rotate on hover close button demo">
<div class="grid w-full justify-items-center gap-7">
<button type="button" aria-label="Close" class="group grid size-15 cursor-pointer place-items-center rounded-full border-2 border-tcb13-ink/30 bg-white shadow-[0_12px_28px_-16px_var(--color-tcb13-shadow)] transition duration-250 hover:border-tcb13-acc focus-visible:border-tcb13-acc focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb13-acc active:scale-92 motion-reduce:transition-none">
<span aria-hidden="true" class="relative size-5.5 transition-transform duration-450 ease-[cubic-bezier(.22,1,.36,1)] before:absolute before:top-1/2 before:left-1/2 before:h-[2.5px] before:w-5.5 before:-translate-1/2 before:rotate-45 before:rounded-full before:bg-tcb13-ink before:transition-colors before:duration-250 after:absolute after:top-1/2 after:left-1/2 after:h-[2.5px] after:w-5.5 after:-translate-1/2 after:-rotate-45 after:rounded-full after:bg-tcb13-ink after:transition-colors after:duration-250 group-hover:rotate-180 group-hover:before:bg-tcb13-acc group-hover:after:bg-tcb13-acc group-focus-visible:rotate-180 motion-reduce:transition-none"></span>
</button>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-tcb13-mono text-[11.5px] text-tcb13-mut ring-1 ring-black/8">group-hover:rotate-180 · ease-[cubic-bezier(.22,1,.36,1)]</p>
</div>
</section><section class="tcb-13 w-full min-h-svh grid place-items-center bg-[linear-gradient(180deg,var(--color-tcb13-bg),var(--color-tcb13-bg2))] px-6 py-12 font-tcb13-sans" aria-label="Rotate on hover close button demo">
<div class="grid w-full justify-items-center gap-7">
<button type="button" aria-label="Close" class="group grid size-15 cursor-pointer place-items-center rounded-full border-2 border-tcb13-ink/30 bg-white shadow-[0_12px_28px_-16px_var(--color-tcb13-shadow)] transition duration-250 hover:border-tcb13-acc focus-visible:border-tcb13-acc focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb13-acc active:scale-92 motion-reduce:transition-none">
<span aria-hidden="true" class="relative size-5.5 transition-transform duration-450 ease-[cubic-bezier(.22,1,.36,1)] before:absolute before:top-1/2 before:left-1/2 before:h-[2.5px] before:w-5.5 before:-translate-1/2 before:rotate-45 before:rounded-full before:bg-tcb13-ink before:transition-colors before:duration-250 after:absolute after:top-1/2 after:left-1/2 after:h-[2.5px] after:w-5.5 after:-translate-1/2 after:-rotate-45 after:rounded-full after:bg-tcb13-ink after:transition-colors after:duration-250 group-hover:rotate-180 group-hover:before:bg-tcb13-acc group-hover:after:bg-tcb13-acc group-focus-visible:rotate-180 motion-reduce:transition-none"></span>
</button>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-tcb13-mono text-[11.5px] text-tcb13-mut ring-1 ring-black/8">group-hover:rotate-180 · ease-[cubic-bezier(.22,1,.36,1)]</p>
</div>
</section>@import "tailwindcss";
@theme {
--color-tcb13-bg: #f5f6fa;
--color-tcb13-bg: oklch(0.97 0.006 265);
--color-tcb13-bg2: #e8e9f2;
--color-tcb13-bg2: oklch(0.93 0.014 265);
--color-tcb13-ink: #3a3e52;
--color-tcb13-ink: oklch(0.35 0.03 265);
--color-tcb13-mut: #555a70;
--color-tcb13-mut: oklch(0.46 0.03 265);
--color-tcb13-acc: #4150d8;
--color-tcb13-acc: oklch(0.52 0.19 268);
--color-tcb13-shadow: #4a4f7080;
--color-tcb13-shadow: oklch(0.4 0.06 265 / 0.5);
--font-tcb13-sans: 'Geist', system-ui, sans-serif;
--font-tcb13-mono: 'Geist Mono', ui-monospace, monospace;
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-13 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-tcb13-bg: #f5f6fa;
--color-tcb13-bg: oklch(0.97 0.006 265);
--color-tcb13-bg2: #e8e9f2;
--color-tcb13-bg2: oklch(0.93 0.014 265);
--color-tcb13-ink: #3a3e52;
--color-tcb13-ink: oklch(0.35 0.03 265);
--color-tcb13-mut: #555a70;
--color-tcb13-mut: oklch(0.46 0.03 265);
--color-tcb13-acc: #4150d8;
--color-tcb13-acc: oklch(0.52 0.19 268);
--color-tcb13-shadow: #4a4f7080;
--color-tcb13-shadow: oklch(0.4 0.06 265 / 0.5);
--font-tcb13-sans: 'Geist', system-ui, sans-serif;
--font-tcb13-mono: 'Geist Mono', ui-monospace, monospace;
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-13 {
width: 100%;
min-height: 100svh;
}Setup — do this once per project
Skip this if your project already runs Tailwind v4.
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>Compiles in the browser — perfect for a CodePen or a quick test, not for production.
npm install tailwindcss @tailwindcss/vite
npm install tailwindcss @tailwindcss/vite// vite.config.js ("type": "module" in package.json)
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [tailwindcss()],
})// vite.config.js ("type": "module" in package.json)
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [tailwindcss()],
})Any v4 setup works — Vite, PostCSS or the CLI. Nothing in this demo is bundler-specific.
@import "tailwindcss";
@theme {
--color-tcb13-bg: #f5f6fa;
--color-tcb13-bg: oklch(0.97 0.006 265);
--color-tcb13-bg2: #e8e9f2;
--color-tcb13-bg2: oklch(0.93 0.014 265);
--color-tcb13-ink: #3a3e52;
--color-tcb13-ink: oklch(0.35 0.03 265);
--color-tcb13-mut: #555a70;
--color-tcb13-mut: oklch(0.46 0.03 265);
--color-tcb13-acc: #4150d8;
--color-tcb13-acc: oklch(0.52 0.19 268);
--color-tcb13-shadow: #4a4f7080;
--color-tcb13-shadow: oklch(0.4 0.06 265 / 0.5);
--font-tcb13-sans: 'Geist', system-ui, sans-serif;
--font-tcb13-mono: 'Geist Mono', ui-monospace, monospace;
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-13 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-tcb13-bg: #f5f6fa;
--color-tcb13-bg: oklch(0.97 0.006 265);
--color-tcb13-bg2: #e8e9f2;
--color-tcb13-bg2: oklch(0.93 0.014 265);
--color-tcb13-ink: #3a3e52;
--color-tcb13-ink: oklch(0.35 0.03 265);
--color-tcb13-mut: #555a70;
--color-tcb13-mut: oklch(0.46 0.03 265);
--color-tcb13-acc: #4150d8;
--color-tcb13-acc: oklch(0.52 0.19 268);
--color-tcb13-shadow: #4a4f7080;
--color-tcb13-shadow: oklch(0.4 0.06 265 / 0.5);
--font-tcb13-sans: 'Geist', system-ui, sans-serif;
--font-tcb13-mono: 'Geist Mono', ui-monospace, monospace;
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-13 {
width: 100%;
min-height: 100svh;
}<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400..800&family=Geist+Mono:wght@400..600&display=swap">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geist:wght@400..800&family=Geist+Mono:wght@400..600&display=swap">What changed in the port
Which parts became utilities, which stayed CSS, and why.
- The original's
@media (hover:hover){…}block vanished: v4 compiles everyhover:utility inside that query already. color-mix(in oklab, var(--ink) 30%, transparent)becameborder-tcb13-ink/30.- UI upgrade from the CSS original: keyboard focus spins the glyph and colours the ring too, and the accent darkened slightly (
0.55 → 0.52) so the focused border clears 5:1 on white.
Here's a working CSS demo from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Rotate on Hover Tailwind Close Button
Source: https://codefronts.com/components/tailwind-css-close-buttons/rotate-out/
The most-searched close-button animation, done cleanly: a 180° group-hover:rotate-180 on the glyph with an ease-out-expo curve, the ring and bars shifting to the accent. grid place-items-center kills the sub-pixel wobble that plagues spinning icons, and v4's hover: is already gated behind @media (hover:hover) — the original's hand-written media query simply disappears.
## HTML
```html
<section class="tcb-13 w-full min-h-svh grid place-items-center bg-[linear-gradient(180deg,var(--color-tcb13-bg),var(--color-tcb13-bg2))] px-6 py-12 font-tcb13-sans" aria-label="Rotate on hover close button demo">
<div class="grid w-full justify-items-center gap-7">
<button type="button" aria-label="Close" class="group grid size-15 cursor-pointer place-items-center rounded-full border-2 border-tcb13-ink/30 bg-white shadow-[0_12px_28px_-16px_var(--color-tcb13-shadow)] transition duration-250 hover:border-tcb13-acc focus-visible:border-tcb13-acc focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb13-acc active:scale-92 motion-reduce:transition-none">
<span aria-hidden="true" class="relative size-5.5 transition-transform duration-450 ease-[cubic-bezier(.22,1,.36,1)] before:absolute before:top-1/2 before:left-1/2 before:h-[2.5px] before:w-5.5 before:-translate-1/2 before:rotate-45 before:rounded-full before:bg-tcb13-ink before:transition-colors before:duration-250 after:absolute after:top-1/2 after:left-1/2 after:h-[2.5px] after:w-5.5 after:-translate-1/2 after:-rotate-45 after:rounded-full after:bg-tcb13-ink after:transition-colors after:duration-250 group-hover:rotate-180 group-hover:before:bg-tcb13-acc group-hover:after:bg-tcb13-acc group-focus-visible:rotate-180 motion-reduce:transition-none"></span>
</button>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-tcb13-mono text-[11.5px] text-tcb13-mut ring-1 ring-black/8">group-hover:rotate-180 · ease-[cubic-bezier(.22,1,.36,1)]</p>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tcb13-bg: #f5f6fa;
--color-tcb13-bg: oklch(0.97 0.006 265);
--color-tcb13-bg2: #e8e9f2;
--color-tcb13-bg2: oklch(0.93 0.014 265);
--color-tcb13-ink: #3a3e52;
--color-tcb13-ink: oklch(0.35 0.03 265);
--color-tcb13-mut: #555a70;
--color-tcb13-mut: oklch(0.46 0.03 265);
--color-tcb13-acc: #4150d8;
--color-tcb13-acc: oklch(0.52 0.19 268);
--color-tcb13-shadow: #4a4f7080;
--color-tcb13-shadow: oklch(0.4 0.06 265 / 0.5);
--font-tcb13-sans: 'Geist', system-ui, sans-serif;
--font-tcb13-mono: 'Geist Mono', ui-monospace, monospace;
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-13 {
width: 100%;
min-height: 100svh;
}
```Here's a working CSS demo from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Rotate on Hover Tailwind Close Button
Source: https://codefronts.com/components/tailwind-css-close-buttons/rotate-out/
The most-searched close-button animation, done cleanly: a 180° group-hover:rotate-180 on the glyph with an ease-out-expo curve, the ring and bars shifting to the accent. grid place-items-center kills the sub-pixel wobble that plagues spinning icons, and v4's hover: is already gated behind @media (hover:hover) — the original's hand-written media query simply disappears.
## HTML
```html
<section class="tcb-13 w-full min-h-svh grid place-items-center bg-[linear-gradient(180deg,var(--color-tcb13-bg),var(--color-tcb13-bg2))] px-6 py-12 font-tcb13-sans" aria-label="Rotate on hover close button demo">
<div class="grid w-full justify-items-center gap-7">
<button type="button" aria-label="Close" class="group grid size-15 cursor-pointer place-items-center rounded-full border-2 border-tcb13-ink/30 bg-white shadow-[0_12px_28px_-16px_var(--color-tcb13-shadow)] transition duration-250 hover:border-tcb13-acc focus-visible:border-tcb13-acc focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb13-acc active:scale-92 motion-reduce:transition-none">
<span aria-hidden="true" class="relative size-5.5 transition-transform duration-450 ease-[cubic-bezier(.22,1,.36,1)] before:absolute before:top-1/2 before:left-1/2 before:h-[2.5px] before:w-5.5 before:-translate-1/2 before:rotate-45 before:rounded-full before:bg-tcb13-ink before:transition-colors before:duration-250 after:absolute after:top-1/2 after:left-1/2 after:h-[2.5px] after:w-5.5 after:-translate-1/2 after:-rotate-45 after:rounded-full after:bg-tcb13-ink after:transition-colors after:duration-250 group-hover:rotate-180 group-hover:before:bg-tcb13-acc group-hover:after:bg-tcb13-acc group-focus-visible:rotate-180 motion-reduce:transition-none"></span>
</button>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-tcb13-mono text-[11.5px] text-tcb13-mut ring-1 ring-black/8">group-hover:rotate-180 · ease-[cubic-bezier(.22,1,.36,1)]</p>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tcb13-bg: #f5f6fa;
--color-tcb13-bg: oklch(0.97 0.006 265);
--color-tcb13-bg2: #e8e9f2;
--color-tcb13-bg2: oklch(0.93 0.014 265);
--color-tcb13-ink: #3a3e52;
--color-tcb13-ink: oklch(0.35 0.03 265);
--color-tcb13-mut: #555a70;
--color-tcb13-mut: oklch(0.46 0.03 265);
--color-tcb13-acc: #4150d8;
--color-tcb13-acc: oklch(0.52 0.19 268);
--color-tcb13-shadow: #4a4f7080;
--color-tcb13-shadow: oklch(0.4 0.06 265 / 0.5);
--font-tcb13-sans: 'Geist', system-ui, sans-serif;
--font-tcb13-mono: 'Geist Mono', ui-monospace, monospace;
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's utilities, so the
stage is sized before the browser build compiles. */
.tcb-13 {
width: 100%;
min-height: 100svh;
}
```How this works
Rotate the wrapper, not the bars. The bars live on before:/after: with their own ±45°. Spinning the parent span 180° maps the × onto itself — it reads as a spin but ends exactly where it started, so there is no "wrong" resting angle if the pointer leaves mid-turn.
<span class="… transition-transform duration-450 ease-[cubic-bezier(.22,1,.36,1)]
group-hover:rotate-180 group-focus-visible:rotate-180">Make it yours
- Quarter turn:
rotate-90reads snappier on small buttons. - Spin + shrink: add
group-hover:scale-85. - Neutral hover: drop the accent classes to keep only the motion.
Gotchas — read before shipping
will-changeis not needed for a one-shot transform; the original's hover-gatedwill-changewas dropped.- Rotating an element with a non-integer centre causes shimmer — keep glyph spans at even pixel sizes.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 16.4+ | 128+ | 111+ |
The floor is Tailwind v4's generated sheet.