Button that flips like a card on hover and keyboard focus to reveal a second line on the back.
<div class="flex flex-wrap items-center justify-center gap-3">
<x-markas.flip-button back-label="It takes 2 minutes">Create account</x-markas.flip-button>
<x-markas.flip-button variant="secondary" back-label="No card needed">Start free trial</x-markas.flip-button>
</div>import { FlipButton } from "@/components/markas/FlipButton";
export default function FlipButtonExample() {
return (
<div className="flex flex-wrap items-center justify-center gap-3">
<FlipButton backLabel="It takes 2 minutes">Create account</FlipButton>
<FlipButton variant="secondary" backLabel="No card needed">
Start free trial
</FlipButton>
</div>
);
}<script setup lang="ts">
import FlipButton from "@/components/markas/FlipButton.vue";
</script>
<template>
<div class="flex flex-wrap items-center justify-center gap-3">
<FlipButton back-label="It takes 2 minutes">Create account</FlipButton>
<FlipButton variant="secondary" back-label="No card needed"
>Start free trial</FlipButton
>
</div>
</template><script lang="ts">
import FlipButton from "$lib/components/markas/FlipButton.svelte";
</script>
<div class="flex flex-wrap items-center justify-center gap-3">
<FlipButton backLabel="It takes 2 minutes">Create account</FlipButton>
<FlipButton variant="secondary" backLabel="No card needed">
Start free trial
</FlipButton>
</div>---
import FlipButton from "@/components/markas/FlipButton.astro";
---
<div class="flex flex-wrap items-center justify-center gap-3">
<FlipButton backLabel="It takes 2 minutes">Create account</FlipButton>
<FlipButton variant="secondary" backLabel="No card needed">
Start free trial
</FlipButton>
</div>Examples
Variants
<div class="flex flex-wrap items-center justify-center gap-3">
<x-markas.flip-button back-label="Let's go">Primary</x-markas.flip-button>
<x-markas.flip-button variant="secondary" back-label="Let's go">Secondary</x-markas.flip-button>
<x-markas.flip-button variant="ghost" back-label="Let's go">Ghost</x-markas.flip-button>
<x-markas.flip-button variant="danger" back-label="Are you sure">Danger</x-markas.flip-button>
</div><script setup lang="ts">
import FlipButton from "@/components/markas/FlipButton.vue";
</script>
<template>
<div class="flex flex-wrap items-center justify-center gap-3">
<FlipButton back-label="Let's go">Primary</FlipButton>
<FlipButton variant="secondary" back-label="Let's go">Secondary</FlipButton>
<FlipButton variant="ghost" back-label="Let's go">Ghost</FlipButton>
<FlipButton variant="danger" back-label="Are you sure">Danger</FlipButton>
</div>
</template><script lang="ts">
import FlipButton from "$lib/components/markas/FlipButton.svelte";
</script>
<div class="flex flex-wrap items-center justify-center gap-3">
<FlipButton backLabel="Let's go">Primary</FlipButton>
<FlipButton variant="secondary" backLabel="Let's go">Secondary</FlipButton>
<FlipButton variant="ghost" backLabel="Let's go">Ghost</FlipButton>
<FlipButton variant="danger" backLabel="Are you sure">Danger</FlipButton>
</div>---
import FlipButton from "@/components/markas/FlipButton.astro";
---
<div class="flex flex-wrap items-center justify-center gap-3">
<FlipButton backLabel="Let's go">Primary</FlipButton>
<FlipButton variant="secondary" backLabel="Let's go">Secondary</FlipButton>
<FlipButton variant="ghost" backLabel="Let's go">Ghost</FlipButton>
<FlipButton variant="danger" backLabel="Are you sure">Danger</FlipButton>
</div>Sizes
<div class="flex flex-wrap items-center justify-center gap-3">
<x-markas.flip-button size="sm" back-label="Free">Small</x-markas.flip-button>
<x-markas.flip-button back-label="Free">Medium</x-markas.flip-button>
<x-markas.flip-button size="lg" back-label="Free">Large</x-markas.flip-button>
</div><script setup lang="ts">
import FlipButton from "@/components/markas/FlipButton.vue";
</script>
<template>
<div class="flex flex-wrap items-center justify-center gap-3">
<FlipButton size="sm" back-label="Free">Small</FlipButton>
<FlipButton back-label="Free">Medium</FlipButton>
<FlipButton size="lg" back-label="Free">Large</FlipButton>
</div>
</template><script lang="ts">
import FlipButton from "$lib/components/markas/FlipButton.svelte";
</script>
<div class="flex flex-wrap items-center justify-center gap-3">
<FlipButton size="sm" backLabel="Free">Small</FlipButton>
<FlipButton backLabel="Free">Medium</FlipButton>
<FlipButton size="lg" backLabel="Free">Large</FlipButton>
</div>---
import FlipButton from "@/components/markas/FlipButton.astro";
---
<div class="flex flex-wrap items-center justify-center gap-3">
<FlipButton size="sm" backLabel="Free">Small</FlipButton>
<FlipButton backLabel="Free">Medium</FlipButton>
<FlipButton size="lg" backLabel="Free">Large</FlipButton>
</div>With icons
<div class="flex justify-center">
<x-markas.flip-button size="lg">
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3v12m0 0-4-4m4 4 4-4M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2" /></svg>
Download report
<x-slot:back>
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5Zm0 0v5h5" /></svg>
PDF, 2.4 MB
</x-slot:back>
</x-markas.flip-button>
</div>Installation
npx markasui@latest add flip-buttonpnpm dlx markasui@latest add flip-buttonyarn dlx markasui@latest add flip-buttonbunx --bun markasui@latest add flip-button- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
resources/views/components/markas/flip-button.blade.php.
resources/views/components/markas/flip-button.blade.php
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/FlipButton.tsx.
src/components/markas/FlipButton.tsx
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/FlipButton.vue.
src/components/markas/FlipButton.vue
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/lib/components/markas/FlipButton.svelte.
src/lib/components/markas/FlipButton.svelte
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/components/markas/FlipButton.astro.
src/components/markas/FlipButton.astro
- Make sure Tailwind CSS v4 and markas.css are installed. See Installation.
- Copy the component source below to
src/app/markas/flip-button.component.ts.
src/app/markas/flip-button.component.ts
Usage
<x-markas.flip-button back-label="It takes 2 minutes">Create account</x-markas.flip-button>
<x-markas.flip-button size="lg">
Download report
<x-slot:back>PDF, 2.4 MB</x-slot:back>
</x-markas.flip-button>import { FlipButton } from "@/components/markas/FlipButton";
<FlipButton backLabel="It takes 2 minutes">Create account</FlipButton>
<FlipButton size="lg" backLabel={<>PDF, 2.4 MB</>}>Download report</FlipButton><script setup lang="ts">
import FlipButton from "@/components/markas/FlipButton.vue";
</script>
<template>
<FlipButton back-label="It takes 2 minutes">Create account</FlipButton>
<FlipButton size="lg">
Download report
<template #back>PDF, 2.4 MB</template>
</FlipButton>
</template><script lang="ts">
import FlipButton from "$lib/components/markas/FlipButton.svelte";
</script>
<FlipButton backLabel="It takes 2 minutes">Create account</FlipButton>
<FlipButton size="lg">
Download report
{#snippet back()}PDF, 2.4 MB{/snippet}
</FlipButton>---
import FlipButton from "@/components/markas/FlipButton.astro";
---
<FlipButton backLabel="It takes 2 minutes">Create account</FlipButton>
<FlipButton size="lg">
Download report
<Fragment slot="back">PDF, 2.4 MB</Fragment>
</FlipButton>import { Component } from "@angular/core";
import { FlipButton } from "./markas/flip-button.component";
@Component({
selector: "app-signup",
imports: [FlipButton],
template: `
<button markas-flip-button backLabel="It takes 2 minutes">
Create account
</button>
<button markas-flip-button size="lg">
Download report
<ng-container back>PDF, 2.4 MB</ng-container>
</button>
`,
})
export class Signup {}Angular uses an attribute selector on the native button. Without backLabel or a back element, the back face gets a copy of the label after the first render.
- Pure CSS: no JavaScript and no Alpine.js. The flip runs on hover and on keyboard focus.
- The back face is aria-hidden. Screen readers only read the front label.
- Touch devices have no hover, so never put required information only on the back.
Props
| Name | Type | Default | Description |
|---|---|---|---|
variant | 'primary' | 'secondary' | 'ghost' | 'danger' | primary | Visual style, the same set as Button. |
size | 'sm' | 'md' | 'lg' | md | Height 32, 40, or 48px, the same as Button. |
backLabel | string (React: ReactNode) | - | Text on the back face. Vue, Blade, and Astro also take a back slot, Svelte a back snippet, Angular an element with the back attribute. Falls back to the label. |
type | 'button' | 'submit' | 'reset' | button | Native type attribute. |
Accessibility
- A native button element, so Enter and Space work and focus shows a 2px primary outline.
- The back face is aria-hidden, so the accessible name is always the front label.
- Keyboard focus flips the button too, so keyboard users see the same back text.
- With prefers-reduced-motion the faces swap without the 3D turn.
Related components
More buttons components with the same classes in every framework.
- Copy ButtonCopies a string to the clipboard. The copy icon turns into an animated check mark and a live region says Copied.
- GitHub Stars ButtonLink to a GitHub repository with the GitHub mark and a star count that counts up when it scrolls into view. No fetch.
- Hold ButtonPress-and-hold button for risky actions. A fill tracks progress, releasing early cancels, and a complete event fires.
- Ripple ButtonButton that sends a ripple out from the click point, or from the center when pressed with the keyboard.
- Shimmer ButtonButton with a soft sheen that sweeps across it on a loop. The loop pauses off screen and stops with reduced motion.