Lewati ke konten
MarkasUI
Ketik untuk mencari

    Panduan

    MarkasUI

    Form

    Feedback

    Overlay

    Navigasi

    Data

    Section

    Animasi

    Latar

    Tombol

    Template

    Halaman

    Tilt Card

    Kartu yang miring 3D mengikuti kursor dengan kilau yang bergerak dan lapisan parallax opsional, lalu kembali halus. Terangkat saat fokus keyboard.

    Markas Gold member

    0042 1987 5531

    MemberRania Putri

    Since2021

    MarkasGold member

    0042 1987 5531

    MemberRania Putri

    Since2021

    MarkasGold member

    0042 1987 5531

    MemberRania Putri

    Since2021

    Markas Gold member

    0042 1987 5531

    MemberRania Putri

    Since2021

    MarkasGold member

    0042 1987 5531

    MemberRania Putri

    Since2021

    @php
        $stage = 'grid place-items-center py-8';
        $card = 'grid aspect-[1.586/1] w-80 content-between bg-linear-to-br from-primary to-primary-strong p-6 text-on-primary';
        $row = 'flex items-center justify-between';
        $brand = 'text-base font-semibold';
        $tier = 'rounded-full bg-on-primary/15 px-2.5 py-0.5 text-xs font-medium';
        $chip = 'h-8 w-11 rounded-md bg-linear-to-br from-warning to-warning/50';
        $number = 'text-lg font-medium tracking-widest tabular-nums';
        $footer = 'flex items-end justify-between text-sm font-medium';
        $caption = 'block text-xs font-normal text-on-primary/70';
    @endphp
    
    <div class="{{ $stage }}">
        <x-markas.tilt-card :class="$card">
            <div class="{{ $row }}">
                <span class="{{ $brand }}">Markas</span>
                <span class="{{ $tier }}">Gold member</span>
            </div>
            <div data-depth="14" class="{{ $chip }}"></div>
            <p data-depth="8" class="{{ $number }}">0042 1987 5531</p>
            <div class="{{ $footer }}">
                <p><span class="{{ $caption }}">Member</span>Rania Putri</p>
                <p><span class="{{ $caption }}">Since</span>2021</p>
            </div>
        </x-markas.tilt-card>
    </div>
    import { TiltCard } from "@/components/markas/TiltCard";
    
    const stage = "grid place-items-center py-8";
    const card =
      "grid aspect-[1.586/1] w-80 content-between bg-linear-to-br from-primary to-primary-strong p-6 text-on-primary";
    const row = "flex items-center justify-between";
    const brand = "text-base font-semibold";
    const tier = "rounded-full bg-on-primary/15 px-2.5 py-0.5 text-xs font-medium";
    const chip = "h-8 w-11 rounded-md bg-linear-to-br from-warning to-warning/50";
    const number = "text-lg font-medium tracking-widest tabular-nums";
    const footer = "flex items-end justify-between text-sm font-medium";
    const caption = "block text-xs font-normal text-on-primary/70";
    
    export default function TiltCardExample() {
      return (
        <div className={stage}>
          <TiltCard className={card}>
            <div className={row}>
              <span className={brand}>Markas</span>
              <span className={tier}>Gold member</span>
            </div>
            <div data-depth="14" className={chip}></div>
            <p data-depth="8" className={number}>
              0042 1987 5531
            </p>
            <div className={footer}>
              <p>
                <span className={caption}>Member</span>Rania Putri
              </p>
              <p>
                <span className={caption}>Since</span>2021
              </p>
            </div>
          </TiltCard>
        </div>
      );
    }
    <script setup lang="ts">
    import TiltCard from "@/components/markas/TiltCard.vue";
    
    const stage = "grid place-items-center py-8";
    const card =
      "grid aspect-[1.586/1] w-80 content-between bg-linear-to-br from-primary to-primary-strong p-6 text-on-primary";
    const row = "flex items-center justify-between";
    const brand = "text-base font-semibold";
    const tier = "rounded-full bg-on-primary/15 px-2.5 py-0.5 text-xs font-medium";
    const chip = "h-8 w-11 rounded-md bg-linear-to-br from-warning to-warning/50";
    const number = "text-lg font-medium tracking-widest tabular-nums";
    const footer = "flex items-end justify-between text-sm font-medium";
    const caption = "block text-xs font-normal text-on-primary/70";
    </script>
    
    <template>
      <div :class="stage">
        <TiltCard :class="card">
          <div :class="row">
            <span :class="brand">Markas</span>
            <span :class="tier">Gold member</span>
          </div>
          <div data-depth="14" :class="chip"></div>
          <p data-depth="8" :class="number">0042 1987 5531</p>
          <div :class="footer">
            <p><span :class="caption">Member</span>Rania Putri</p>
            <p><span :class="caption">Since</span>2021</p>
          </div>
        </TiltCard>
      </div>
    </template>
    <script lang="ts">
      import TiltCard from "$lib/components/markas/TiltCard.svelte";
    
      const stage = "grid place-items-center py-8";
      const card =
        "grid aspect-[1.586/1] w-80 content-between bg-linear-to-br from-primary to-primary-strong p-6 text-on-primary";
      const row = "flex items-center justify-between";
      const brand = "text-base font-semibold";
      const tier =
        "rounded-full bg-on-primary/15 px-2.5 py-0.5 text-xs font-medium";
      const chip = "h-8 w-11 rounded-md bg-linear-to-br from-warning to-warning/50";
      const number = "text-lg font-medium tracking-widest tabular-nums";
      const footer = "flex items-end justify-between text-sm font-medium";
      const caption = "block text-xs font-normal text-on-primary/70";
    </script>
    
    <div class={stage}>
      <TiltCard class={card}>
        <div class={row}>
          <span class={brand}>Markas</span>
          <span class={tier}>Gold member</span>
        </div>
        <div data-depth="14" class={chip}></div>
        <p data-depth="8" class={number}>0042 1987 5531</p>
        <div class={footer}>
          <p><span class={caption}>Member</span>Rania Putri</p>
          <p><span class={caption}>Since</span>2021</p>
        </div>
      </TiltCard>
    </div>
    ---
    import TiltCard from "@/components/markas/TiltCard.astro";
    
    const stage = "grid place-items-center py-8";
    const card =
      "grid aspect-[1.586/1] w-80 content-between bg-linear-to-br from-primary to-primary-strong p-6 text-on-primary";
    const row = "flex items-center justify-between";
    const brand = "text-base font-semibold";
    const tier = "rounded-full bg-on-primary/15 px-2.5 py-0.5 text-xs font-medium";
    const chip = "h-8 w-11 rounded-md bg-linear-to-br from-warning to-warning/50";
    const number = "text-lg font-medium tracking-widest tabular-nums";
    const footer = "flex items-end justify-between text-sm font-medium";
    const caption = "block text-xs font-normal text-on-primary/70";
    ---
    
      <div class={stage}>
        <TiltCard class={card}>
          <div class={row}>
            <span class={brand}>Markas</span>
            <span class={tier}>Gold member</span>
          </div>
          <div data-depth="14" class={chip}></div>
          <p data-depth="8" class={number}>0042 1987 5531</p>
          <div class={footer}>
            <p><span class={caption}>Member</span>Rania Putri</p>
            <p><span class={caption}>Since</span>2021</p>
          </div>
        </TiltCard>
      </div>
    import { Component } from "@angular/core";
    import { TiltCard } from "./markas/tilt-card.component";
    
    @Component({
      selector: "markas-example",
      imports: [TiltCard],
      template: `
        <div [class]="stage">
          <markas-tilt-card [class]="card">
            <div [class]="row">
              <span [class]="brand">Markas</span>
              <span [class]="tier">Gold member</span>
            </div>
            <div data-depth="14" [class]="chip"></div>
            <p data-depth="8" [class]="number">0042 1987 5531</p>
            <div [class]="footer">
              <p><span [class]="caption">Member</span>Rania Putri</p>
              <p><span [class]="caption">Since</span>2021</p>
            </div>
          </markas-tilt-card>
        </div>
      `,
    })
    export default class TiltCardExample {
      protected readonly stage = "grid place-items-center py-8";
      protected readonly card =
        "grid aspect-[1.586/1] w-80 content-between bg-linear-to-br from-primary to-primary-strong p-6 text-on-primary";
      protected readonly row = "flex items-center justify-between";
      protected readonly brand = "text-base font-semibold";
      protected readonly tier =
        "rounded-full bg-on-primary/15 px-2.5 py-0.5 text-xs font-medium";
      protected readonly chip =
        "h-8 w-11 rounded-md bg-linear-to-br from-warning to-warning/50";
      protected readonly number =
        "text-lg font-medium tracking-widest tabular-nums";
      protected readonly footer =
        "flex items-end justify-between text-sm font-medium";
      protected readonly caption = "block text-xs font-normal text-on-primary/70";
    }

    Contoh

    Kartu produk dengan gambar parallax

    Studio headphones

    Wireless, 40 hour battery

    $129

    Studio headphones

    Wireless, 40 hour battery

    $129

    Studio headphones

    Wireless, 40 hour battery

    $129

    Studio headphones

    Wireless, 40 hour battery

    $129

    Studio headphones

    Wireless, 40 hour battery

    $129

    Kartu profil

    Adi Santoso

    Product designer, Bandung

    48Projects

    1.2kFollowers

    312Following

    Adi Santoso

    Product designer, Bandung

    48Projects

    1.2kFollowers

    312Following

    Adi Santoso

    Product designer, Bandung

    48Projects

    1.2kFollowers

    312Following

    Adi Santoso

    Product designer, Bandung

    48Projects

    1.2kFollowers

    312Following

    Adi Santoso

    Product designer, Bandung

    48Projects

    1.2kFollowers

    312Following

    Kemiringan halus tanpa kilau

    Pro

    Popular

    $12 per month

    • Unlimited projects
    • Custom domains
    • Priority support
    Choose Pro

    Pro

    Popular

    $12 per month

    • Unlimited projects
    • Custom domains
    • Priority support
    Choose Pro

    Pro

    Popular

    $12 per month

    • Unlimited projects
    • Custom domains
    • Priority support
    Choose Pro

    Pro

    Popular

    $12 per month

    • Unlimited projects
    • Custom domains
    • Priority support
    Choose Pro

    Pro

    Popular

    $12 per month

    • Unlimited projects
    • Custom domains
    • Priority support
    Choose Pro

    Instalasi

    npx markasui@latest add tilt-card

    Pemakaian

    <x-markas.tilt-card :max-angle="12" class="w-72 border border-line bg-surface p-5">
        <img data-depth="16" src="/img/headphones.png" alt="" class="rounded-lg" />
        <p class="mt-4 font-semibold">Headphone studio</p>
        <x-markas.button>Tambah ke keranjang</x-markas.button>
    </x-markas.tilt-card>

    Butuh Alpine.js.

    import { TiltCard } from "@/components/markas/TiltCard";
    
    <TiltCard maxAngle={12} className="w-72 border border-line bg-surface p-5">
      <img
        data-depth="16"
        src="/img/headphones.png"
        alt=""
        className="rounded-lg"
      />
      <p className="mt-4 font-semibold">Headphone studio</p>
    </TiltCard>;
    <template>
      <TiltCard :max-angle="12" class="w-72 border border-line bg-surface p-5">
        <img data-depth="16" src="/img/headphones.png" alt="" class="rounded-lg" />
        <p class="mt-4 font-semibold">Headphone studio</p>
      </TiltCard>
    </template>
    <script lang="ts">
      import TiltCard from "$lib/components/markas/TiltCard.svelte";
    </script>
    
    <TiltCard maxAngle={8} class="border border-line bg-surface p-6">
      <div data-depth="20">Pro plan</div>
    </TiltCard>
    ---
    import TiltCard from "@/components/markas/TiltCard.astro";
    ---
    
    <TiltCard maxAngle={8} class="border border-line bg-surface p-6">
      <div data-depth="20">Pro plan</div>
    </TiltCard>

    Satu script kecil yang dibundel melayani semua kartu di halaman.

    import { Component } from "@angular/core";
    import { TiltCard } from "./markas/tilt-card.component";
    
    @Component({
      selector: "app-plan",
      imports: [TiltCard],
      template: `
        <markas-tilt-card [maxAngle]="8" class="border border-line bg-surface p-6">
          <div data-depth="20">Pro plan</div>
        </markas-tilt-card>
      `,
    })
    export class Plan {}
    • Kartu berputar hingga maxAngle derajat ke arah kursor lewat custom property --tilt-x dan --tilt-y, lalu kembali halus saat kursor keluar.
    • Anak dengan data-depth="16" bergeser hingga 16px untuk parallax. Pakai pada satu atau dua elemen.
    • Fokus keyboard pada tautan atau tombol di dalam kartu membuat kartu sedikit terangkat. Dengan reduced motion kartu tetap datar.
    • glare={false} menghapus cahaya bergerak. Atribut dan class jatuh ke kartu itu sendiri.

    Props

    NamaTipeDefaultKeterangan
    maxAnglenumber10Rotasi terbesar dalam derajat, tercapai saat kursor di tepi kartu. 4 sampai 8 terasa halus, 12 sampai 15 lebih main-main.
    glarebooleantrueMenampilkan cahaya lembut yang mengikuti kursor di atas kartu.
    children / slotReactNode / slot-Isi kartu. Atur tampilan kartu dengan class sendiri (latar, border, padding). Anak dengan data-depth="16" bergeser hingga sebanyak itu px untuk parallax.

    Aksesibilitas

    • Kemiringan, kilau, dan parallax hanya visual; kilau adalah lapisan aria-hidden yang tidak pernah menangkap pointer.
    • Saat tautan atau tombol di dalam kartu mendapat fokus keyboard, kartu sedikit terangkat sehingga fokus mudah diikuti.
    • Dengan reduced motion kartu tetap datar dan diam, tanpa kilau.

    Komponen terkait

    Komponen markasui lain dengan class yang sama di setiap framework.