23 / 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
3D Fold Away Tailwind Close Button
The × splits along its horizon and both halves hinge away from the viewer like a split-flap display: two copies of one glyph, cropped with [clip-path:inset(0_0_50%_0)] and its mirror, tip with group-hover:rotate-x-[78deg] and -rotate-x-[78deg] while brightness-72 darkens them into shadow. A 40ms stagger makes the fold feel physical.
Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time
Untitled UI React · Affiliate link
The code
<section class="tcb-23 w-full min-h-svh grid place-items-center bg-[linear-gradient(180deg,var(--color-tcb23-bg),var(--color-tcb23-bg2))] px-6 py-12 font-tcb23-sans" aria-label="3D fold away close button demo">
<div class="grid w-full justify-items-center gap-7">
<button type="button" aria-label="Close" class="group relative size-19 cursor-pointer rounded-[18px] border-[1.5px] border-tcb23-line bg-white shadow-[0_18px_40px_-24px_var(--color-tcb23-shadow)] transition-shadow duration-300 perspective-[500px] hover:shadow-[0_10px_22px_-16px_var(--color-tcb23-shadow)] focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb23-acc active:scale-95">
<span aria-hidden="true" class="absolute inset-0 grid place-items-center transition duration-450 ease-[cubic-bezier(.4,0,.2,1)] [clip-path:inset(0_0_50%_0)] group-hover:rotate-x-[78deg] group-hover:brightness-72 group-focus-visible:rotate-x-[78deg] group-focus-visible:brightness-72 motion-reduce:transition-none motion-reduce:transform-none! motion-reduce:filter-none!">
<i class="relative block size-6.5 before:absolute before:top-1/2 before:left-1/2 before:h-[3px] before:w-6.5 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-tcb23-ink after:absolute after:top-1/2 after:left-1/2 after:h-[3px] after:w-6.5 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-tcb23-ink"></i>
</span>
<span aria-hidden="true" class="absolute inset-0 grid place-items-center transition delay-40 duration-450 ease-[cubic-bezier(.4,0,.2,1)] [clip-path:inset(50%_0_0_0)] group-hover:-rotate-x-[78deg] group-hover:brightness-82 group-focus-visible:-rotate-x-[78deg] group-focus-visible:brightness-82 motion-reduce:transition-none motion-reduce:transform-none! motion-reduce:filter-none!">
<i class="relative block size-6.5 before:absolute before:top-1/2 before:left-1/2 before:h-[3px] before:w-6.5 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-tcb23-ink after:absolute after:top-1/2 after:left-1/2 after:h-[3px] after:w-6.5 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-tcb23-ink"></i>
</span>
</button>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-tcb23-mono text-[11.5px] text-tcb23-mut ring-1 ring-black/8">[clip-path:inset(0_0_50%_0)] · group-hover:rotate-x-[78deg]</p>
</div>
</section><section class="tcb-23 w-full min-h-svh grid place-items-center bg-[linear-gradient(180deg,var(--color-tcb23-bg),var(--color-tcb23-bg2))] px-6 py-12 font-tcb23-sans" aria-label="3D fold away close button demo">
<div class="grid w-full justify-items-center gap-7">
<button type="button" aria-label="Close" class="group relative size-19 cursor-pointer rounded-[18px] border-[1.5px] border-tcb23-line bg-white shadow-[0_18px_40px_-24px_var(--color-tcb23-shadow)] transition-shadow duration-300 perspective-[500px] hover:shadow-[0_10px_22px_-16px_var(--color-tcb23-shadow)] focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb23-acc active:scale-95">
<span aria-hidden="true" class="absolute inset-0 grid place-items-center transition duration-450 ease-[cubic-bezier(.4,0,.2,1)] [clip-path:inset(0_0_50%_0)] group-hover:rotate-x-[78deg] group-hover:brightness-72 group-focus-visible:rotate-x-[78deg] group-focus-visible:brightness-72 motion-reduce:transition-none motion-reduce:transform-none! motion-reduce:filter-none!">
<i class="relative block size-6.5 before:absolute before:top-1/2 before:left-1/2 before:h-[3px] before:w-6.5 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-tcb23-ink after:absolute after:top-1/2 after:left-1/2 after:h-[3px] after:w-6.5 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-tcb23-ink"></i>
</span>
<span aria-hidden="true" class="absolute inset-0 grid place-items-center transition delay-40 duration-450 ease-[cubic-bezier(.4,0,.2,1)] [clip-path:inset(50%_0_0_0)] group-hover:-rotate-x-[78deg] group-hover:brightness-82 group-focus-visible:-rotate-x-[78deg] group-focus-visible:brightness-82 motion-reduce:transition-none motion-reduce:transform-none! motion-reduce:filter-none!">
<i class="relative block size-6.5 before:absolute before:top-1/2 before:left-1/2 before:h-[3px] before:w-6.5 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-tcb23-ink after:absolute after:top-1/2 after:left-1/2 after:h-[3px] after:w-6.5 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-tcb23-ink"></i>
</span>
</button>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-tcb23-mono text-[11.5px] text-tcb23-mut ring-1 ring-black/8">[clip-path:inset(0_0_50%_0)] · group-hover:rotate-x-[78deg]</p>
</div>
</section>@import "tailwindcss";
@theme {
--color-tcb23-bg: #eef2f8;
--color-tcb23-bg: oklch(0.95 0.012 240);
--color-tcb23-bg2: #dde3ee;
--color-tcb23-bg2: oklch(0.9 0.02 245);
--color-tcb23-ink: #2d3748;
--color-tcb23-ink: oklch(0.3 0.03 250);
--color-tcb23-mut: #4f5a6d;
--color-tcb23-mut: oklch(0.45 0.035 250);
--color-tcb23-line: #d2d9e4;
--color-tcb23-line: oklch(0.87 0.02 245);
--color-tcb23-acc: #3d6ad1;
--color-tcb23-acc: oklch(0.55 0.15 262);
--color-tcb23-shadow: #3f4d6799;
--color-tcb23-shadow: oklch(0.4 0.06 245 / 0.6);
--font-tcb23-sans: 'Geist', system-ui, sans-serif;
--font-tcb23-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-23 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-tcb23-bg: #eef2f8;
--color-tcb23-bg: oklch(0.95 0.012 240);
--color-tcb23-bg2: #dde3ee;
--color-tcb23-bg2: oklch(0.9 0.02 245);
--color-tcb23-ink: #2d3748;
--color-tcb23-ink: oklch(0.3 0.03 250);
--color-tcb23-mut: #4f5a6d;
--color-tcb23-mut: oklch(0.45 0.035 250);
--color-tcb23-line: #d2d9e4;
--color-tcb23-line: oklch(0.87 0.02 245);
--color-tcb23-acc: #3d6ad1;
--color-tcb23-acc: oklch(0.55 0.15 262);
--color-tcb23-shadow: #3f4d6799;
--color-tcb23-shadow: oklch(0.4 0.06 245 / 0.6);
--font-tcb23-sans: 'Geist', system-ui, sans-serif;
--font-tcb23-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-23 {
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-tcb23-bg: #eef2f8;
--color-tcb23-bg: oklch(0.95 0.012 240);
--color-tcb23-bg2: #dde3ee;
--color-tcb23-bg2: oklch(0.9 0.02 245);
--color-tcb23-ink: #2d3748;
--color-tcb23-ink: oklch(0.3 0.03 250);
--color-tcb23-mut: #4f5a6d;
--color-tcb23-mut: oklch(0.45 0.035 250);
--color-tcb23-line: #d2d9e4;
--color-tcb23-line: oklch(0.87 0.02 245);
--color-tcb23-acc: #3d6ad1;
--color-tcb23-acc: oklch(0.55 0.15 262);
--color-tcb23-shadow: #3f4d6799;
--color-tcb23-shadow: oklch(0.4 0.06 245 / 0.6);
--font-tcb23-sans: 'Geist', system-ui, sans-serif;
--font-tcb23-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-23 {
width: 100%;
min-height: 100svh;
}@import "tailwindcss";
@theme {
--color-tcb23-bg: #eef2f8;
--color-tcb23-bg: oklch(0.95 0.012 240);
--color-tcb23-bg2: #dde3ee;
--color-tcb23-bg2: oklch(0.9 0.02 245);
--color-tcb23-ink: #2d3748;
--color-tcb23-ink: oklch(0.3 0.03 250);
--color-tcb23-mut: #4f5a6d;
--color-tcb23-mut: oklch(0.45 0.035 250);
--color-tcb23-line: #d2d9e4;
--color-tcb23-line: oklch(0.87 0.02 245);
--color-tcb23-acc: #3d6ad1;
--color-tcb23-acc: oklch(0.55 0.15 262);
--color-tcb23-shadow: #3f4d6799;
--color-tcb23-shadow: oklch(0.4 0.06 245 / 0.6);
--font-tcb23-sans: 'Geist', system-ui, sans-serif;
--font-tcb23-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-23 {
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.
rotateX(calc(var(--fold) * -1))became the negative utility-rotate-x-[78deg];filter: brightness(.72)becamebrightness-72.- UI upgrade from the CSS original: keyboard focus folds the glyph too, and reduced motion now forces both
transformandfilteroff with!so hover cannot re-apply them. - UI upgrade: the hairline border darkened (
0.85 → 0.87on a whiter card) and the caption uses a 7:1 ink.
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: 3D Fold Away Tailwind Close Button
Source: https://codefronts.com/components/tailwind-css-close-buttons/fold-away/
The × splits along its horizon and both halves hinge away from the viewer like a split-flap display: two copies of one glyph, cropped with [clip-path:inset(0_0_50%_0)] and its mirror, tip with group-hover:rotate-x-[78deg] and -rotate-x-[78deg] while brightness-72 darkens them into shadow. A 40ms stagger makes the fold feel physical.
## HTML
```html
<section class="tcb-23 w-full min-h-svh grid place-items-center bg-[linear-gradient(180deg,var(--color-tcb23-bg),var(--color-tcb23-bg2))] px-6 py-12 font-tcb23-sans" aria-label="3D fold away close button demo">
<div class="grid w-full justify-items-center gap-7">
<button type="button" aria-label="Close" class="group relative size-19 cursor-pointer rounded-[18px] border-[1.5px] border-tcb23-line bg-white shadow-[0_18px_40px_-24px_var(--color-tcb23-shadow)] transition-shadow duration-300 perspective-[500px] hover:shadow-[0_10px_22px_-16px_var(--color-tcb23-shadow)] focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb23-acc active:scale-95">
<span aria-hidden="true" class="absolute inset-0 grid place-items-center transition duration-450 ease-[cubic-bezier(.4,0,.2,1)] [clip-path:inset(0_0_50%_0)] group-hover:rotate-x-[78deg] group-hover:brightness-72 group-focus-visible:rotate-x-[78deg] group-focus-visible:brightness-72 motion-reduce:transition-none motion-reduce:transform-none! motion-reduce:filter-none!">
<i class="relative block size-6.5 before:absolute before:top-1/2 before:left-1/2 before:h-[3px] before:w-6.5 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-tcb23-ink after:absolute after:top-1/2 after:left-1/2 after:h-[3px] after:w-6.5 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-tcb23-ink"></i>
</span>
<span aria-hidden="true" class="absolute inset-0 grid place-items-center transition delay-40 duration-450 ease-[cubic-bezier(.4,0,.2,1)] [clip-path:inset(50%_0_0_0)] group-hover:-rotate-x-[78deg] group-hover:brightness-82 group-focus-visible:-rotate-x-[78deg] group-focus-visible:brightness-82 motion-reduce:transition-none motion-reduce:transform-none! motion-reduce:filter-none!">
<i class="relative block size-6.5 before:absolute before:top-1/2 before:left-1/2 before:h-[3px] before:w-6.5 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-tcb23-ink after:absolute after:top-1/2 after:left-1/2 after:h-[3px] after:w-6.5 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-tcb23-ink"></i>
</span>
</button>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-tcb23-mono text-[11.5px] text-tcb23-mut ring-1 ring-black/8">[clip-path:inset(0_0_50%_0)] · group-hover:rotate-x-[78deg]</p>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tcb23-bg: #eef2f8;
--color-tcb23-bg: oklch(0.95 0.012 240);
--color-tcb23-bg2: #dde3ee;
--color-tcb23-bg2: oklch(0.9 0.02 245);
--color-tcb23-ink: #2d3748;
--color-tcb23-ink: oklch(0.3 0.03 250);
--color-tcb23-mut: #4f5a6d;
--color-tcb23-mut: oklch(0.45 0.035 250);
--color-tcb23-line: #d2d9e4;
--color-tcb23-line: oklch(0.87 0.02 245);
--color-tcb23-acc: #3d6ad1;
--color-tcb23-acc: oklch(0.55 0.15 262);
--color-tcb23-shadow: #3f4d6799;
--color-tcb23-shadow: oklch(0.4 0.06 245 / 0.6);
--font-tcb23-sans: 'Geist', system-ui, sans-serif;
--font-tcb23-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-23 {
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: 3D Fold Away Tailwind Close Button
Source: https://codefronts.com/components/tailwind-css-close-buttons/fold-away/
The × splits along its horizon and both halves hinge away from the viewer like a split-flap display: two copies of one glyph, cropped with [clip-path:inset(0_0_50%_0)] and its mirror, tip with group-hover:rotate-x-[78deg] and -rotate-x-[78deg] while brightness-72 darkens them into shadow. A 40ms stagger makes the fold feel physical.
## HTML
```html
<section class="tcb-23 w-full min-h-svh grid place-items-center bg-[linear-gradient(180deg,var(--color-tcb23-bg),var(--color-tcb23-bg2))] px-6 py-12 font-tcb23-sans" aria-label="3D fold away close button demo">
<div class="grid w-full justify-items-center gap-7">
<button type="button" aria-label="Close" class="group relative size-19 cursor-pointer rounded-[18px] border-[1.5px] border-tcb23-line bg-white shadow-[0_18px_40px_-24px_var(--color-tcb23-shadow)] transition-shadow duration-300 perspective-[500px] hover:shadow-[0_10px_22px_-16px_var(--color-tcb23-shadow)] focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb23-acc active:scale-95">
<span aria-hidden="true" class="absolute inset-0 grid place-items-center transition duration-450 ease-[cubic-bezier(.4,0,.2,1)] [clip-path:inset(0_0_50%_0)] group-hover:rotate-x-[78deg] group-hover:brightness-72 group-focus-visible:rotate-x-[78deg] group-focus-visible:brightness-72 motion-reduce:transition-none motion-reduce:transform-none! motion-reduce:filter-none!">
<i class="relative block size-6.5 before:absolute before:top-1/2 before:left-1/2 before:h-[3px] before:w-6.5 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-tcb23-ink after:absolute after:top-1/2 after:left-1/2 after:h-[3px] after:w-6.5 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-tcb23-ink"></i>
</span>
<span aria-hidden="true" class="absolute inset-0 grid place-items-center transition delay-40 duration-450 ease-[cubic-bezier(.4,0,.2,1)] [clip-path:inset(50%_0_0_0)] group-hover:-rotate-x-[78deg] group-hover:brightness-82 group-focus-visible:-rotate-x-[78deg] group-focus-visible:brightness-82 motion-reduce:transition-none motion-reduce:transform-none! motion-reduce:filter-none!">
<i class="relative block size-6.5 before:absolute before:top-1/2 before:left-1/2 before:h-[3px] before:w-6.5 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-tcb23-ink after:absolute after:top-1/2 after:left-1/2 after:h-[3px] after:w-6.5 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-tcb23-ink"></i>
</span>
</button>
<p aria-hidden="true" class="rounded-full bg-white/70 px-3.5 py-2 font-tcb23-mono text-[11.5px] text-tcb23-mut ring-1 ring-black/8">[clip-path:inset(0_0_50%_0)] · group-hover:rotate-x-[78deg]</p>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tcb23-bg: #eef2f8;
--color-tcb23-bg: oklch(0.95 0.012 240);
--color-tcb23-bg2: #dde3ee;
--color-tcb23-bg2: oklch(0.9 0.02 245);
--color-tcb23-ink: #2d3748;
--color-tcb23-ink: oklch(0.3 0.03 250);
--color-tcb23-mut: #4f5a6d;
--color-tcb23-mut: oklch(0.45 0.035 250);
--color-tcb23-line: #d2d9e4;
--color-tcb23-line: oklch(0.87 0.02 245);
--color-tcb23-acc: #3d6ad1;
--color-tcb23-acc: oklch(0.55 0.15 262);
--color-tcb23-shadow: #3f4d6799;
--color-tcb23-shadow: oklch(0.4 0.06 245 / 0.6);
--font-tcb23-sans: 'Geist', system-ui, sans-serif;
--font-tcb23-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-23 {
width: 100%;
min-height: 100svh;
}
```How this works
Split with clip-path, not markup. Both halves render the full glyph; each shows only its own half. Rotating them around their shared centre line makes the seam the hinge:
top: [clip-path:inset(0_0_50%_0)] group-hover:rotate-x-[78deg] group-hover:brightness-72
bot: [clip-path:inset(50%_0_0_0)] delay-40 group-hover:-rotate-x-[78deg] group-hover:brightness-82Make it yours
- Full vanish:
rotate-x-90— the halves go edge-on and disappear. - Horizontal hinge: swap to
inset(0_50%_0_0)androtate-y-*. - Softer fold:
duration-700.
Gotchas — read before shipping
perspective-*sets perspective for children; put it on the button, not the halves.- Filter + transform on the same element promotes it to its own layer — fine for two small halves, costly on large panels.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 16.4+ | 128+ | 111+ |
The floor is Tailwind v4's generated sheet.