51 Tailwind CSS Buttons
28 / 51

All 51 in 51 Tailwind CSS Buttons

  1. 01Tailwind Submit Button (Form Primary)
  2. 02Tailwind Primary and Secondary Button Pair
  3. 03Tailwind Ghost / Outline Button
  4. 04Tailwind Icon-Only Button with Accessible Tooltip
  5. 05Tailwind Gradient CTA Button
  6. 06Tailwind Loading Spinner Button (State Transition)
  7. 07Tailwind Disabled Button State (Full State Reference)
  8. 08Tailwind Button Group Component (Segmented Radio-Like)
  9. 09Tailwind Add to Cart Button
  10. 10Tailwind Download Progress Button
  11. 11Tailwind Like Heart Button
  12. 12Tailwind Confirm Delete Button
  13. 13Tailwind Play Pause Button
  14. 14Tailwind Subscribe Confetti Button
  15. 15Tailwind Magnetic Mercury Ripple Button
  16. 16Tailwind Brutalist Glitch Button
  17. 17Tailwind Neon Plasma Burst Button
  18. 18Tailwind Clay Press Button
  19. 19Tailwind Editorial Ink Spread Button
  20. 20Tailwind Particle Shard Burst Button
  21. 21Tailwind Brushed Brass Plate Button
  22. 22Tailwind Washi Paper Crane Button
  23. 23Tailwind Frosted Ice Cube Button
  24. 24Tailwind Vintage Typewriter Key Button
  25. 25Tailwind Lacquered Walnut Wood Button
  26. 26Tailwind Pharma Gel Capsule Button
  27. 27Tailwind Aged Copper Coin Button
  28. 28Tailwind Origami Fortune Cookie Button
  29. 29Tailwind Holographic Foil Sticker Button
  30. 30Tailwind Brutalist Concrete Slab Button
  31. 31Tailwind Mercury Bead Morph Button
  32. 32Tailwind Soft Pill Modern SaaS Button
  33. 33Tailwind Masking Tape Label Button
  34. 34Tailwind Obsidian Glass Shard Button
  35. 35Tailwind Wine Velvet Ribbon Button
  36. 36Tailwind LED Segment Display Button
  37. 37Tailwind Cassette Mixtape Label Button
  38. 38Tailwind Chalkboard Menu Button
  39. 39Tailwind Vinyl Record Sleeve Ripple Button
  40. 40Tailwind Polaroid Snapshot Button
  41. 41Tailwind Airline Boarding Pass Button
  42. 42Tailwind Aged Brass Subway Token Button
  43. 43Tailwind Vintage Rx Pharmacy Label Button
  44. 44Tailwind Bakelite Radio Dial Toggle Button
  45. 45Tailwind Regal Postage Stamp Button
  46. 46Tailwind Victorian Cigar Band Foil Button
  47. 47Tailwind Vintage Calculator Key Button
  48. 48Tailwind Toolbox Latch Spotlight Button
  49. 49Tailwind Receipt Paper Total Count-Up Button
  50. 50Tailwind IBM Punch Card Magnetic Follow Button
  51. 51Tailwind Brass Periscope Lens Button
Tailwind + JSMIT licensed

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.

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

<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;
  }
}
(() => {
  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.

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-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;
  }
}
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=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 group sits 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-dim at ≈7:1 — dimmer than the rest state, still comfortably readable, which is the point of a de-emphasised label rather than a disabled one.
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: 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 fortunes array 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-expanded plus 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

ChromeSafariFirefoxEdge
111+16.4+128+111+

clip-path polygons and individual transform utilities are baseline; aria-live and aria-expanded are platform features.

Techniques used in this demo

Utilitiesfirst-class utility or variant

Arbitraryneeds bracket syntax

HTML & JSno Tailwind involved

Search CodeFronts

Loading…