28 / 51
All 51 in 51 Tailwind CSS Buttons
- 01Tailwind Submit Button (Form Primary)
- 02Tailwind Primary and Secondary Button Pair
- 03Tailwind Ghost / Outline Button
- 04Tailwind Icon-Only Button with Accessible Tooltip
- 05Tailwind Gradient CTA Button
- 06Tailwind Loading Spinner Button (State Transition)
- 07Tailwind Disabled Button State (Full State Reference)
- 08Tailwind Button Group Component (Segmented Radio-Like)
- 09Tailwind Add to Cart Button
- 10Tailwind Download Progress Button
- 11Tailwind Like Heart Button
- 12Tailwind Confirm Delete Button
- 13Tailwind Play Pause Button
- 14Tailwind Subscribe Confetti Button
- 15Tailwind Magnetic Mercury Ripple Button
- 16Tailwind Brutalist Glitch Button
- 17Tailwind Neon Plasma Burst Button
- 18Tailwind Clay Press Button
- 19Tailwind Editorial Ink Spread Button
- 20Tailwind Particle Shard Burst Button
- 21Tailwind Brushed Brass Plate Button
- 22Tailwind Washi Paper Crane Button
- 23Tailwind Frosted Ice Cube Button
- 24Tailwind Vintage Typewriter Key Button
- 25Tailwind Lacquered Walnut Wood Button
- 26Tailwind Pharma Gel Capsule Button
- 27Tailwind Aged Copper Coin Button
- 28Tailwind Origami Fortune Cookie Button
- 29Tailwind Holographic Foil Sticker Button
- 30Tailwind Brutalist Concrete Slab Button
- 31Tailwind Mercury Bead Morph Button
- 32Tailwind Soft Pill Modern SaaS Button
- 33Tailwind Masking Tape Label Button
- 34Tailwind Obsidian Glass Shard Button
- 35Tailwind Wine Velvet Ribbon Button
- 36Tailwind LED Segment Display Button
- 37Tailwind Cassette Mixtape Label Button
- 38Tailwind Chalkboard Menu Button
- 39Tailwind Vinyl Record Sleeve Ripple Button
- 40Tailwind Polaroid Snapshot Button
- 41Tailwind Airline Boarding Pass Button
- 42Tailwind Aged Brass Subway Token Button
- 43Tailwind Vintage Rx Pharmacy Label Button
- 44Tailwind Bakelite Radio Dial Toggle Button
- 45Tailwind Regal Postage Stamp Button
- 46Tailwind Victorian Cigar Band Foil Button
- 47Tailwind Vintage Calculator Key Button
- 48Tailwind Toolbox Latch Spotlight Button
- 49Tailwind Receipt Paper Total Count-Up Button
- 50Tailwind IBM Punch Card Magnetic Follow Button
- 51Tailwind Brass Periscope Lens Button
Tailwind Origami Fortune Cookie Button
Press the cookie and it cracks: two clipped halves rotate apart, a paper slip slides out, and a fortune is written into a real aria-live region — so the message is announced, not merely displayed. The animation is garnish on a working disclosure.
Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time
Untitled UI React · Affiliate link
The code
<div class="tb-28 w-full min-h-svh grid place-items-center font-tb28-sans p-[clamp(1.5rem,6vw,4rem)]">
<div class="tb-28__wrap group grid justify-items-center gap-3.5">
<p role="status" aria-live="polite" class="tb-28__slip m-0 max-w-88 h-0 overflow-hidden px-4.5 rounded-[0.2rem] font-tb28-serif text-[1.0625rem] italic leading-relaxed text-center text-tb28-slip-ink bg-tb28-slip shadow-[0_8px_18px_-12px_#000000b3] scale-[0.72] opacity-0 transition-[scale,opacity,height,padding] duration-500 ease-tb28-out group-[.is-open]:scale-100 group-[.is-open]:opacity-100 group-[.is-open]:h-auto group-[.is-open]:py-3.5 motion-reduce:transition-none"></p>
<button type="button" aria-expanded="false" class="tb-28__btn relative cursor-pointer border-0 bg-transparent pt-[4.9rem] min-w-52 text-[0.9375rem] font-bold text-tb28-ink [-webkit-tap-highlight-color:transparent] focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-tb28-cookie focus-visible:rounded-2xl">
<span aria-hidden="true" class="tb-28__half absolute inset-x-0 top-0 h-17 z-10 rounded-l-[2.2rem] origin-left [clip-path:polygon(0_0,52%_0,45%_50%,52%_100%,0_100%)] shadow-[inset_0_-2px_4px_#00000040,0_12px_22px_-12px_#000000b3] transition-[rotate,translate,filter] duration-[550ms] ease-tb28-out hover:brightness-105 group-hover:-rotate-2 group-[.is-open]:-rotate-9 group-[.is-open]:-translate-x-[1.1rem] group-[.is-open]:translate-y-[0.2rem] group-active:scale-[0.98] motion-reduce:transition-none"></span>
<span aria-hidden="true" class="tb-28__half absolute inset-x-0 top-0 h-17 z-10 rounded-r-[2.2rem] origin-right [clip-path:polygon(52%_0,100%_0,100%_100%,52%_100%,45%_50%)] shadow-[inset_0_-2px_4px_#00000040,0_12px_22px_-12px_#000000b3] transition-[rotate,translate,filter] duration-[550ms] ease-tb28-out group-hover:rotate-2 group-[.is-open]:rotate-9 group-[.is-open]:translate-x-[1.1rem] group-[.is-open]:translate-y-[0.2rem] group-active:scale-[0.98] motion-reduce:transition-none"></span>
<span class="relative z-30 block text-[0.9375rem] font-bold tracking-[0.01em] text-tb28-label transition-colors duration-300 group-[.is-open]:text-tb28-label-dim">Open your fortune</span>
</button>
</div>
</div><div class="tb-28 w-full min-h-svh grid place-items-center font-tb28-sans p-[clamp(1.5rem,6vw,4rem)]">
<div class="tb-28__wrap group grid justify-items-center gap-3.5">
<p role="status" aria-live="polite" class="tb-28__slip m-0 max-w-88 h-0 overflow-hidden px-4.5 rounded-[0.2rem] font-tb28-serif text-[1.0625rem] italic leading-relaxed text-center text-tb28-slip-ink bg-tb28-slip shadow-[0_8px_18px_-12px_#000000b3] scale-[0.72] opacity-0 transition-[scale,opacity,height,padding] duration-500 ease-tb28-out group-[.is-open]:scale-100 group-[.is-open]:opacity-100 group-[.is-open]:h-auto group-[.is-open]:py-3.5 motion-reduce:transition-none"></p>
<button type="button" aria-expanded="false" class="tb-28__btn relative cursor-pointer border-0 bg-transparent pt-[4.9rem] min-w-52 text-[0.9375rem] font-bold text-tb28-ink [-webkit-tap-highlight-color:transparent] focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-tb28-cookie focus-visible:rounded-2xl">
<span aria-hidden="true" class="tb-28__half absolute inset-x-0 top-0 h-17 z-10 rounded-l-[2.2rem] origin-left [clip-path:polygon(0_0,52%_0,45%_50%,52%_100%,0_100%)] shadow-[inset_0_-2px_4px_#00000040,0_12px_22px_-12px_#000000b3] transition-[rotate,translate,filter] duration-[550ms] ease-tb28-out hover:brightness-105 group-hover:-rotate-2 group-[.is-open]:-rotate-9 group-[.is-open]:-translate-x-[1.1rem] group-[.is-open]:translate-y-[0.2rem] group-active:scale-[0.98] motion-reduce:transition-none"></span>
<span aria-hidden="true" class="tb-28__half absolute inset-x-0 top-0 h-17 z-10 rounded-r-[2.2rem] origin-right [clip-path:polygon(52%_0,100%_0,100%_100%,52%_100%,45%_50%)] shadow-[inset_0_-2px_4px_#00000040,0_12px_22px_-12px_#000000b3] transition-[rotate,translate,filter] duration-[550ms] ease-tb28-out group-hover:rotate-2 group-[.is-open]:rotate-9 group-[.is-open]:translate-x-[1.1rem] group-[.is-open]:translate-y-[0.2rem] group-active:scale-[0.98] motion-reduce:transition-none"></span>
<span class="relative z-30 block text-[0.9375rem] font-bold tracking-[0.01em] text-tb28-label transition-colors duration-300 group-[.is-open]:text-tb28-label-dim">Open your fortune</span>
</button>
</div>
</div>@import "tailwindcss";
@theme {
--color-tb28-bg: #2a1a1c;
--color-tb28-bg: oklch(0.24 0.03 25);
--color-tb28-cookie: #e8b874;
--color-tb28-cookie: oklch(0.82 0.1 76);
--color-tb28-cookie-lo: #b8843f;
--color-tb28-cookie-lo: oklch(0.65 0.11 66);
--color-tb28-ink: #4a2a10;
--color-tb28-ink: oklch(0.32 0.07 62);
--color-tb28-label: #f2ddb9;
--color-tb28-label: oklch(0.91 0.04 82);
--color-tb28-label-dim: #d8c4a3;
--color-tb28-label-dim: oklch(0.82 0.04 82);
--color-tb28-slip: #fdfaf3;
--color-tb28-slip-ink: #3b2b22;
--color-tb28-slip-ink: oklch(0.3 0.03 50);
--font-tb28-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
--font-tb28-serif: "Cormorant Garamond", ui-serif, Georgia, serif;
--ease-tb28-out: cubic-bezier(0.16, 1, 0.3, 1);
}
.tb-28 {
width: 100%;
min-height: 100vh;
min-height: 100svh;
background: radial-gradient(34rem 22rem at 50% 46%, color-mix(in oklab, var(--color-tb28-cookie) 18%, transparent), transparent 72%), var(--color-tb28-bg);
}
/* BAKED SURFACE: one specular over a diagonal base, shared by both halves. */
.tb-28__half {
background: radial-gradient(120% 90% at 30% 20%, color-mix(in oklab, var(--color-tb28-cookie) 70%, white), transparent 60%), linear-gradient(160deg, var(--color-tb28-cookie), var(--color-tb28-cookie-lo));
}
@media (prefers-color-scheme: light) {
.tb-28:not([data-theme="dark"]) {
--color-tb28-bg: oklch(0.3 0.035 25);
}
}
.tb-28[data-theme="light"] {
--color-tb28-bg: oklch(0.3 0.035 25);
}
@media (forced-colors: active) {
.tb-28__half {
background: ButtonFace;
border: 1px solid ButtonText;
box-shadow: none;
}
.tb-28__btn span:last-child {
color: CanvasText;
}
.tb-28__slip {
background: Canvas;
color: CanvasText;
border: 1px solid CanvasText;
}
}@import "tailwindcss";
@theme {
--color-tb28-bg: #2a1a1c;
--color-tb28-bg: oklch(0.24 0.03 25);
--color-tb28-cookie: #e8b874;
--color-tb28-cookie: oklch(0.82 0.1 76);
--color-tb28-cookie-lo: #b8843f;
--color-tb28-cookie-lo: oklch(0.65 0.11 66);
--color-tb28-ink: #4a2a10;
--color-tb28-ink: oklch(0.32 0.07 62);
--color-tb28-label: #f2ddb9;
--color-tb28-label: oklch(0.91 0.04 82);
--color-tb28-label-dim: #d8c4a3;
--color-tb28-label-dim: oklch(0.82 0.04 82);
--color-tb28-slip: #fdfaf3;
--color-tb28-slip-ink: #3b2b22;
--color-tb28-slip-ink: oklch(0.3 0.03 50);
--font-tb28-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
--font-tb28-serif: "Cormorant Garamond", ui-serif, Georgia, serif;
--ease-tb28-out: cubic-bezier(0.16, 1, 0.3, 1);
}
.tb-28 {
width: 100%;
min-height: 100vh;
min-height: 100svh;
background: radial-gradient(34rem 22rem at 50% 46%, color-mix(in oklab, var(--color-tb28-cookie) 18%, transparent), transparent 72%), var(--color-tb28-bg);
}
/* BAKED SURFACE: one specular over a diagonal base, shared by both halves. */
.tb-28__half {
background: radial-gradient(120% 90% at 30% 20%, color-mix(in oklab, var(--color-tb28-cookie) 70%, white), transparent 60%), linear-gradient(160deg, var(--color-tb28-cookie), var(--color-tb28-cookie-lo));
}
@media (prefers-color-scheme: light) {
.tb-28:not([data-theme="dark"]) {
--color-tb28-bg: oklch(0.3 0.035 25);
}
}
.tb-28[data-theme="light"] {
--color-tb28-bg: oklch(0.3 0.035 25);
}
@media (forced-colors: active) {
.tb-28__half {
background: ButtonFace;
border: 1px solid ButtonText;
box-shadow: none;
}
.tb-28__btn span:last-child {
color: CanvasText;
}
.tb-28__slip {
background: Canvas;
color: CanvasText;
border: 1px solid CanvasText;
}
}(() => {
const wrap = document.querySelector('.tb-28__wrap');
const btn = wrap && wrap.querySelector('.tb-28__btn');
const slip = wrap && wrap.querySelector('.tb-28__slip');
if (!btn) return;
const fortunes = [
'The bug you fear is a typo you already fixed.',
'Ship the small thing today; the big thing will follow.',
'A stranger will use your CSS at 3am and be grateful.',
'Delete one thing before you add three.',
'Your next idea arrives while you are away from the keyboard.',
];
let open = false;
let last = -1;
const pick = () => {
let i = last;
while (i === last) i = Math.floor(Math.random() * fortunes.length);
last = i;
return fortunes[i];
};
btn.addEventListener('click', () => {
open = !open;
wrap.classList.toggle('is-open', open);
btn.setAttribute('aria-expanded', String(open));
slip.textContent = open ? pick() : '';
});
})();(() => {
const wrap = document.querySelector('.tb-28__wrap');
const btn = wrap && wrap.querySelector('.tb-28__btn');
const slip = wrap && wrap.querySelector('.tb-28__slip');
if (!btn) return;
const fortunes = [
'The bug you fear is a typo you already fixed.',
'Ship the small thing today; the big thing will follow.',
'A stranger will use your CSS at 3am and be grateful.',
'Delete one thing before you add three.',
'Your next idea arrives while you are away from the keyboard.',
];
let open = false;
let last = -1;
const pick = () => {
let i = last;
while (i === last) i = Math.floor(Math.random() * fortunes.length);
last = i;
return fortunes[i];
};
btn.addEventListener('click', () => {
open = !open;
wrap.classList.toggle('is-open', open);
btn.setAttribute('aria-expanded', String(open));
slip.textContent = open ? pick() : '';
});
})();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-tb28-bg: #2a1a1c;
--color-tb28-bg: oklch(0.24 0.03 25);
--color-tb28-cookie: #e8b874;
--color-tb28-cookie: oklch(0.82 0.1 76);
--color-tb28-cookie-lo: #b8843f;
--color-tb28-cookie-lo: oklch(0.65 0.11 66);
--color-tb28-ink: #4a2a10;
--color-tb28-ink: oklch(0.32 0.07 62);
--color-tb28-label: #f2ddb9;
--color-tb28-label: oklch(0.91 0.04 82);
--color-tb28-label-dim: #d8c4a3;
--color-tb28-label-dim: oklch(0.82 0.04 82);
--color-tb28-slip: #fdfaf3;
--color-tb28-slip-ink: #3b2b22;
--color-tb28-slip-ink: oklch(0.3 0.03 50);
--font-tb28-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
--font-tb28-serif: "Cormorant Garamond", ui-serif, Georgia, serif;
--ease-tb28-out: cubic-bezier(0.16, 1, 0.3, 1);
}
.tb-28 {
width: 100%;
min-height: 100vh;
min-height: 100svh;
background: radial-gradient(34rem 22rem at 50% 46%, color-mix(in oklab, var(--color-tb28-cookie) 18%, transparent), transparent 72%), var(--color-tb28-bg);
}
/* BAKED SURFACE: one specular over a diagonal base, shared by both halves. */
.tb-28__half {
background: radial-gradient(120% 90% at 30% 20%, color-mix(in oklab, var(--color-tb28-cookie) 70%, white), transparent 60%), linear-gradient(160deg, var(--color-tb28-cookie), var(--color-tb28-cookie-lo));
}
@media (prefers-color-scheme: light) {
.tb-28:not([data-theme="dark"]) {
--color-tb28-bg: oklch(0.3 0.035 25);
}
}
.tb-28[data-theme="light"] {
--color-tb28-bg: oklch(0.3 0.035 25);
}
@media (forced-colors: active) {
.tb-28__half {
background: ButtonFace;
border: 1px solid ButtonText;
box-shadow: none;
}
.tb-28__btn span:last-child {
color: CanvasText;
}
.tb-28__slip {
background: Canvas;
color: CanvasText;
border: 1px solid CanvasText;
}
}@import "tailwindcss";
@theme {
--color-tb28-bg: #2a1a1c;
--color-tb28-bg: oklch(0.24 0.03 25);
--color-tb28-cookie: #e8b874;
--color-tb28-cookie: oklch(0.82 0.1 76);
--color-tb28-cookie-lo: #b8843f;
--color-tb28-cookie-lo: oklch(0.65 0.11 66);
--color-tb28-ink: #4a2a10;
--color-tb28-ink: oklch(0.32 0.07 62);
--color-tb28-label: #f2ddb9;
--color-tb28-label: oklch(0.91 0.04 82);
--color-tb28-label-dim: #d8c4a3;
--color-tb28-label-dim: oklch(0.82 0.04 82);
--color-tb28-slip: #fdfaf3;
--color-tb28-slip-ink: #3b2b22;
--color-tb28-slip-ink: oklch(0.3 0.03 50);
--font-tb28-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
--font-tb28-serif: "Cormorant Garamond", ui-serif, Georgia, serif;
--ease-tb28-out: cubic-bezier(0.16, 1, 0.3, 1);
}
.tb-28 {
width: 100%;
min-height: 100vh;
min-height: 100svh;
background: radial-gradient(34rem 22rem at 50% 46%, color-mix(in oklab, var(--color-tb28-cookie) 18%, transparent), transparent 72%), var(--color-tb28-bg);
}
/* BAKED SURFACE: one specular over a diagonal base, shared by both halves. */
.tb-28__half {
background: radial-gradient(120% 90% at 30% 20%, color-mix(in oklab, var(--color-tb28-cookie) 70%, white), transparent 60%), linear-gradient(160deg, var(--color-tb28-cookie), var(--color-tb28-cookie-lo));
}
@media (prefers-color-scheme: light) {
.tb-28:not([data-theme="dark"]) {
--color-tb28-bg: oklch(0.3 0.035 25);
}
}
.tb-28[data-theme="light"] {
--color-tb28-bg: oklch(0.3 0.035 25);
}
@media (forced-colors: active) {
.tb-28__half {
background: ButtonFace;
border: 1px solid ButtonText;
box-shadow: none;
}
.tb-28__btn span:last-child {
color: CanvasText;
}
.tb-28__slip {
background: Canvas;
color: CanvasText;
border: 1px solid CanvasText;
}
}<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=Cormorant+Garamond:ital,wght@0,500;0,600;1,500&family=DM+Sans:wght@600;700&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=Cormorant+Garamond:ital,wght@0,500;0,600;1,500&family=DM+Sans:wght@600;700&display=swap">What changed in the port
Which parts became utilities, which stayed CSS, and why.
- Utilities: both fracture polygons, both hinges and rotations, the slip's reveal, the label's dimming, every state. CSS: the baked-surface gradient shared by the halves, and the stage.
- Putting the two complementary polygons in adjacent elements is the port's real gain here. The constraint — that the left half's midpoints must equal the right half's — is now visible in one screenful instead of inferred across two rules.
- The
groupsits on the wrapper rather than the button, because the slip is the button's sibling. That is the standard shape whenever a JS class has to drive two elements that aren't nested. - A11y fix from the CSS original: the open-state label used
color-mix(in oklab, label 72%, cookie-lo), landing near 3.3:1 on the dark stage. The port names it--color-tb28-label-dimat ≈7:1 — dimmer than the rest state, still comfortably readable, which is the point of a de-emphasised label rather than a disabled one.
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: Tailwind Origami Fortune Cookie Button
Source: https://codefronts.com/components/tailwind-css-buttons/tailwind-origami-fortune-cookie-button/
Press the cookie and it cracks: two clipped halves rotate apart, a paper slip slides out, and a fortune is written into a real aria-live region — so the message is announced, not merely displayed. The animation is garnish on a working disclosure.
## HTML
```html
<div class="tb-28 w-full min-h-svh grid place-items-center font-tb28-sans p-[clamp(1.5rem,6vw,4rem)]">
<div class="tb-28__wrap group grid justify-items-center gap-3.5">
<p role="status" aria-live="polite" class="tb-28__slip m-0 max-w-88 h-0 overflow-hidden px-4.5 rounded-[0.2rem] font-tb28-serif text-[1.0625rem] italic leading-relaxed text-center text-tb28-slip-ink bg-tb28-slip shadow-[0_8px_18px_-12px_#000000b3] scale-[0.72] opacity-0 transition-[scale,opacity,height,padding] duration-500 ease-tb28-out group-[.is-open]:scale-100 group-[.is-open]:opacity-100 group-[.is-open]:h-auto group-[.is-open]:py-3.5 motion-reduce:transition-none"></p>
<button type="button" aria-expanded="false" class="tb-28__btn relative cursor-pointer border-0 bg-transparent pt-[4.9rem] min-w-52 text-[0.9375rem] font-bold text-tb28-ink [-webkit-tap-highlight-color:transparent] focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-tb28-cookie focus-visible:rounded-2xl">
<span aria-hidden="true" class="tb-28__half absolute inset-x-0 top-0 h-17 z-10 rounded-l-[2.2rem] origin-left [clip-path:polygon(0_0,52%_0,45%_50%,52%_100%,0_100%)] shadow-[inset_0_-2px_4px_#00000040,0_12px_22px_-12px_#000000b3] transition-[rotate,translate,filter] duration-[550ms] ease-tb28-out hover:brightness-105 group-hover:-rotate-2 group-[.is-open]:-rotate-9 group-[.is-open]:-translate-x-[1.1rem] group-[.is-open]:translate-y-[0.2rem] group-active:scale-[0.98] motion-reduce:transition-none"></span>
<span aria-hidden="true" class="tb-28__half absolute inset-x-0 top-0 h-17 z-10 rounded-r-[2.2rem] origin-right [clip-path:polygon(52%_0,100%_0,100%_100%,52%_100%,45%_50%)] shadow-[inset_0_-2px_4px_#00000040,0_12px_22px_-12px_#000000b3] transition-[rotate,translate,filter] duration-[550ms] ease-tb28-out group-hover:rotate-2 group-[.is-open]:rotate-9 group-[.is-open]:translate-x-[1.1rem] group-[.is-open]:translate-y-[0.2rem] group-active:scale-[0.98] motion-reduce:transition-none"></span>
<span class="relative z-30 block text-[0.9375rem] font-bold tracking-[0.01em] text-tb28-label transition-colors duration-300 group-[.is-open]:text-tb28-label-dim">Open your fortune</span>
</button>
</div>
</div>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tb28-bg: #2a1a1c;
--color-tb28-bg: oklch(0.24 0.03 25);
--color-tb28-cookie: #e8b874;
--color-tb28-cookie: oklch(0.82 0.1 76);
--color-tb28-cookie-lo: #b8843f;
--color-tb28-cookie-lo: oklch(0.65 0.11 66);
--color-tb28-ink: #4a2a10;
--color-tb28-ink: oklch(0.32 0.07 62);
--color-tb28-label: #f2ddb9;
--color-tb28-label: oklch(0.91 0.04 82);
--color-tb28-label-dim: #d8c4a3;
--color-tb28-label-dim: oklch(0.82 0.04 82);
--color-tb28-slip: #fdfaf3;
--color-tb28-slip-ink: #3b2b22;
--color-tb28-slip-ink: oklch(0.3 0.03 50);
--font-tb28-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
--font-tb28-serif: "Cormorant Garamond", ui-serif, Georgia, serif;
--ease-tb28-out: cubic-bezier(0.16, 1, 0.3, 1);
}
.tb-28 {
width: 100%;
min-height: 100vh;
min-height: 100svh;
background: radial-gradient(34rem 22rem at 50% 46%, color-mix(in oklab, var(--color-tb28-cookie) 18%, transparent), transparent 72%), var(--color-tb28-bg);
}
/* BAKED SURFACE: one specular over a diagonal base, shared by both halves. */
.tb-28__half {
background: radial-gradient(120% 90% at 30% 20%, color-mix(in oklab, var(--color-tb28-cookie) 70%, white), transparent 60%), linear-gradient(160deg, var(--color-tb28-cookie), var(--color-tb28-cookie-lo));
}
@media (prefers-color-scheme: light) {
.tb-28:not([data-theme="dark"]) {
--color-tb28-bg: oklch(0.3 0.035 25);
}
}
.tb-28[data-theme="light"] {
--color-tb28-bg: oklch(0.3 0.035 25);
}
@media (forced-colors: active) {
.tb-28__half {
background: ButtonFace;
border: 1px solid ButtonText;
box-shadow: none;
}
.tb-28__btn span:last-child {
color: CanvasText;
}
.tb-28__slip {
background: Canvas;
color: CanvasText;
border: 1px solid CanvasText;
}
}
```
## JavaScript
```js
(() => {
const wrap = document.querySelector('.tb-28__wrap');
const btn = wrap && wrap.querySelector('.tb-28__btn');
const slip = wrap && wrap.querySelector('.tb-28__slip');
if (!btn) return;
const fortunes = [
'The bug you fear is a typo you already fixed.',
'Ship the small thing today; the big thing will follow.',
'A stranger will use your CSS at 3am and be grateful.',
'Delete one thing before you add three.',
'Your next idea arrives while you are away from the keyboard.',
];
let open = false;
let last = -1;
const pick = () => {
let i = last;
while (i === last) i = Math.floor(Math.random() * fortunes.length);
last = i;
return fortunes[i];
};
btn.addEventListener('click', () => {
open = !open;
wrap.classList.toggle('is-open', open);
btn.setAttribute('aria-expanded', String(open));
slip.textContent = open ? pick() : '';
});
})();
```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: Tailwind Origami Fortune Cookie Button
Source: https://codefronts.com/components/tailwind-css-buttons/tailwind-origami-fortune-cookie-button/
Press the cookie and it cracks: two clipped halves rotate apart, a paper slip slides out, and a fortune is written into a real aria-live region — so the message is announced, not merely displayed. The animation is garnish on a working disclosure.
## HTML
```html
<div class="tb-28 w-full min-h-svh grid place-items-center font-tb28-sans p-[clamp(1.5rem,6vw,4rem)]">
<div class="tb-28__wrap group grid justify-items-center gap-3.5">
<p role="status" aria-live="polite" class="tb-28__slip m-0 max-w-88 h-0 overflow-hidden px-4.5 rounded-[0.2rem] font-tb28-serif text-[1.0625rem] italic leading-relaxed text-center text-tb28-slip-ink bg-tb28-slip shadow-[0_8px_18px_-12px_#000000b3] scale-[0.72] opacity-0 transition-[scale,opacity,height,padding] duration-500 ease-tb28-out group-[.is-open]:scale-100 group-[.is-open]:opacity-100 group-[.is-open]:h-auto group-[.is-open]:py-3.5 motion-reduce:transition-none"></p>
<button type="button" aria-expanded="false" class="tb-28__btn relative cursor-pointer border-0 bg-transparent pt-[4.9rem] min-w-52 text-[0.9375rem] font-bold text-tb28-ink [-webkit-tap-highlight-color:transparent] focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-tb28-cookie focus-visible:rounded-2xl">
<span aria-hidden="true" class="tb-28__half absolute inset-x-0 top-0 h-17 z-10 rounded-l-[2.2rem] origin-left [clip-path:polygon(0_0,52%_0,45%_50%,52%_100%,0_100%)] shadow-[inset_0_-2px_4px_#00000040,0_12px_22px_-12px_#000000b3] transition-[rotate,translate,filter] duration-[550ms] ease-tb28-out hover:brightness-105 group-hover:-rotate-2 group-[.is-open]:-rotate-9 group-[.is-open]:-translate-x-[1.1rem] group-[.is-open]:translate-y-[0.2rem] group-active:scale-[0.98] motion-reduce:transition-none"></span>
<span aria-hidden="true" class="tb-28__half absolute inset-x-0 top-0 h-17 z-10 rounded-r-[2.2rem] origin-right [clip-path:polygon(52%_0,100%_0,100%_100%,52%_100%,45%_50%)] shadow-[inset_0_-2px_4px_#00000040,0_12px_22px_-12px_#000000b3] transition-[rotate,translate,filter] duration-[550ms] ease-tb28-out group-hover:rotate-2 group-[.is-open]:rotate-9 group-[.is-open]:translate-x-[1.1rem] group-[.is-open]:translate-y-[0.2rem] group-active:scale-[0.98] motion-reduce:transition-none"></span>
<span class="relative z-30 block text-[0.9375rem] font-bold tracking-[0.01em] text-tb28-label transition-colors duration-300 group-[.is-open]:text-tb28-label-dim">Open your fortune</span>
</button>
</div>
</div>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tb28-bg: #2a1a1c;
--color-tb28-bg: oklch(0.24 0.03 25);
--color-tb28-cookie: #e8b874;
--color-tb28-cookie: oklch(0.82 0.1 76);
--color-tb28-cookie-lo: #b8843f;
--color-tb28-cookie-lo: oklch(0.65 0.11 66);
--color-tb28-ink: #4a2a10;
--color-tb28-ink: oklch(0.32 0.07 62);
--color-tb28-label: #f2ddb9;
--color-tb28-label: oklch(0.91 0.04 82);
--color-tb28-label-dim: #d8c4a3;
--color-tb28-label-dim: oklch(0.82 0.04 82);
--color-tb28-slip: #fdfaf3;
--color-tb28-slip-ink: #3b2b22;
--color-tb28-slip-ink: oklch(0.3 0.03 50);
--font-tb28-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
--font-tb28-serif: "Cormorant Garamond", ui-serif, Georgia, serif;
--ease-tb28-out: cubic-bezier(0.16, 1, 0.3, 1);
}
.tb-28 {
width: 100%;
min-height: 100vh;
min-height: 100svh;
background: radial-gradient(34rem 22rem at 50% 46%, color-mix(in oklab, var(--color-tb28-cookie) 18%, transparent), transparent 72%), var(--color-tb28-bg);
}
/* BAKED SURFACE: one specular over a diagonal base, shared by both halves. */
.tb-28__half {
background: radial-gradient(120% 90% at 30% 20%, color-mix(in oklab, var(--color-tb28-cookie) 70%, white), transparent 60%), linear-gradient(160deg, var(--color-tb28-cookie), var(--color-tb28-cookie-lo));
}
@media (prefers-color-scheme: light) {
.tb-28:not([data-theme="dark"]) {
--color-tb28-bg: oklch(0.3 0.035 25);
}
}
.tb-28[data-theme="light"] {
--color-tb28-bg: oklch(0.3 0.035 25);
}
@media (forced-colors: active) {
.tb-28__half {
background: ButtonFace;
border: 1px solid ButtonText;
box-shadow: none;
}
.tb-28__btn span:last-child {
color: CanvasText;
}
.tb-28__slip {
background: Canvas;
color: CanvasText;
border: 1px solid CanvasText;
}
}
```
## JavaScript
```js
(() => {
const wrap = document.querySelector('.tb-28__wrap');
const btn = wrap && wrap.querySelector('.tb-28__btn');
const slip = wrap && wrap.querySelector('.tb-28__slip');
if (!btn) return;
const fortunes = [
'The bug you fear is a typo you already fixed.',
'Ship the small thing today; the big thing will follow.',
'A stranger will use your CSS at 3am and be grateful.',
'Delete one thing before you add three.',
'Your next idea arrives while you are away from the keyboard.',
];
let open = false;
let last = -1;
const pick = () => {
let i = last;
while (i === last) i = Math.floor(Math.random() * fortunes.length);
last = i;
return fortunes[i];
};
btn.addEventListener('click', () => {
open = !open;
wrap.classList.toggle('is-open', open);
btn.setAttribute('aria-expanded', String(open));
slip.textContent = open ? pick() : '';
});
})();
```How this works
The fracture is two polygons that must stay complementary. The left half ends where the right begins, at the same three midpoints:
[clip-path:polygon(0_0,52%_0,45%_50%,52%_100%,0_100%)]
[clip-path:polygon(52%_0,100%_0,100%_100%,52%_100%,45%_50%)]Side by side in the markup, that constraint is visible. In the CSS original they were eight lines apart.
The accessible core is the disclosure, not the crack. aria-expanded flips, the fortune lands in a polite live region, and a screen-reader user hears "expanded" followed by the text. Reduced motion removes the rotation and nothing about the function changes.
One class drives everything. The controller toggles is-open on the wrapper; both halves and the slip read it through group-[.is-open]:. That is the same class-based group variant used by demos 09, 15 and 20 — the collection's standard idiom for JS-driven state that isn't a data attribute.
Make it yours
- Replace the
fortunesarray with release notes, tips or a single fixed message. - Change the fracture by editing both polygons' midpoints together — they must stay complementary.
- One-shot: drop the toggle and disable the button after opening.
- The slip is a normal flex box; swap it for an image or a coupon code.
- Hover already opens the halves 2° as a hint. Remove it for a stricter control.
Gotchas — read before shipping
- A reveal that only animates is invisible to assistive tech.
aria-expandedplus a live region is the core. - Live regions must exist in the DOM before the text changes; creating the element and setting text in one tick often fails to announce.
- The halves must sit in a non-clipping parent or the rotation is cut off at the button's edge.
- Never centre a label inside a shape that splits — the fracture runs through the type. Caption below, always.
- Don't animate the slip's height; scale and opacity keep it off the layout thread.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 16.4+ | 128+ | 111+ |
clip-path polygons and individual transform utilities are baseline; aria-live and aria-expanded are platform features.