Pure TailwindMIT licensed

Origami Fold Tailwind Close Button

Each bar of the × is a strip of creased paper: perspective-[400px] on the button, transform-3d on the rig, and on hover each pseudo-element tips back along its own length with group-hover:before:rotate-x-[58deg], its two-tone gradient becoming the lit and shaded faces of the fold. Keyboard focus now folds it too.

Live Demo
Plain CSSTailwind v4
Try it

Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time

Untitled UI React · Affiliate link

Get Untitled UI Pro

The code

<section class="tcb-11 w-full min-h-svh grid place-items-center bg-[linear-gradient(170deg,var(--color-tcb11-bg),var(--color-tcb11-bg2))] px-6 py-12 font-tcb11-sans" aria-label="Origami fold close button demo">
  <div class="grid w-full justify-items-center gap-7">
    <button type="button" aria-label="Close" class="group relative size-18 cursor-pointer rounded-[1.25rem] bg-tcb11-card shadow-[0_16px_34px_-18px_var(--color-tcb11-shadow),inset_0_0_0_1px_var(--color-tcb11-edge)] perspective-[400px] focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb11-acc active:scale-95">
      <span aria-hidden="true" class="absolute inset-0 transform-3d before:absolute before:top-1/2 before:left-1/2 before:h-[9px] before:w-8 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-[linear-gradient(180deg,var(--color-tcb11-pa)_50%,var(--color-tcb11-pb)_50%)] before:shadow-[0_6px_10px_-4px_var(--color-tcb11-shadow)] before:transition before:duration-380 before:ease-[cubic-bezier(.34,1.3,.5,1)] after:absolute after:top-1/2 after:left-1/2 after:h-[9px] after:w-8 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-[linear-gradient(180deg,var(--color-tcb11-pa)_50%,var(--color-tcb11-pb)_50%)] after:shadow-[0_6px_10px_-4px_var(--color-tcb11-shadow)] after:transition after:duration-380 after:ease-[cubic-bezier(.34,1.3,.5,1)] group-hover:before:rotate-x-[58deg] group-hover:before:bg-[linear-gradient(180deg,var(--color-tcb11-pa)_50%,var(--color-tcb11-pc)_50%)] group-hover:after:rotate-x-[58deg] group-hover:after:bg-[linear-gradient(180deg,var(--color-tcb11-pa)_50%,var(--color-tcb11-pc)_50%)] group-focus-visible:before:rotate-x-[58deg] group-focus-visible:after:rotate-x-[58deg] motion-reduce:before:transition-none motion-reduce:after:transition-none motion-reduce:group-hover:before:rotate-x-0 motion-reduce:group-hover:after:rotate-x-0"></span>
    </button>
    <p aria-hidden="true" class="rounded-full bg-white/60 px-3.5 py-2 font-tcb11-mono text-[11.5px] text-tcb11-mut ring-1 ring-black/8">perspective-[400px] · transform-3d · group-hover:before:rotate-x-[58deg]</p>
  </div>
</section>
@import "tailwindcss";

