Snippets · Tailwind CSS

Tailwind Button Presets

A copy-paste collection of ready-made button styles built entirely with Tailwind utility classes. Click a preset to copy its class string, then drop it onto any button element in your markup.

Primary

Solid accent fill for the main call-to-action on a page.

inline-flex items-center justify-center gap-2 rounded-lg bg-accent px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-accent/90 focus:outline-none focus:ring-2 focus:ring-accent/40

Secondary

Dark, neutral solid for supporting actions alongside a primary button.

inline-flex items-center justify-center gap-2 rounded-lg bg-zinc-800 px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-zinc-700 focus:outline-none focus:ring-2 focus:ring-zinc-500

Outline

Bordered and minimal: sits quietly on any surface or background.

inline-flex items-center justify-center gap-2 rounded-lg border border-zinc-400 px-5 py-2.5 text-sm font-semibold text-zinc-800 transition-colors hover:bg-zinc-100 focus:outline-none focus:ring-2 focus:ring-zinc-400 dark:border-white/30 dark:text-zinc-100 dark:hover:bg-white/10

Ghost

No background or border; an understated inline action.

inline-flex items-center justify-center gap-2 rounded-lg px-5 py-2.5 text-sm font-semibold text-zinc-700 transition-colors hover:bg-zinc-100 focus:outline-none focus:ring-2 focus:ring-zinc-400 dark:text-zinc-300 dark:hover:bg-white/10

Gradient

Violet-to-fuchsia gradient sweep for high-impact moments.

inline-flex items-center justify-center gap-2 rounded-lg bg-gradient-to-r from-violet-600 to-fuchsia-500 px-5 py-2.5 text-sm font-semibold text-white transition-opacity hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-fuchsia-400

Glass

Frosted translucent panel with backdrop blur, built for overlays and hero images.

inline-flex items-center justify-center gap-2 rounded-lg border border-white/20 bg-white/10 px-5 py-2.5 text-sm font-semibold text-white backdrop-blur-md transition-colors hover:bg-white/20 focus:outline-none focus:ring-2 focus:ring-white/30

Neon

Cyan glow with an outer shadow, straight out of a cyberpunk terminal.

inline-flex items-center justify-center gap-2 rounded-lg border border-cyan-400/60 bg-cyan-400/10 px-5 py-2.5 text-sm font-semibold text-cyan-300 shadow-[0_0_15px_rgba(34,211,238,0.35)] transition-shadow hover:shadow-[0_0_30px_rgba(34,211,238,0.6)] focus:outline-none focus:ring-2 focus:ring-cyan-400

Pill

Fully rounded capsule shape for a soft, friendly CTA.

inline-flex items-center justify-center gap-2 rounded-full bg-accent px-6 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-accent/90 focus:outline-none focus:ring-2 focus:ring-accent/40

Soft

Subtle accent tint background: a quiet alternative to primary.

inline-flex items-center justify-center gap-2 rounded-lg bg-accent/10 px-5 py-2.5 text-sm font-semibold text-accent transition-colors hover:bg-accent/20 focus:outline-none focus:ring-2 focus:ring-accent/40

Destructive

Solid red for delete, reset, and other destructive actions.

inline-flex items-center justify-center gap-2 rounded-lg bg-red-600 px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-red-500 focus:outline-none focus:ring-2 focus:ring-red-400

How these presets are built

Utility-first construction

Every preset on this page is one string of Tailwind utility classes, and each class compiles to a single CSS declaration. inline-flex turns the element into a flex container that still flows with surrounding text, items-center and justify-center center the label and icon, gap-2 spaces them, rounded-lg softens the corners, and px-5 py-2.5 sets the padding. Because the declarations come from the generated stylesheet, the same five or six utilities also cover buttons outside this collection, so the pattern carries over to your own markup. No component-specific CSS file is needed, no extra build step is required, and the whole preset stays readable at a glance. Stable hit area.

Colors and alpha values

Color utilities follow the syntax defined in CSS Color Module Level 4. Values such as bg-accent/90 or bg-accent/10 carry an alpha channel, so the accent color blends with the page background at 90 or 10 percent opacity. The same mechanism appears in border and ring utilities, where a translucent ring sits on any backdrop without a hard edge. Because alpha is part of the color value itself, a fill at one opacity and a ring at another describe two colors rather than two opacity rules, and the cascade stays predictable across light and dark themes. Match the text.

Hover and focus states

The hover: prefix compiles to the :hover pseudo-class, and transition utilities tell the browser which properties interpolate between states. MDN describes transitions as defining the change between two states of an element, with states coming from :hover or :active. Most presets also ship a focus:ring, which draws a visible outline on keyboard focus. Never hover alone.

Edge cases

Rendering differs across engines. The glass preset uses backdrop-blur, which applies only where the browser supports backdrop-filter, and the neon preset uses a box-shadow with zero offset and a blur radius. Where the backing property is missing, the translucent fill still renders, so the button never disappears. Glow follows radius.

Common mistakes

The frequent errors involve transition scope. transition-colors animates background, border and text color, while transition-shadow covers the glow. Changing the accent without a contrast check can push the label below WCAG thresholds, and dropping the focus ring while keeping focus:outline-none hides the indicator from keyboard users. Pair the transition.

Alternatives

A plain stylesheet can reproduce any preset with background, border, padding and box-shadow. Component libraries ship their own buttons, and CSS custom properties let a theme recolor all of them from one place. That keeps the same look without the utility layer. No JavaScript.

Utility classes and hand-written CSS are not mutually exclusive, and the presets on this page are meant to be read as one layer among several. A design system that already ships component classes can keep them and reach for the utility strings here when a one-off button needs a different weight, radius or accent than the system provides. Because every value in these strings maps to a CSS property documented in the same specifications that govern hand-written rules, the two approaches produce the same computed styles in the browser and can be mixed on the same page without a specificity fight.

FAQ

Can I use these presets in an existing Tailwind project?
Yes, they are plain utility strings. Paste them onto any button or link once your configuration scans the file.
Why does the hover effect not appear on touch screens?
The :hover pseudo-class is unreliable on touchscreens, so browsers may ignore it or keep it stuck. Focus rings and tap feedback carry the interaction instead.
How can I change the accent or destructive color?
Swap bg-accent, text-accent and the hover variants for your own tokens, or add a custom color to the Tailwind theme.
Do these buttons meet WCAG contrast requirements?
The default pairings target the WCAG 2.2 thresholds. Recheck any color you change, since contrast depends on the fill and the label together.

The CSS color, shadow and interaction standards behind these presets

  • MDN: box-shadow defines the offset, blur and spread syntax behind the neon glow.
  • MDN: transition explains how transition-colors and transition-shadow interpolate between the resting and hover states used here.
  • MDN: the :hover pseudo-class documents the pointing-device state the hover: prefix compiles to, including its touchscreen limitations.
  • W3C: CSS Color Module Level 4 specifies the color value syntax, including the alpha channel used by bg-accent/90 and bg-accent/10.
  • W3C: WCAG 2.2 sets the contrast and focus visibility criteria the text pairings and focus rings are checked against.