Skip to content
MarkasUI
Type to search

    Guide

    MarkasUI

    Form

    Feedback

    Overlay

    Navigation

    Data

    Sections

    Animations

    Backgrounds

    Buttons

    Templates

    Pages

    Flip Button

    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>
    import { Component } from "@angular/core";
    import { FlipButton } from "./markas/flip-button.component";
    
    @Component({
      selector: "markas-example",
      imports: [FlipButton],
      template: `
        <div class="flex flex-wrap items-center justify-center gap-3">
          <button markas-flip-button backLabel="It takes 2 minutes">
            Create account
          </button>
          <button markas-flip-button variant="secondary" backLabel="No card needed">
            Start free trial
          </button>
        </div>
      `,
    })
    export default class FlipButtonExample {}

    Examples

    Variants

    Sizes

    With icons

    Installation

    npx markasui@latest add flip-button

    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

    NameTypeDefaultDescription
    variant'primary' | 'secondary' | 'ghost' | 'danger'primaryVisual style, the same set as Button.
    size'sm' | 'md' | 'lg'mdHeight 32, 40, or 48px, the same as Button.
    backLabelstring (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'buttonNative 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.