@theme {
  --color-tcb11-bg: #f2ebdc;
  --color-tcb11-bg: oklch(0.93 0.025 80);
  --color-tcb11-bg2: #e3d5bb;
  --color-tcb11-bg2: oklch(0.87 0.04 70);
  --color-tcb11-card: #fdfbf6;
  --color-tcb11-card: oklch(0.99 0.008 85);
  --color-tcb11-edge: #eadfca;
  --color-tcb11-edge: oklch(0.9 0.03 80);
  --color-tcb11-pa: #fbf5e6;
  --color-tcb11-pa: oklch(0.97 0.02 85);
  --color-tcb11-pb: #c4ae8b;
  --color-tcb11-pb: oklch(0.78 0.05 75);
  --color-tcb11-pc: #a38c6b;
  --color-tcb11-pc: oklch(0.68 0.06 70);
  --color-tcb11-acc: #a0732c;
  --color-tcb11-acc: oklch(0.58 0.12 70);
  --color-tcb11-mut: #6b5a3e;
  --color-tcb11-mut: oklch(0.47 0.05 70);
  --color-tcb11-shadow: #7e653f8c;
  --color-tcb11-shadow: oklch(0.5 0.08 70 / 0.55);
  --font-tcb11-sans: 'Geist', system-ui, sans-serif;
  --font-tcb11-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-11 {
  width: 100%;
  min-height: 100svh;
}

Setup — do this once per project

Skip this if your project already runs Tailwind v4.

1Load Tailwind
<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.

2Add the stylesheetRequiredthe @theme block is what makes the custom utilities exist
@import "tailwindcss";

@theme {
  --color-tcb11-bg: #f2ebdc;
  --color-tcb11-bg: oklch(0.93 0.025 80);
  --color-tcb11-bg2: #e3d5bb;
  --color-tcb11-bg2: oklch(0.87 0.04 70);
  --color-tcb11-card: #fdfbf6;
  --color-tcb11-card: oklch(0.99 0.008 85);
  --color-tcb11-edge: #eadfca;
  --color-tcb11-edge: oklch(0.9 0.03 80);
  --color-tcb11-pa: #fbf5e6;
  --color-tcb11-pa: oklch(0.97 0.02 85);
  --color-tcb11-pb: #c4ae8b;
  --color-tcb11-pb: oklch(0.78 0.05 75);
  --color-tcb11-pc: #a38c6b;
  --color-tcb11-pc: oklch(0.68 0.06 70);
  --color-tcb11-acc: #a0732c;
  --color-tcb11-acc: oklch(0.58 0.12 70);
  --color-tcb11-mut: #6b5a3e;
  --color-tcb11-mut: oklch(0.47 0.05 70);
  --color-tcb11-shadow: #7e653f8c;
  --color-tcb11-shadow: oklch(0.5 0.08 70 / 0.55);
  --font-tcb11-sans: 'Geist', system-ui, sans-serif;
  --font-tcb11-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-11 {
  width: 100%;
  min-height: 100svh;
}
3Fonts used by this demooptional — skip if you have your own type stack
<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 --fold variable and six hover rules became group-hover:before:rotate-x-[58deg] and its after: twin; the base rotate(45deg) never has to be restated.
  • UI upgrade from the CSS original: keyboard focus now plays the same fold (group-focus-visible:), so the effect is not mouse-only.
  • UI upgrade: under motion-reduce: the fold is removed entirely rather than just snapped, and the focus ring colour deepened to 4.6:1 on the parchment stage.
Paste this into ChatGPT, Claude, Cursor, or any coding assistant. The block below is pre-framed with everything the AI needs to integrate this demo into your project — markup, styles, scoping notes, and the source URL. Hit Copy and paste straight into your chat.
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: Origami Fold Tailwind Close Button
Source: https://codefronts.com/components/tailwind-css-close-buttons/origami-crease/

Each bar of the × is a strip of creased paper: perspective-[400px] on the button, transform-3d on the rig, and on hover each pseudo-element tips back along its own length with group-hover:before:rotate-x-[58deg], its two-tone gradient becoming the lit and shaded faces of the fold. Keyboard focus now folds it too.
## HTML
```html
<section class="tcb-11 w-full min-h-svh grid place-items-center bg-[linear-gradient(170deg,var(--color-tcb11-bg),var(--color-tcb11-bg2))] px-6 py-12 font-tcb11-sans" aria-label="Origami fold close button demo">
  <div class="grid w-full justify-items-center gap-7">
    <button type="button" aria-label="Close" class="group relative size-18 cursor-pointer rounded-[1.25rem] bg-tcb11-card shadow-[0_16px_34px_-18px_var(--color-tcb11-shadow),inset_0_0_0_1px_var(--color-tcb11-edge)] perspective-[400px] focus-visible:outline-3 focus-visible:outline-offset-3 focus-visible:outline-tcb11-acc active:scale-95">
      <span aria-hidden="true" class="absolute inset-0 transform-3d before:absolute before:top-1/2 before:left-1/2 before:h-[9px] before:w-8 before:-translate-1/2 before:rotate-45 before:rounded-[2px] before:bg-[linear-gradient(180deg,var(--color-tcb11-pa)_50%,var(--color-tcb11-pb)_50%)] before:shadow-[0_6px_10px_-4px_var(--color-tcb11-shadow)] before:transition before:duration-380 before:ease-[cubic-bezier(.34,1.3,.5,1)] after:absolute after:top-1/2 after:left-1/2 after:h-[9px] after:w-8 after:-translate-1/2 after:-rotate-45 after:rounded-[2px] after:bg-[linear-gradient(180deg,var(--color-tcb11-pa)_50%,var(--color-tcb11-pb)_50%)] after:shadow-[0_6px_10px_-4px_var(--color-tcb11-shadow)] after:transition after:duration-380 after:ease-[cubic-bezier(.34,1.3,.5,1)] group-hover:before:rotate-x-[58deg] group-hover:before:bg-[linear-gradient(180deg,var(--color-tcb11-pa)_50%,var(--color-tcb11-pc)_50%)] group-hover:after:rotate-x-[58deg] group-hover:after:bg-[linear-gradient(180deg,var(--color-tcb11-pa)_50%,var(--color-tcb11-pc)_50%)] group-focus-visible:before:rotate-x-[58deg] group-focus-visible:after:rotate-x-[58deg] motion-reduce:before:transition-none motion-reduce:after:transition-none motion-reduce:group-hover:before:rotate-x-0 motion-reduce:group-hover:after:rotate-x-0"></span>
    </button>
    <p aria-hidden="true" class="rounded-full bg-white/60 px-3.5 py-2 font-tcb11-mono text-[11.5px] text-tcb11-mut ring-1 ring-black/8">perspective-[400px] · transform-3d · group-hover:before:rotate-x-[58deg]</p>
  </div>
</section>
```
## CSS
```css
@import "tailwindcss";

@theme {
  --color-tcb11-bg: #f2ebdc;
  --color-tcb11-bg: oklch(0.93 0.025 80);
  --color-tcb11-bg2: #e3d5bb;
  --color-tcb11-bg2: oklch(0.87 0.04 70);
  --color-tcb11-card: #fdfbf6;
  --color-tcb11-card: oklch(0.99 0.008 85);
  --color-tcb11-edge: #eadfca;
  --color-tcb11-edge: oklch(0.9 0.03 80);
  --color-tcb11-pa: #fbf5e6;
  --color-tcb11-pa: oklch(0.97 0.02 85);
  --color-tcb11-pb: #c4ae8b;
  --color-tcb11-pb: oklch(0.78 0.05 75);
  --color-tcb11-pc: #a38c6b;
  --color-tcb11-pc: oklch(0.68 0.06 70);
  --color-tcb11-acc: #a0732c;
  --color-tcb11-acc: oklch(0.58 0.12 70);
  --color-tcb11-mut: #6b5a3e;
  --color-tcb11-mut: oklch(0.47 0.05 70);
  --color-tcb11-shadow: #7e653f8c;
  --color-tcb11-shadow: oklch(0.5 0.08 70 / 0.55);
  --font-tcb11-sans: 'Geist', system-ui, sans-serif;
  --font-tcb11-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-11 {
  width: 100%;
  min-height: 100svh;
}
```

How this works

Two rotations on two properties. Tailwind puts rotate-45 on the CSS rotate property and rotate-x-[58deg] on transform. The browser applies rotate first in the chain, so the 45° turn happens in the parent's space and the X-tilt happens along the bar — exactly the original's rotate(45deg) rotateX(58deg):

before:rotate-45 group-hover:before:rotate-x-[58deg]
after:-rotate-45 group-hover:after:rotate-x-[58deg]

Make it yours

  • Deeper fold: rotate-x-[72deg] — past ~80° the bars vanish edge-on.
  • Paper tone: edit --color-tcb11-pa / pb.
  • Slower crease: duration-500 on the pseudo-elements.

Gotchas — read before shipping

  • perspective must be on an ancestor of the rotating element, and transform-3d on every layer between them, or the fold flattens.
  • Gradients do not interpolate — the crease tone swaps instantly while the fold eases; that is intentional here.

Browser support

ChromeSafariFirefoxEdge
111+16.4+128+111+

3D transforms are universal; the floor is Tailwind v4.

Techniques used in this demo

Utilitiesfirst-class utility or variant

Search CodeFronts

Loading…