Pembungkus yang membuat anaknya melayang, naik turun, mengorbit, atau bernapas dengan ritme sendiri, dengan parallax kursor dan kemunculan berurutan.
Ship the idea this week
Copy a component into Blade, React, or Vue and keep going.
Ship the idea this week
Copy a component into Blade, React, or Vue and keep going.
Ship the idea this week
Copy a component into Blade, React, or Vue and keep going.
Ship the idea this week
Copy a component into Blade, React, or Vue and keep going.
Ship the idea this week
Copy a component into Blade, React, or Vue and keep going.
@php
$hero = 'relative grid h-80 place-items-center overflow-hidden rounded-xl border border-line bg-canvas px-6 text-center';
$layer = 'absolute inset-0';
$tileA = 'absolute top-[12%] left-[10%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay';
$tileB = 'absolute top-[16%] right-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay';
$tileC = 'absolute bottom-[14%] left-[16%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay';
$tileD = 'absolute right-[18%] bottom-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay';
$tileE = 'absolute top-[46%] left-[4%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay';
$icon = 'size-6';
$copy = 'relative max-w-64';
$title = 'text-2xl font-semibold text-ink';
$text = 'mt-2 text-sm text-muted';
@endphp
<div class="{{ $hero }}">
<x-markas.float :parallax="14" aria-hidden="true" :class="$layer">
<span class="{{ $tileA }}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="{{ $icon }}"><path d="m8 8-4 4 4 4"></path><path d="m16 8 4 4-4 4"></path></svg></span>
<span class="{{ $tileB }}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="{{ $icon }}"><path d="M12 3 13.9 8.1 19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z"></path></svg></span>
<span class="{{ $tileC }}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="{{ $icon }}"><path d="m12 4 8 4-8 4-8-4 8-4Z"></path><path d="m4 12 8 4 8-4"></path><path d="m4 16 8 4 8-4"></path></svg></span>
<span class="{{ $tileD }}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="{{ $icon }}"><path d="M13 3 5 14h6l-1 7 8-11h-6l1-7Z"></path></svg></span>
<span class="{{ $tileE }}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="{{ $icon }}"><path d="m5 3 14 7-6 2-2 6-6-15Z"></path></svg></span>
</x-markas.float>
<div class="{{ $copy }}">
<p class="{{ $title }}">Ship the idea this week</p>
<p class="{{ $text }}">Copy a component into Blade, React, or Vue and keep going.</p>
</div>
</div>import { Float } from "@/components/markas/Float";
const hero =
"relative grid h-80 place-items-center overflow-hidden rounded-xl border border-line bg-canvas px-6 text-center";
const layer = "absolute inset-0";
const tileA =
"absolute top-[12%] left-[10%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileB =
"absolute top-[16%] right-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileC =
"absolute bottom-[14%] left-[16%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileD =
"absolute right-[18%] bottom-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileE =
"absolute top-[46%] left-[4%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const icon = "size-6";
const copy = "relative max-w-64";
const title = "text-2xl font-semibold text-ink";
const text = "mt-2 text-sm text-muted";
export default function FloatExample() {
return (
<div className={hero}>
<Float parallax={14} aria-hidden="true" className={layer}>
<span className={tileA}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
className={icon}
>
<path d="m8 8-4 4 4 4"></path>
<path d="m16 8 4 4-4 4"></path>
</svg>
</span>
<span className={tileB}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
className={icon}
>
<path d="M12 3 13.9 8.1 19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z"></path>
</svg>
</span>
<span className={tileC}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
className={icon}
>
<path d="m12 4 8 4-8 4-8-4 8-4Z"></path>
<path d="m4 12 8 4 8-4"></path>
<path d="m4 16 8 4 8-4"></path>
</svg>
</span>
<span className={tileD}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
className={icon}
>
<path d="M13 3 5 14h6l-1 7 8-11h-6l1-7Z"></path>
</svg>
</span>
<span className={tileE}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
className={icon}
>
<path d="m5 3 14 7-6 2-2 6-6-15Z"></path>
</svg>
</span>
</Float>
<div className={copy}>
<p className={title}>Ship the idea this week</p>
<p className={text}>
Copy a component into Blade, React, or Vue and keep going.
</p>
</div>
</div>
);
}<script setup lang="ts">
import Float from "@/components/markas/Float.vue";
const hero =
"relative grid h-80 place-items-center overflow-hidden rounded-xl border border-line bg-canvas px-6 text-center";
const layer = "absolute inset-0";
const tileA =
"absolute top-[12%] left-[10%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileB =
"absolute top-[16%] right-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileC =
"absolute bottom-[14%] left-[16%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileD =
"absolute right-[18%] bottom-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileE =
"absolute top-[46%] left-[4%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const icon = "size-6";
const copy = "relative max-w-64";
const title = "text-2xl font-semibold text-ink";
const text = "mt-2 text-sm text-muted";
</script>
<template>
<div :class="hero">
<Float :parallax="14" aria-hidden="true" :class="layer">
<span :class="tileA"
><svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
:class="icon"
>
<path d="m8 8-4 4 4 4"></path>
<path d="m16 8 4 4-4 4"></path></svg
></span>
<span :class="tileB"
><svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
:class="icon"
>
<path
d="M12 3 13.9 8.1 19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z"
></path></svg
></span>
<span :class="tileC"
><svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
:class="icon"
>
<path d="m12 4 8 4-8 4-8-4 8-4Z"></path>
<path d="m4 12 8 4 8-4"></path>
<path d="m4 16 8 4 8-4"></path></svg
></span>
<span :class="tileD"
><svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
:class="icon"
>
<path d="M13 3 5 14h6l-1 7 8-11h-6l1-7Z"></path></svg
></span>
<span :class="tileE"
><svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
:class="icon"
>
<path d="m5 3 14 7-6 2-2 6-6-15Z"></path></svg
></span>
</Float>
<div :class="copy">
<p :class="title">Ship the idea this week</p>
<p :class="text">
Copy a component into Blade, React, or Vue and keep going.
</p>
</div>
</div>
</template><script lang="ts">
import Float from "$lib/components/markas/Float.svelte";
const hero =
"relative grid h-80 place-items-center overflow-hidden rounded-xl border border-line bg-canvas px-6 text-center";
const layer = "absolute inset-0";
const tileA =
"absolute top-[12%] left-[10%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileB =
"absolute top-[16%] right-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileC =
"absolute bottom-[14%] left-[16%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileD =
"absolute right-[18%] bottom-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileE =
"absolute top-[46%] left-[4%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const icon = "size-6";
const copy = "relative max-w-64";
const title = "text-2xl font-semibold text-ink";
const text = "mt-2 text-sm text-muted";
</script>
<div class={hero}>
<Float parallax={14} aria-hidden="true" class={layer}>
<span class={tileA}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="m8 8-4 4 4 4" />
<path d="m16 8 4 4-4 4" />
</svg>
</span>
<span class={tileB}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path
d="M12 3 13.9 8.1 19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z"
/>
</svg>
</span>
<span class={tileC}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="m12 4 8 4-8 4-8-4 8-4Z" />
<path d="m4 12 8 4 8-4" />
<path d="m4 16 8 4 8-4" />
</svg>
</span>
<span class={tileD}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="M13 3 5 14h6l-1 7 8-11h-6l1-7Z" />
</svg>
</span>
<span class={tileE}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="m5 3 14 7-6 2-2 6-6-15Z" />
</svg>
</span>
</Float>
<div class={copy}>
<p class={title}>Ship the idea this week</p>
<p class={text}>
Copy a component into Blade, React, or Vue and keep going.
</p>
</div>
</div>---
import Float from "@/components/markas/Float.astro";
const hero =
"relative grid h-80 place-items-center overflow-hidden rounded-xl border border-line bg-canvas px-6 text-center";
const layer = "absolute inset-0";
const tileA =
"absolute top-[12%] left-[10%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileB =
"absolute top-[16%] right-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileC =
"absolute bottom-[14%] left-[16%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileD =
"absolute right-[18%] bottom-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const tileE =
"absolute top-[46%] left-[4%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
const icon = "size-6";
const copy = "relative max-w-64";
const title = "text-2xl font-semibold text-ink";
const text = "mt-2 text-sm text-muted";
---
<div class={hero}>
<Float parallax={14} aria-hidden="true" class={layer}>
<span class={tileA}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="m8 8-4 4 4 4" />
<path d="m16 8 4 4-4 4" />
</svg>
</span>
<span class={tileB}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="M12 3 13.9 8.1 19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z" />
</svg>
</span>
<span class={tileC}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="m12 4 8 4-8 4-8-4 8-4Z" />
<path d="m4 12 8 4 8-4" />
<path d="m4 16 8 4 8-4" />
</svg>
</span>
<span class={tileD}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="M13 3 5 14h6l-1 7 8-11h-6l1-7Z" />
</svg>
</span>
<span class={tileE}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="m5 3 14 7-6 2-2 6-6-15Z" />
</svg>
</span>
</Float>
<div class={copy}>
<p class={title}>Ship the idea this week</p>
<p class={text}>
Copy a component into Blade, React, or Vue and keep going.
</p>
</div>
</div>import { Component } from "@angular/core";
import { Float } from "./markas/float.component";
@Component({
selector: "markas-example",
imports: [Float],
template: `
<div [class]="hero">
<markas-float [parallax]="14" aria-hidden="true" [class]="layer">
<span [class]="tileA">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
[class]="icon"
>
<path d="m8 8-4 4 4 4" />
<path d="m16 8 4 4-4 4" />
</svg>
</span>
<span [class]="tileB">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
[class]="icon"
>
<path
d="M12 3 13.9 8.1 19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3Z"
/>
</svg>
</span>
<span [class]="tileC">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
[class]="icon"
>
<path d="m12 4 8 4-8 4-8-4 8-4Z" />
<path d="m4 12 8 4 8-4" />
<path d="m4 16 8 4 8-4" />
</svg>
</span>
<span [class]="tileD">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
[class]="icon"
>
<path d="M13 3 5 14h6l-1 7 8-11h-6l1-7Z" />
</svg>
</span>
<span [class]="tileE">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
[class]="icon"
>
<path d="m5 3 14 7-6 2-2 6-6-15Z" />
</svg>
</span>
</markas-float>
<div [class]="copy">
<p [class]="title">Ship the idea this week</p>
<p [class]="text">
Copy a component into Blade, React, or Vue and keep going.
</p>
</div>
</div>
`,
})
export default class FloatExample {
protected readonly hero =
"relative grid h-80 place-items-center overflow-hidden rounded-xl border border-line bg-canvas px-6 text-center";
protected readonly layer = "absolute inset-0";
protected readonly tileA =
"absolute top-[12%] left-[10%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
protected readonly tileB =
"absolute top-[16%] right-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
protected readonly tileC =
"absolute bottom-[14%] left-[16%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
protected readonly tileD =
"absolute right-[18%] bottom-[12%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
protected readonly tileE =
"absolute top-[46%] left-[4%] grid size-12 place-items-center rounded-xl border border-line bg-surface text-ink shadow-overlay";
protected readonly icon = "size-6";
protected readonly copy = "relative max-w-64";
protected readonly title = "text-2xl font-semibold text-ink";
protected readonly text = "mt-2 text-sm text-muted";
}Contoh
Badge naik turun di kartu harga
Pro yearly
Rp 79.000 / month
- Unlimited projects
- Priority support in Bahasa Indonesia
- Billed Rp 948.000 a year
Pro yearly
Rp 79.000 / month
- Unlimited projects
- Priority support in Bahasa Indonesia
- Billed Rp 948.000 a year
Pro yearly
Rp 79.000 / month
- Unlimited projects
- Priority support in Bahasa Indonesia
- Billed Rp 948.000 a year
Pro yearly
Rp 79.000 / month
- Unlimited projects
- Priority support in Bahasa Indonesia
- Billed Rp 948.000 a year
Pro yearly
Rp 79.000 / month
- Unlimited projects
- Priority support in Bahasa Indonesia
- Billed Rp 948.000 a year
@php
$stage = 'grid place-items-center py-6';
$card = 'relative w-72 rounded-xl border border-line bg-surface p-6';
$badgeWrap = 'absolute -top-3 right-5';
$badge = 'inline-block rounded-full bg-primary px-3 py-1 text-xs font-semibold text-on-primary';
$plan = 'text-sm font-medium text-muted';
$price = 'mt-2 text-3xl font-semibold text-ink tabular-nums';
$period = 'text-sm font-normal text-muted';
$list = 'mt-4 space-y-2 text-sm text-ink';
@endphp
<div class="{{ $stage }}">
<div class="{{ $card }}">
<x-markas.float motion="bob" :amplitude="6" :duration="3" :class="$badgeWrap">
<span class="{{ $badge }}">Save 20%</span>
</x-markas.float>
<p class="{{ $plan }}">Pro yearly</p>
<p class="{{ $price }}">Rp 79.000 <span class="{{ $period }}">/ month</span></p>
<ul class="{{ $list }}">
<li>Unlimited projects</li>
<li>Priority support in Bahasa Indonesia</li>
<li>Billed Rp 948.000 a year</li>
</ul>
</div>
</div>import { Float } from "@/components/markas/Float";
const stage = "grid place-items-center py-6";
const card = "relative w-72 rounded-xl border border-line bg-surface p-6";
const badgeWrap = "absolute -top-3 right-5";
const badge =
"inline-block rounded-full bg-primary px-3 py-1 text-xs font-semibold text-on-primary";
const plan = "text-sm font-medium text-muted";
const price = "mt-2 text-3xl font-semibold text-ink tabular-nums";
const period = "text-sm font-normal text-muted";
const list = "mt-4 space-y-2 text-sm text-ink";
export default function Example() {
return (
<div className={stage}>
<div className={card}>
<Float motion="bob" amplitude={6} duration={3} className={badgeWrap}>
<span className={badge}>Save 20%</span>
</Float>
<p className={plan}>Pro yearly</p>
<p className={price}>
Rp 79.000 <span className={period}>/ month</span>
</p>
<ul className={list}>
<li>Unlimited projects</li>
<li>Priority support in Bahasa Indonesia</li>
<li>Billed Rp 948.000 a year</li>
</ul>
</div>
</div>
);
}<script setup lang="ts">
import Float from "@/components/markas/Float.vue";
const stage = "grid place-items-center py-6";
const card = "relative w-72 rounded-xl border border-line bg-surface p-6";
const badgeWrap = "absolute -top-3 right-5";
const badge =
"inline-block rounded-full bg-primary px-3 py-1 text-xs font-semibold text-on-primary";
const plan = "text-sm font-medium text-muted";
const price = "mt-2 text-3xl font-semibold text-ink tabular-nums";
const period = "text-sm font-normal text-muted";
const list = "mt-4 space-y-2 text-sm text-ink";
</script>
<template>
<div :class="stage">
<div :class="card">
<Float motion="bob" :amplitude="6" :duration="3" :class="badgeWrap">
<span :class="badge">Save 20%</span>
</Float>
<p :class="plan">Pro yearly</p>
<p :class="price">Rp 79.000 <span :class="period">/ month</span></p>
<ul :class="list">
<li>Unlimited projects</li>
<li>Priority support in Bahasa Indonesia</li>
<li>Billed Rp 948.000 a year</li>
</ul>
</div>
</div>
</template><script lang="ts">
import Float from "$lib/components/markas/Float.svelte";
const stage = "grid place-items-center py-6";
const card = "relative w-72 rounded-xl border border-line bg-surface p-6";
const badgeWrap = "absolute -top-3 right-5";
const badge =
"inline-block rounded-full bg-primary px-3 py-1 text-xs font-semibold text-on-primary";
const plan = "text-sm font-medium text-muted";
const price = "mt-2 text-3xl font-semibold text-ink tabular-nums";
const period = "text-sm font-normal text-muted";
const list = "mt-4 space-y-2 text-sm text-ink";
</script>
<div class={stage}>
<div class={card}>
<Float motion="bob" amplitude={6} duration={3} class={badgeWrap}>
<span class={badge}>Save 20%</span>
</Float>
<p class={plan}>Pro yearly</p>
<p class={price}>
Rp 79.000 <span class={period}>/ month</span>
</p>
<ul class={list}>
<li>Unlimited projects</li>
<li>Priority support in Bahasa Indonesia</li>
<li>Billed Rp 948.000 a year</li>
</ul>
</div>
</div>---
import Float from "@/components/markas/Float.astro";
const stage = "grid place-items-center py-6";
const card = "relative w-72 rounded-xl border border-line bg-surface p-6";
const badgeWrap = "absolute -top-3 right-5";
const badge =
"inline-block rounded-full bg-primary px-3 py-1 text-xs font-semibold text-on-primary";
const plan = "text-sm font-medium text-muted";
const price = "mt-2 text-3xl font-semibold text-ink tabular-nums";
const period = "text-sm font-normal text-muted";
const list = "mt-4 space-y-2 text-sm text-ink";
---
<div class={stage}>
<div class={card}>
<Float motion="bob" amplitude={6} duration={3} class={badgeWrap}>
<span class={badge}>Save 20%</span>
</Float>
<p class={plan}>Pro yearly</p>
<p class={price}>
Rp 79.000 <span class={period}>/ month</span>
</p>
<ul class={list}>
<li>Unlimited projects</li>
<li>Priority support in Bahasa Indonesia</li>
<li>Billed Rp 948.000 a year</li>
</ul>
</div>
</div>import { Component } from "@angular/core";
import { Float } from "./markas/float.component";
@Component({
selector: "markas-example",
imports: [Float],
template: `
<div [class]="stage">
<div [class]="card">
<markas-float
motion="bob"
[amplitude]="6"
[duration]="3"
[class]="badgeWrap"
>
<span [class]="badge">Save 20%</span>
</markas-float>
<p [class]="plan">Pro yearly</p>
<p [class]="price">Rp 79.000 <span [class]="period">/ month</span></p>
<ul [class]="list">
<li>Unlimited projects</li>
<li>Priority support in Bahasa Indonesia</li>
<li>Billed Rp 948.000 a year</li>
</ul>
</div>
</div>
`,
})
export default class FloatPricingExample {
protected readonly stage = "grid place-items-center py-6";
protected readonly card =
"relative w-72 rounded-xl border border-line bg-surface p-6";
protected readonly badgeWrap = "absolute -top-3 right-5";
protected readonly badge =
"inline-block rounded-full bg-primary px-3 py-1 text-xs font-semibold text-on-primary";
protected readonly plan = "text-sm font-medium text-muted";
protected readonly price =
"mt-2 text-3xl font-semibold text-ink tabular-nums";
protected readonly period = "text-sm font-normal text-muted";
protected readonly list = "mt-4 space-y-2 text-sm text-ink";
}Avatar mengorbit dengan kemunculan berurutan
2,400
makers across Indonesia
2,400
makers across Indonesia
2,400
makers across Indonesia
2,400
makers across Indonesia
2,400
makers across Indonesia
@php
$stage = 'relative grid h-72 place-items-center overflow-hidden rounded-xl border border-line bg-surface';
$layer = 'absolute inset-0';
$avatarA = 'absolute top-[14%] left-[18%] grid size-12 place-items-center rounded-full bg-primary-soft text-sm font-semibold text-ink';
$avatarB = 'absolute top-[10%] right-[20%] grid size-10 place-items-center rounded-full bg-success/15 text-sm font-semibold text-ink';
$avatarC = 'absolute bottom-[16%] left-[12%] grid size-10 place-items-center rounded-full bg-warning/15 text-sm font-semibold text-ink';
$avatarD = 'absolute right-[14%] bottom-[18%] grid size-14 place-items-center rounded-full bg-primary text-sm font-semibold text-on-primary';
$avatarE = 'absolute top-[44%] right-[6%] grid size-9 place-items-center rounded-full bg-danger/10 text-xs font-semibold text-ink';
$copy = 'relative text-center';
$count = 'text-3xl font-semibold text-ink tabular-nums';
$label = 'text-sm text-muted';
@endphp
<div class="{{ $stage }}">
<x-markas.float motion="orbit" :amplitude="8" :duration="9" :seed="2" :entrance="true" aria-hidden="true" :class="$layer">
<span class="{{ $avatarA }}">RP</span>
<span class="{{ $avatarB }}">BS</span>
<span class="{{ $avatarC }}">SA</span>
<span class="{{ $avatarD }}">DP</span>
<span class="{{ $avatarE }}">NW</span>
</x-markas.float>
<div class="{{ $copy }}">
<p class="{{ $count }}">2,400</p>
<p class="{{ $label }}">makers across Indonesia</p>
</div>
</div>import { Float } from "@/components/markas/Float";
const stage =
"relative grid h-72 place-items-center overflow-hidden rounded-xl border border-line bg-surface";
const layer = "absolute inset-0";
const avatarA =
"absolute top-[14%] left-[18%] grid size-12 place-items-center rounded-full bg-primary-soft text-sm font-semibold text-ink";
const avatarB =
"absolute top-[10%] right-[20%] grid size-10 place-items-center rounded-full bg-success/15 text-sm font-semibold text-ink";
const avatarC =
"absolute bottom-[16%] left-[12%] grid size-10 place-items-center rounded-full bg-warning/15 text-sm font-semibold text-ink";
const avatarD =
"absolute right-[14%] bottom-[18%] grid size-14 place-items-center rounded-full bg-primary text-sm font-semibold text-on-primary";
const avatarE =
"absolute top-[44%] right-[6%] grid size-9 place-items-center rounded-full bg-danger/10 text-xs font-semibold text-ink";
const copy = "relative text-center";
const count = "text-3xl font-semibold text-ink tabular-nums";
const label = "text-sm text-muted";
export default function Example() {
return (
<div className={stage}>
<Float
motion="orbit"
amplitude={8}
duration={9}
seed={2}
entrance={true}
aria-hidden="true"
className={layer}
>
<span className={avatarA}>RP</span>
<span className={avatarB}>BS</span>
<span className={avatarC}>SA</span>
<span className={avatarD}>DP</span>
<span className={avatarE}>NW</span>
</Float>
<div className={copy}>
<p className={count}>2,400</p>
<p className={label}>makers across Indonesia</p>
</div>
</div>
);
}<script setup lang="ts">
import Float from "@/components/markas/Float.vue";
const stage =
"relative grid h-72 place-items-center overflow-hidden rounded-xl border border-line bg-surface";
const layer = "absolute inset-0";
const avatarA =
"absolute top-[14%] left-[18%] grid size-12 place-items-center rounded-full bg-primary-soft text-sm font-semibold text-ink";
const avatarB =
"absolute top-[10%] right-[20%] grid size-10 place-items-center rounded-full bg-success/15 text-sm font-semibold text-ink";
const avatarC =
"absolute bottom-[16%] left-[12%] grid size-10 place-items-center rounded-full bg-warning/15 text-sm font-semibold text-ink";
const avatarD =
"absolute right-[14%] bottom-[18%] grid size-14 place-items-center rounded-full bg-primary text-sm font-semibold text-on-primary";
const avatarE =
"absolute top-[44%] right-[6%] grid size-9 place-items-center rounded-full bg-danger/10 text-xs font-semibold text-ink";
const copy = "relative text-center";
const count = "text-3xl font-semibold text-ink tabular-nums";
const label = "text-sm text-muted";
</script>
<template>
<div :class="stage">
<Float
motion="orbit"
:amplitude="8"
:duration="9"
:seed="2"
:entrance="true"
aria-hidden="true"
:class="layer"
>
<span :class="avatarA">RP</span>
<span :class="avatarB">BS</span>
<span :class="avatarC">SA</span>
<span :class="avatarD">DP</span>
<span :class="avatarE">NW</span>
</Float>
<div :class="copy">
<p :class="count">2,400</p>
<p :class="label">makers across Indonesia</p>
</div>
</div>
</template><script lang="ts">
import Float from "$lib/components/markas/Float.svelte";
const stage =
"relative grid h-72 place-items-center overflow-hidden rounded-xl border border-line bg-surface";
const layer = "absolute inset-0";
const avatarA =
"absolute top-[14%] left-[18%] grid size-12 place-items-center rounded-full bg-primary-soft text-sm font-semibold text-ink";
const avatarB =
"absolute top-[10%] right-[20%] grid size-10 place-items-center rounded-full bg-success/15 text-sm font-semibold text-ink";
const avatarC =
"absolute bottom-[16%] left-[12%] grid size-10 place-items-center rounded-full bg-warning/15 text-sm font-semibold text-ink";
const avatarD =
"absolute right-[14%] bottom-[18%] grid size-14 place-items-center rounded-full bg-primary text-sm font-semibold text-on-primary";
const avatarE =
"absolute top-[44%] right-[6%] grid size-9 place-items-center rounded-full bg-danger/10 text-xs font-semibold text-ink";
const copy = "relative text-center";
const count = "text-3xl font-semibold text-ink tabular-nums";
const label = "text-sm text-muted";
</script>
<div class={stage}>
<Float
motion="orbit"
amplitude={8}
duration={9}
seed={2}
entrance
aria-hidden="true"
class={layer}
>
<span class={avatarA}>RP</span>
<span class={avatarB}>BS</span>
<span class={avatarC}>SA</span>
<span class={avatarD}>DP</span>
<span class={avatarE}>NW</span>
</Float>
<div class={copy}>
<p class={count}>2,400</p>
<p class={label}>makers across Indonesia</p>
</div>
</div>---
import Float from "@/components/markas/Float.astro";
const stage =
"relative grid h-72 place-items-center overflow-hidden rounded-xl border border-line bg-surface";
const layer = "absolute inset-0";
const avatarA =
"absolute top-[14%] left-[18%] grid size-12 place-items-center rounded-full bg-primary-soft text-sm font-semibold text-ink";
const avatarB =
"absolute top-[10%] right-[20%] grid size-10 place-items-center rounded-full bg-success/15 text-sm font-semibold text-ink";
const avatarC =
"absolute bottom-[16%] left-[12%] grid size-10 place-items-center rounded-full bg-warning/15 text-sm font-semibold text-ink";
const avatarD =
"absolute right-[14%] bottom-[18%] grid size-14 place-items-center rounded-full bg-primary text-sm font-semibold text-on-primary";
const avatarE =
"absolute top-[44%] right-[6%] grid size-9 place-items-center rounded-full bg-danger/10 text-xs font-semibold text-ink";
const copy = "relative text-center";
const count = "text-3xl font-semibold text-ink tabular-nums";
const label = "text-sm text-muted";
---
<div class={stage}>
<Float
motion="orbit"
amplitude={8}
duration={9}
seed={2}
entrance
aria-hidden="true"
class={layer}
>
<span class={avatarA}>RP</span>
<span class={avatarB}>BS</span>
<span class={avatarC}>SA</span>
<span class={avatarD}>DP</span>
<span class={avatarE}>NW</span>
</Float>
<div class={copy}>
<p class={count}>2,400</p>
<p class={label}>makers across Indonesia</p>
</div>
</div>import { Component } from "@angular/core";
import { Float } from "./markas/float.component";
@Component({
selector: "markas-example",
imports: [Float],
template: `
<div [class]="stage">
<markas-float
motion="orbit"
[amplitude]="8"
[duration]="9"
[seed]="2"
entrance
aria-hidden="true"
[class]="layer"
>
<span [class]="avatarA">RP</span>
<span [class]="avatarB">BS</span>
<span [class]="avatarC">SA</span>
<span [class]="avatarD">DP</span>
<span [class]="avatarE">NW</span>
</markas-float>
<div [class]="copy">
<p [class]="count">2,400</p>
<p [class]="label">makers across Indonesia</p>
</div>
</div>
`,
})
export default class FloatOrbitExample {
protected readonly stage =
"relative grid h-72 place-items-center overflow-hidden rounded-xl border border-line bg-surface";
protected readonly layer = "absolute inset-0";
protected readonly avatarA =
"absolute top-[14%] left-[18%] grid size-12 place-items-center rounded-full bg-primary-soft text-sm font-semibold text-ink";
protected readonly avatarB =
"absolute top-[10%] right-[20%] grid size-10 place-items-center rounded-full bg-success/15 text-sm font-semibold text-ink";
protected readonly avatarC =
"absolute bottom-[16%] left-[12%] grid size-10 place-items-center rounded-full bg-warning/15 text-sm font-semibold text-ink";
protected readonly avatarD =
"absolute right-[14%] bottom-[18%] grid size-14 place-items-center rounded-full bg-primary text-sm font-semibold text-on-primary";
protected readonly avatarE =
"absolute top-[44%] right-[6%] grid size-9 place-items-center rounded-full bg-danger/10 text-xs font-semibold text-ink";
protected readonly copy = "relative text-center";
protected readonly count = "text-3xl font-semibold text-ink tabular-nums";
protected readonly label = "text-sm text-muted";
}Ikon bernapas di footer
@php
$footer = 'flex items-center justify-between gap-4 rounded-xl border border-line bg-surface px-5 py-4';
$text = 'text-sm text-muted';
$strong = 'font-medium text-ink';
$row = 'flex items-center gap-2';
$dot = 'grid size-9 place-items-center rounded-full bg-subtle text-ink';
$icon = 'size-5';
@endphp
<footer class="{{ $footer }}">
<p class="{{ $text }}"><span class="{{ $strong }}">MarkasUI</span> made in Bandung</p>
<x-markas.float motion="breathe" :amplitude="12" :duration="4" aria-hidden="true" :class="$row">
<span class="{{ $dot }}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="{{ $icon }}"><path d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10Z"></path></svg></span>
<span class="{{ $dot }}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="{{ $icon }}"><path d="M5 8h11v5a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5V8Z"></path><path d="M16 10h1.5a2.5 2.5 0 0 1 0 5H16"></path><path d="M8 3v2"></path><path d="M12 3v2"></path></svg></span>
<span class="{{ $dot }}"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="{{ $icon }}"><path d="M12 21s6-5.3 6-11a6 6 0 0 0-12 0c0 5.7 6 11 6 11Z"></path><path d="M12 12a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"></path></svg></span>
</x-markas.float>
</footer>import { Float } from "@/components/markas/Float";
const footer =
"flex items-center justify-between gap-4 rounded-xl border border-line bg-surface px-5 py-4";
const text = "text-sm text-muted";
const strong = "font-medium text-ink";
const row = "flex items-center gap-2";
const dot = "grid size-9 place-items-center rounded-full bg-subtle text-ink";
const icon = "size-5";
export default function Example() {
return (
<footer className={footer}>
<p className={text}>
<span className={strong}>MarkasUI</span> made in Bandung
</p>
<Float
motion="breathe"
amplitude={12}
duration={4}
aria-hidden="true"
className={row}
>
<span className={dot}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
className={icon}
>
<path d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10Z"></path>
</svg>
</span>
<span className={dot}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
className={icon}
>
<path d="M5 8h11v5a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5V8Z"></path>
<path d="M16 10h1.5a2.5 2.5 0 0 1 0 5H16"></path>
<path d="M8 3v2"></path>
<path d="M12 3v2"></path>
</svg>
</span>
<span className={dot}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
className={icon}
>
<path d="M12 21s6-5.3 6-11a6 6 0 0 0-12 0c0 5.7 6 11 6 11Z"></path>
<path d="M12 12a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"></path>
</svg>
</span>
</Float>
</footer>
);
}<script setup lang="ts">
import Float from "@/components/markas/Float.vue";
const footer =
"flex items-center justify-between gap-4 rounded-xl border border-line bg-surface px-5 py-4";
const text = "text-sm text-muted";
const strong = "font-medium text-ink";
const row = "flex items-center gap-2";
const dot = "grid size-9 place-items-center rounded-full bg-subtle text-ink";
const icon = "size-5";
</script>
<template>
<footer :class="footer">
<p :class="text"><span :class="strong">MarkasUI</span> made in Bandung</p>
<Float
motion="breathe"
:amplitude="12"
:duration="4"
aria-hidden="true"
:class="row"
>
<span :class="dot"
><svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
:class="icon"
>
<path
d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10Z"
></path></svg
></span>
<span :class="dot"
><svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
:class="icon"
>
<path d="M5 8h11v5a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5V8Z"></path>
<path d="M16 10h1.5a2.5 2.5 0 0 1 0 5H16"></path>
<path d="M8 3v2"></path>
<path d="M12 3v2"></path></svg
></span>
<span :class="dot"
><svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
:class="icon"
>
<path d="M12 21s6-5.3 6-11a6 6 0 0 0-12 0c0 5.7 6 11 6 11Z"></path>
<path d="M12 12a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"></path></svg
></span>
</Float>
</footer>
</template><script lang="ts">
import Float from "$lib/components/markas/Float.svelte";
const footer =
"flex items-center justify-between gap-4 rounded-xl border border-line bg-surface px-5 py-4";
const text = "text-sm text-muted";
const strong = "font-medium text-ink";
const row = "flex items-center gap-2";
const dot = "grid size-9 place-items-center rounded-full bg-subtle text-ink";
const icon = "size-5";
</script>
<footer class={footer}>
<p class={text}>
<span class={strong}>MarkasUI</span> made in Bandung
</p>
<Float
motion="breathe"
amplitude={12}
duration={4}
aria-hidden="true"
class={row}
>
<span class={dot}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path
d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10Z"
/>
</svg>
</span>
<span class={dot}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="M5 8h11v5a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5V8Z" />
<path d="M16 10h1.5a2.5 2.5 0 0 1 0 5H16" />
<path d="M8 3v2" />
<path d="M12 3v2" />
</svg>
</span>
<span class={dot}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="M12 21s6-5.3 6-11a6 6 0 0 0-12 0c0 5.7 6 11 6 11Z" />
<path d="M12 12a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z" />
</svg>
</span>
</Float>
</footer>---
import Float from "@/components/markas/Float.astro";
const footer =
"flex items-center justify-between gap-4 rounded-xl border border-line bg-surface px-5 py-4";
const text = "text-sm text-muted";
const strong = "font-medium text-ink";
const row = "flex items-center gap-2";
const dot = "grid size-9 place-items-center rounded-full bg-subtle text-ink";
const icon = "size-5";
---
<footer class={footer}>
<p class={text}>
<span class={strong}>MarkasUI</span> made in Bandung
</p>
<Float
motion="breathe"
amplitude={12}
duration={4}
aria-hidden="true"
class={row}
>
<span class={dot}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10Z" />
</svg>
</span>
<span class={dot}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="M5 8h11v5a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5V8Z" />
<path d="M16 10h1.5a2.5 2.5 0 0 1 0 5H16" />
<path d="M8 3v2" />
<path d="M12 3v2" />
</svg>
</span>
<span class={dot}>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class={icon}
>
<path d="M12 21s6-5.3 6-11a6 6 0 0 0-12 0c0 5.7 6 11 6 11Z" />
<path d="M12 12a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z" />
</svg>
</span>
</Float>
</footer>import { Component } from "@angular/core";
import { Float } from "./markas/float.component";
@Component({
selector: "markas-example",
imports: [Float],
template: `
<footer [class]="footer">
<p [class]="text">
<span [class]="strong">MarkasUI</span> made in Bandung
</p>
<markas-float
motion="breathe"
[amplitude]="12"
[duration]="4"
aria-hidden="true"
[class]="row"
>
<span [class]="dot">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
[class]="icon"
>
<path
d="M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10Z"
/>
</svg>
</span>
<span [class]="dot">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
[class]="icon"
>
<path d="M5 8h11v5a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5V8Z" />
<path d="M16 10h1.5a2.5 2.5 0 0 1 0 5H16" />
<path d="M8 3v2" />
<path d="M12 3v2" />
</svg>
</span>
<span [class]="dot">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
[class]="icon"
>
<path d="M12 21s6-5.3 6-11a6 6 0 0 0-12 0c0 5.7 6 11 6 11Z" />
<path d="M12 12a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z" />
</svg>
</span>
</markas-float>
</footer>
`,
})
export default class FloatFooterExample {
protected readonly footer =
"flex items-center justify-between gap-4 rounded-xl border border-line bg-surface px-5 py-4";
protected readonly text = "text-sm text-muted";
protected readonly strong = "font-medium text-ink";
protected readonly row = "flex items-center gap-2";
protected readonly dot =
"grid size-9 place-items-center rounded-full bg-subtle text-ink";
protected readonly icon = "size-5";
}Instalasi
npx markasui@latest add floatpnpm dlx markasui@latest add floatyarn dlx markasui@latest add floatbunx --bun markasui@latest add float- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Pasang dependensi:
npm install alpinejs - Salin source komponen di bawah ini ke
resources/views/components/markas/float.blade.php.
@props([
'motion' => 'drift',
'amplitude' => 10,
'duration' => 6,
'seed' => 1,
'parallax' => 0,
'entrance' => false,
])
@php
$base = '[&>*]:transition-[translate] [&>*]:duration-700 [&>*]:ease-out motion-reduce:[&>*]:transition-none';
@endphp
{{-- Floats each child on its own loop, pauses one while it is hovered or focused, and pauses all when off screen. With parallax, children shift toward the pointer by their depth. --}}
<div
x-data="{
stop: null,
init() {
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const o = { motion: @js($motion), amplitude: @js((float) $amplitude), duration: @js((float) $duration), seed: @js((float) $seed), parallax: @js((float) $parallax), entrance: @js((bool) $entrance) };
const root = this.$el;
const turn = Math.PI * 2;
const rand = (seed, n) => {
const x = Math.sin(seed * 78.233 + n * 12.9898) * 43758.5453;
return x - Math.floor(x);
};
const paths = {
drift: (t, a) => [a * 0.6 * Math.sin(turn * t), a * 0.5 * Math.sin(turn * 2 * t), a * 0.3 * Math.sin(turn * t), 1],
bob: (t, a) => [0, (-a * (1 - Math.cos(turn * t))) / 2, 0, 1],
orbit: (t, a) => [a * Math.cos(turn * t), a * Math.sin(turn * t), 0, 1],
breathe: (t, a) => {
const k = (1 - Math.cos(turn * t)) / 2;
return [0, -a * 0.3 * k, 0, 1 + (a / 100) * k];
},
};
const items = [...root.children];
const path = paths[o.motion] ?? paths.drift;
const loops = items.map((el, i) => {
const amp = o.amplitude * (0.7 + 0.6 * rand(o.seed, i * 4));
const sign = rand(o.seed, i * 4 + 1) < 0.5 ? -1 : 1;
const ms = o.duration * 1000 * (0.8 + 0.4 * rand(o.seed, i * 4 + 2));
const frames = Array.from({ length: 13 }, (_, s) => {
const [x, y, r, k] = path(s / 12, amp);
return { transform: `translate(${x * sign}px, ${y}px) rotate(${r * sign}deg) scale(${k})` };
});
return el.animate?.(frames, { duration: ms, delay: -rand(o.seed, i * 4 + 3) * ms, iterations: Infinity });
});
const held = new Set();
let hidden = false;
let entered = ! o.entrance;
{{-- Rise in one after another the first time the group scrolls into view. --}}
const enter = () => {
entered = true;
items.forEach((el, i) => el.animate?.(
[{ opacity: 0, scale: 0.6 }, { opacity: 1, scale: 1 }],
{ duration: 600, delay: i * 90, easing: 'cubic-bezier(0.34, 1.56, 0.64, 1)', fill: 'backwards' },
));
};
const sync = () => loops.forEach((loop, i) => (hidden || held.has(i) ? loop?.pause() : loop?.play()));
const hold = (on) => (e) => {
const i = items.findIndex((el) => el.contains(e.target));
if (i < 0 || (! on && items[i].contains(e.relatedTarget))) return;
if (on) held.add(i);
else held.delete(i);
sync();
};
const pointer = (e) => {
const r = root.getBoundingClientRect();
const nx = Math.max(-1, Math.min(1, ((e.clientX - r.left) / r.width) * 2 - 1));
const ny = Math.max(-1, Math.min(1, ((e.clientY - r.top) / r.height) * 2 - 1));
items.forEach((el, i) => {
const depth = Number(el.dataset.depth ?? 0.3 + 0.7 * rand(o.seed, i * 4 + 1));
el.style.translate = `${nx * depth * o.parallax}px ${ny * depth * o.parallax}px`;
});
};
const observer = typeof IntersectionObserver === 'undefined' ? null : new IntersectionObserver(([entry]) => {
hidden = ! entry?.isIntersecting;
if (! hidden && ! entered) enter();
sync();
if (! o.parallax) return;
if (hidden) removeEventListener('pointermove', pointer);
else addEventListener('pointermove', pointer);
});
if (observer) observer.observe(root);
else {
if (! entered) enter();
if (o.parallax) addEventListener('pointermove', pointer);
}
const listeners = [['pointerover', hold(true)], ['pointerout', hold(false)], ['focusin', hold(true)], ['focusout', hold(false)]];
for (const [type, fn] of listeners) root.addEventListener(type, fn);
this.stop = () => {
observer?.disconnect();
removeEventListener('pointermove', pointer);
for (const [type, fn] of listeners) root.removeEventListener(type, fn);
for (const loop of loops) loop?.cancel();
for (const el of items) el.style.translate = '';
};
},
destroy() {
this.stop?.();
},
}"
{{ $attributes->class([$base]) }}
>
{{ $slot }}
</div>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/Float.tsx.
"use client";
import { useEffect, useRef, type ComponentProps } from "react";
const base =
"[&>*]:transition-[translate] [&>*]:duration-700 [&>*]:ease-out motion-reduce:[&>*]:transition-none";
export type FloatMotion = "drift" | "bob" | "orbit" | "breathe";
type Options = {
motion: FloatMotion;
amplitude: number;
duration: number;
seed: number;
parallax: number;
entrance: boolean;
};
const STEPS = 12;
const TURN = Math.PI * 2;
const MS = 1000;
const STAGGER_MS = 90;
const ENTRANCE_MS = 600;
/** One loop of each motion: phase t (0 to 1) and amplitude a give x, y (px), rotation (deg), and scale. */
const PATHS: Record<FloatMotion, (t: number, a: number) => number[]> = {
drift: (t, a) => [
a * 0.6 * Math.sin(TURN * t),
a * 0.5 * Math.sin(TURN * 2 * t),
a * 0.3 * Math.sin(TURN * t),
1,
],
bob: (t, a) => [0, (-a * (1 - Math.cos(TURN * t))) / 2, 0, 1],
orbit: (t, a) => [a * Math.cos(TURN * t), a * Math.sin(TURN * t), 0, 1],
breathe: (t, a) => {
const k = (1 - Math.cos(TURN * t)) / 2;
return [0, -a * 0.3 * k, 0, 1 + (a / 100) * k];
},
};
const cx = (...c: (string | false | null | undefined)[]) =>
c.filter(Boolean).join(" ");
/** Same number for the same seed and index in every framework. */
const rand = (seed: number, n: number) => {
const x = Math.sin(seed * 78.233 + n * 12.9898) * 43758.5453;
return x - Math.floor(x);
};
const still = () =>
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
/**
* Float each child on its own loop, pause one while it is hovered or focused, and pause all
* when off screen. With parallax, children shift toward the pointer by their depth.
*/
export function startFloat(root: HTMLElement, o: Options) {
const items = [...root.children] as HTMLElement[];
const path = PATHS[o.motion] ?? PATHS.drift;
const loops = items.map((el, i) => {
const amp = o.amplitude * (0.7 + 0.6 * rand(o.seed, i * 4));
const sign = rand(o.seed, i * 4 + 1) < 0.5 ? -1 : 1;
const ms = o.duration * MS * (0.8 + 0.4 * rand(o.seed, i * 4 + 2));
const frames = Array.from({ length: STEPS + 1 }, (_, s) => {
const [x, y, r, k] = path(s / STEPS, amp);
return {
transform: `translate(${x! * sign}px, ${y}px) rotate(${r! * sign}deg) scale(${k})`,
};
});
return el.animate?.(frames, {
duration: ms,
delay: -rand(o.seed, i * 4 + 3) * ms,
iterations: Infinity,
});
});
const held = new Set<number>();
let hidden = false;
let entered = !o.entrance;
/** Rise in one after another the first time the group scrolls into view. */
const enter = () => {
entered = true;
items.forEach((el, i) =>
el.animate?.(
[
{ opacity: 0, scale: 0.6 },
{ opacity: 1, scale: 1 },
],
{
duration: ENTRANCE_MS,
delay: i * STAGGER_MS,
easing: "cubic-bezier(0.34, 1.56, 0.64, 1)",
fill: "backwards",
},
),
);
};
const sync = () =>
loops.forEach((loop, i) =>
hidden || held.has(i) ? loop?.pause() : loop?.play(),
);
const hold = (on: boolean) => (e: Event) => {
const i = items.findIndex((el) => el.contains(e.target as Node));
const to = (e as FocusEvent).relatedTarget as Node | null;
if (i < 0 || (!on && items[i]!.contains(to))) return;
if (on) held.add(i);
else held.delete(i);
sync();
};
const pointer = (e: PointerEvent) => {
const r = root.getBoundingClientRect();
const nx = Math.max(
-1,
Math.min(1, ((e.clientX - r.left) / r.width) * 2 - 1),
);
const ny = Math.max(
-1,
Math.min(1, ((e.clientY - r.top) / r.height) * 2 - 1),
);
items.forEach((el, i) => {
const depth = Number(
el.dataset.depth ?? 0.3 + 0.7 * rand(o.seed, i * 4 + 1),
);
el.style.translate = `${nx * depth * o.parallax}px ${ny * depth * o.parallax}px`;
});
};
const observer =
typeof IntersectionObserver === "undefined"
? undefined
: new IntersectionObserver(([entry]) => {
hidden = !entry?.isIntersecting;
if (!hidden && !entered) enter();
sync();
if (!o.parallax) return;
if (hidden) removeEventListener("pointermove", pointer);
else addEventListener("pointermove", pointer);
});
if (observer) observer.observe(root);
else {
if (!entered) enter();
if (o.parallax) addEventListener("pointermove", pointer);
}
const listeners = [
["pointerover", hold(true)],
["pointerout", hold(false)],
["focusin", hold(true)],
["focusout", hold(false)],
] as [string, (e: Event) => void][];
for (const [type, fn] of listeners) root.addEventListener(type, fn);
return () => {
observer?.disconnect();
removeEventListener("pointermove", pointer);
for (const [type, fn] of listeners) root.removeEventListener(type, fn);
for (const loop of loops) loop?.cancel();
for (const el of items) el.style.translate = "";
};
}
export type FloatProps = ComponentProps<"div"> & {
/** Path each child follows: wander, rise and fall, circle, or swell. */
motion?: FloatMotion;
/** Distance in px each child travels, varied a little per child. For breathe, also the growth in percent. */
amplitude?: number;
/** Seconds for one loop, varied a little per child. */
duration?: number;
/** Changes the per-child timing, size, and direction. */
seed?: number;
/** Largest shift in px toward the pointer. 0 turns it off. */
parallax?: number;
/** Children pop in one after another the first time the group scrolls into view. */
entrance?: boolean;
};
export function Float({
motion = "drift",
amplitude = 10,
duration = 6,
seed = 1,
parallax = 0,
entrance = false,
className,
children,
...props
}: FloatProps) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!ref.current || still()) return;
return startFloat(ref.current, {
motion,
amplitude,
duration,
seed,
parallax,
entrance,
});
}, [motion, amplitude, duration, seed, parallax, entrance]);
return (
<div ref={ref} {...props} className={cx(base, className)}>
{children}
</div>
);
}- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/Float.vue.
<script setup lang="ts">
import { onBeforeUnmount, onMounted, useTemplateRef, watch } from "vue";
const props = withDefaults(
defineProps<{
/** Path each child follows: wander, rise and fall, circle, or swell. */
motion?: "drift" | "bob" | "orbit" | "breathe";
/** Distance in px each child travels, varied a little per child. For breathe, also the growth in percent. */
amplitude?: number;
/** Seconds for one loop, varied a little per child. */
duration?: number;
/** Changes the per-child timing, size, and direction. */
seed?: number;
/** Largest shift in px toward the pointer. 0 turns it off. */
parallax?: number;
/** Children pop in one after another the first time the group scrolls into view. */
entrance?: boolean;
}>(),
{
motion: "drift",
amplitude: 10,
duration: 6,
seed: 1,
parallax: 0,
entrance: false,
},
);
const base =
"[&>*]:transition-[translate] [&>*]:duration-700 [&>*]:ease-out motion-reduce:[&>*]:transition-none";
type FloatMotion = "drift" | "bob" | "orbit" | "breathe";
type Options = {
motion: FloatMotion;
amplitude: number;
duration: number;
seed: number;
parallax: number;
entrance: boolean;
};
const STEPS = 12;
const TURN = Math.PI * 2;
const MS = 1000;
const STAGGER_MS = 90;
const ENTRANCE_MS = 600;
/** One loop of each motion: phase t (0 to 1) and amplitude a give x, y (px), rotation (deg), and scale. */
const PATHS: Record<FloatMotion, (t: number, a: number) => number[]> = {
drift: (t, a) => [
a * 0.6 * Math.sin(TURN * t),
a * 0.5 * Math.sin(TURN * 2 * t),
a * 0.3 * Math.sin(TURN * t),
1,
],
bob: (t, a) => [0, (-a * (1 - Math.cos(TURN * t))) / 2, 0, 1],
orbit: (t, a) => [a * Math.cos(TURN * t), a * Math.sin(TURN * t), 0, 1],
breathe: (t, a) => {
const k = (1 - Math.cos(TURN * t)) / 2;
return [0, -a * 0.3 * k, 0, 1 + (a / 100) * k];
},
};
/** Same number for the same seed and index in every framework. */
const rand = (seed: number, n: number) => {
const x = Math.sin(seed * 78.233 + n * 12.9898) * 43758.5453;
return x - Math.floor(x);
};
const still = () =>
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
/**
* Float each child on its own loop, pause one while it is hovered or focused, and pause all
* when off screen. With parallax, children shift toward the pointer by their depth.
*/
function startFloat(root: HTMLElement, o: Options) {
const items = [...root.children] as HTMLElement[];
const path = PATHS[o.motion] ?? PATHS.drift;
const loops = items.map((el, i) => {
const amp = o.amplitude * (0.7 + 0.6 * rand(o.seed, i * 4));
const sign = rand(o.seed, i * 4 + 1) < 0.5 ? -1 : 1;
const ms = o.duration * MS * (0.8 + 0.4 * rand(o.seed, i * 4 + 2));
const frames = Array.from({ length: STEPS + 1 }, (_, s) => {
const [x, y, r, k] = path(s / STEPS, amp);
return {
transform: `translate(${x! * sign}px, ${y}px) rotate(${r! * sign}deg) scale(${k})`,
};
});
return el.animate?.(frames, {
duration: ms,
delay: -rand(o.seed, i * 4 + 3) * ms,
iterations: Infinity,
});
});
const held = new Set<number>();
let hidden = false;
let entered = !o.entrance;
/** Rise in one after another the first time the group scrolls into view. */
const enter = () => {
entered = true;
items.forEach((el, i) =>
el.animate?.(
[
{ opacity: 0, scale: 0.6 },
{ opacity: 1, scale: 1 },
],
{
duration: ENTRANCE_MS,
delay: i * STAGGER_MS,
easing: "cubic-bezier(0.34, 1.56, 0.64, 1)",
fill: "backwards",
},
),
);
};
const sync = () =>
loops.forEach((loop, i) =>
hidden || held.has(i) ? loop?.pause() : loop?.play(),
);
const hold = (on: boolean) => (e: Event) => {
const i = items.findIndex((el) => el.contains(e.target as Node));
const to = (e as FocusEvent).relatedTarget as Node | null;
if (i < 0 || (!on && items[i]!.contains(to))) return;
if (on) held.add(i);
else held.delete(i);
sync();
};
const pointer = (e: PointerEvent) => {
const r = root.getBoundingClientRect();
const nx = Math.max(
-1,
Math.min(1, ((e.clientX - r.left) / r.width) * 2 - 1),
);
const ny = Math.max(
-1,
Math.min(1, ((e.clientY - r.top) / r.height) * 2 - 1),
);
items.forEach((el, i) => {
const depth = Number(
el.dataset.depth ?? 0.3 + 0.7 * rand(o.seed, i * 4 + 1),
);
el.style.translate = `${nx * depth * o.parallax}px ${ny * depth * o.parallax}px`;
});
};
const observer =
typeof IntersectionObserver === "undefined"
? undefined
: new IntersectionObserver(([entry]) => {
hidden = !entry?.isIntersecting;
if (!hidden && !entered) enter();
sync();
if (!o.parallax) return;
if (hidden) removeEventListener("pointermove", pointer);
else addEventListener("pointermove", pointer);
});
if (observer) observer.observe(root);
else {
if (!entered) enter();
if (o.parallax) addEventListener("pointermove", pointer);
}
const listeners = [
["pointerover", hold(true)],
["pointerout", hold(false)],
["focusin", hold(true)],
["focusout", hold(false)],
] as [string, (e: Event) => void][];
for (const [type, fn] of listeners) root.addEventListener(type, fn);
return () => {
observer?.disconnect();
removeEventListener("pointermove", pointer);
for (const [type, fn] of listeners) root.removeEventListener(type, fn);
for (const loop of loops) loop?.cancel();
for (const el of items) el.style.translate = "";
};
}
const rootEl = useTemplateRef<HTMLDivElement>("rootRef");
let stop = () => {};
function start() {
stop();
stop = () => {};
if (rootEl.value && !still()) stop = startFloat(rootEl.value, { ...props });
}
onMounted(start);
watch(() => ({ ...props }), start, { flush: "post" });
onBeforeUnmount(() => stop());
</script>
<template>
<div ref="rootRef" :class="base">
<slot />
</div>
</template>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/lib/components/markas/Float.svelte.
<script lang="ts" module>
export type FloatMotion = "drift" | "bob" | "orbit" | "breathe";
type Options = {
motion: FloatMotion;
amplitude: number;
duration: number;
seed: number;
parallax: number;
entrance: boolean;
};
const STEPS = 12;
const TURN = Math.PI * 2;
const MS = 1000;
const STAGGER_MS = 90;
const ENTRANCE_MS = 600;
/** One loop of each motion: phase t (0 to 1) and amplitude a give x, y (px), rotation (deg), and scale. */
const PATHS: Record<FloatMotion, (t: number, a: number) => number[]> = {
drift: (t, a) => [
a * 0.6 * Math.sin(TURN * t),
a * 0.5 * Math.sin(TURN * 2 * t),
a * 0.3 * Math.sin(TURN * t),
1,
],
bob: (t, a) => [0, (-a * (1 - Math.cos(TURN * t))) / 2, 0, 1],
orbit: (t, a) => [a * Math.cos(TURN * t), a * Math.sin(TURN * t), 0, 1],
breathe: (t, a) => {
const k = (1 - Math.cos(TURN * t)) / 2;
return [0, -a * 0.3 * k, 0, 1 + (a / 100) * k];
},
};
/** Same number for the same seed and index in every framework. */
const rand = (seed: number, n: number) => {
const x = Math.sin(seed * 78.233 + n * 12.9898) * 43758.5453;
return x - Math.floor(x);
};
const still = () =>
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
/**
* Float each child on its own loop, pause one while it is hovered or focused, and pause all
* when off screen. With parallax, children shift toward the pointer by their depth.
*/
export function startFloat(root: HTMLElement, o: Options) {
const items = [...root.children] as HTMLElement[];
const path = PATHS[o.motion] ?? PATHS.drift;
const loops = items.map((el, i) => {
const amp = o.amplitude * (0.7 + 0.6 * rand(o.seed, i * 4));
const sign = rand(o.seed, i * 4 + 1) < 0.5 ? -1 : 1;
const ms = o.duration * MS * (0.8 + 0.4 * rand(o.seed, i * 4 + 2));
const frames = Array.from({ length: STEPS + 1 }, (_, s) => {
const [x, y, r, k] = path(s / STEPS, amp);
return {
transform: `translate(${x! * sign}px, ${y}px) rotate(${r! * sign}deg) scale(${k})`,
};
});
return el.animate?.(frames, {
duration: ms,
delay: -rand(o.seed, i * 4 + 3) * ms,
iterations: Infinity,
});
});
const held = new Set<number>();
let hidden = false;
let entered = !o.entrance;
/** Rise in one after another the first time the group scrolls into view. */
const enter = () => {
entered = true;
items.forEach((el, i) =>
el.animate?.(
[
{ opacity: 0, scale: 0.6 },
{ opacity: 1, scale: 1 },
],
{
duration: ENTRANCE_MS,
delay: i * STAGGER_MS,
easing: "cubic-bezier(0.34, 1.56, 0.64, 1)",
fill: "backwards",
},
),
);
};
const sync = () =>
loops.forEach((loop, i) =>
hidden || held.has(i) ? loop?.pause() : loop?.play(),
);
const hold = (on: boolean) => (e: Event) => {
const i = items.findIndex((el) => el.contains(e.target as Node));
const to = (e as FocusEvent).relatedTarget as Node | null;
if (i < 0 || (!on && items[i]!.contains(to))) return;
if (on) held.add(i);
else held.delete(i);
sync();
};
const pointer = (e: PointerEvent) => {
const r = root.getBoundingClientRect();
const nx = Math.max(
-1,
Math.min(1, ((e.clientX - r.left) / r.width) * 2 - 1),
);
const ny = Math.max(
-1,
Math.min(1, ((e.clientY - r.top) / r.height) * 2 - 1),
);
items.forEach((el, i) => {
const depth = Number(
el.dataset.depth ?? 0.3 + 0.7 * rand(o.seed, i * 4 + 1),
);
el.style.translate = `${nx * depth * o.parallax}px ${ny * depth * o.parallax}px`;
});
};
const observer =
typeof IntersectionObserver === "undefined"
? undefined
: new IntersectionObserver(([entry]) => {
hidden = !entry?.isIntersecting;
if (!hidden && !entered) enter();
sync();
if (!o.parallax) return;
if (hidden) removeEventListener("pointermove", pointer);
else addEventListener("pointermove", pointer);
});
if (observer) observer.observe(root);
else {
if (!entered) enter();
if (o.parallax) addEventListener("pointermove", pointer);
}
const listeners = [
["pointerover", hold(true)],
["pointerout", hold(false)],
["focusin", hold(true)],
["focusout", hold(false)],
] as [string, (e: Event) => void][];
for (const [type, fn] of listeners) root.addEventListener(type, fn);
return () => {
observer?.disconnect();
removeEventListener("pointermove", pointer);
for (const [type, fn] of listeners) root.removeEventListener(type, fn);
for (const loop of loops) loop?.cancel();
for (const el of items) el.style.translate = "";
};
}
</script>
<script lang="ts">
import type { Snippet } from "svelte";
import type { HTMLAttributes } from "svelte/elements";
const base =
"[&>*]:transition-[translate] [&>*]:duration-700 [&>*]:ease-out motion-reduce:[&>*]:transition-none";
type Props = HTMLAttributes<HTMLDivElement> & {
/** Path each child follows: wander, rise and fall, circle, or swell. */
motion?: FloatMotion;
/** Distance in px each child travels, varied a little per child. For breathe, also the growth in percent. */
amplitude?: number;
/** Seconds for one loop, varied a little per child. */
duration?: number;
/** Changes the per-child timing, size, and direction. */
seed?: number;
/** Largest shift in px toward the pointer. 0 turns it off. */
parallax?: number;
/** Children pop in one after another the first time the group scrolls into view. */
entrance?: boolean;
children?: Snippet;
};
let {
motion = "drift",
amplitude = 10,
duration = 6,
seed = 1,
parallax = 0,
entrance = false,
class: className,
children,
...rest
}: Props = $props();
let rootEl = $state<HTMLDivElement>();
$effect(() => {
if (!rootEl || still()) return;
return startFloat(rootEl, {
motion,
amplitude,
duration,
seed,
parallax,
entrance,
});
});
</script>
<div bind:this={rootEl} {...rest} class={[base, className]}>
{@render children?.()}
</div>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/Float.astro.
---
import type { HTMLAttributes } from "astro/types";
const base =
"[&>*]:transition-[translate] [&>*]:duration-700 [&>*]:ease-out motion-reduce:[&>*]:transition-none";
export type FloatMotion = "drift" | "bob" | "orbit" | "breathe";
type Props = HTMLAttributes<"div"> & {
/** Path each child follows: wander, rise and fall, circle, or swell. */
motion?: FloatMotion;
/** Distance in px each child travels, varied a little per child. For breathe, also the growth in percent. */
amplitude?: number;
/** Seconds for one loop, varied a little per child. */
duration?: number;
/** Changes the per-child timing, size, and direction. */
seed?: number;
/** Largest shift in px toward the pointer. 0 turns it off. */
parallax?: number;
/** Children pop in one after another the first time the group scrolls into view. */
entrance?: boolean;
};
const {
motion = "drift",
amplitude = 10,
duration = 6,
seed = 1,
parallax = 0,
entrance = false,
class: className,
...rest
} = Astro.props;
---
<markas-float
class="contents"
data-motion={motion}
data-amplitude={amplitude}
data-duration={duration}
data-seed={seed}
data-parallax={parallax}
data-entrance={entrance ? "" : undefined}
>
<div {...rest} class:list={[base, className]}>
<slot />
</div>
</markas-float>
<script>
type FloatMotion = "drift" | "bob" | "orbit" | "breathe";
type Options = {
motion: FloatMotion;
amplitude: number;
duration: number;
seed: number;
parallax: number;
entrance: boolean;
};
const STEPS = 12;
const TURN = Math.PI * 2;
const MS = 1000;
const STAGGER_MS = 90;
const ENTRANCE_MS = 600;
/** One loop of each motion: phase t (0 to 1) and amplitude a give x, y (px), rotation (deg), and scale. */
const PATHS: Record<FloatMotion, (t: number, a: number) => number[]> = {
drift: (t, a) => [
a * 0.6 * Math.sin(TURN * t),
a * 0.5 * Math.sin(TURN * 2 * t),
a * 0.3 * Math.sin(TURN * t),
1,
],
bob: (t, a) => [0, (-a * (1 - Math.cos(TURN * t))) / 2, 0, 1],
orbit: (t, a) => [a * Math.cos(TURN * t), a * Math.sin(TURN * t), 0, 1],
breathe: (t, a) => {
const k = (1 - Math.cos(TURN * t)) / 2;
return [0, -a * 0.3 * k, 0, 1 + (a / 100) * k];
},
};
/** Same number for the same seed and index in every framework. */
const rand = (seed: number, n: number) => {
const x = Math.sin(seed * 78.233 + n * 12.9898) * 43758.5453;
return x - Math.floor(x);
};
const still = () =>
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
/**
* Float each child on its own loop, pause one while it is hovered or focused, and pause all
* when off screen. With parallax, children shift toward the pointer by their depth.
*/
function startFloat(root: HTMLElement, o: Options) {
const items = [...root.children] as HTMLElement[];
const path = PATHS[o.motion] ?? PATHS.drift;
const loops = items.map((el, i) => {
const amp = o.amplitude * (0.7 + 0.6 * rand(o.seed, i * 4));
const sign = rand(o.seed, i * 4 + 1) < 0.5 ? -1 : 1;
const ms = o.duration * MS * (0.8 + 0.4 * rand(o.seed, i * 4 + 2));
const frames = Array.from({ length: STEPS + 1 }, (_, s) => {
const [x, y, r, k] = path(s / STEPS, amp);
return {
transform: `translate(${x! * sign}px, ${y}px) rotate(${r! * sign}deg) scale(${k})`,
};
});
return el.animate?.(frames, {
duration: ms,
delay: -rand(o.seed, i * 4 + 3) * ms,
iterations: Infinity,
});
});
const held = new Set<number>();
let hidden = false;
let entered = !o.entrance;
/** Rise in one after another the first time the group scrolls into view. */
const enter = () => {
entered = true;
items.forEach((el, i) =>
el.animate?.(
[
{ opacity: 0, scale: 0.6 },
{ opacity: 1, scale: 1 },
],
{
duration: ENTRANCE_MS,
delay: i * STAGGER_MS,
easing: "cubic-bezier(0.34, 1.56, 0.64, 1)",
fill: "backwards",
},
),
);
};
const sync = () =>
loops.forEach((loop, i) =>
hidden || held.has(i) ? loop?.pause() : loop?.play(),
);
const hold = (on: boolean) => (e: Event) => {
const i = items.findIndex((el) => el.contains(e.target as Node));
const to = (e as FocusEvent).relatedTarget as Node | null;
if (i < 0 || (!on && items[i]!.contains(to))) return;
if (on) held.add(i);
else held.delete(i);
sync();
};
const pointer = (e: PointerEvent) => {
const r = root.getBoundingClientRect();
const nx = Math.max(
-1,
Math.min(1, ((e.clientX - r.left) / r.width) * 2 - 1),
);
const ny = Math.max(
-1,
Math.min(1, ((e.clientY - r.top) / r.height) * 2 - 1),
);
items.forEach((el, i) => {
const depth = Number(
el.dataset.depth ?? 0.3 + 0.7 * rand(o.seed, i * 4 + 1),
);
el.style.translate = `${nx * depth * o.parallax}px ${ny * depth * o.parallax}px`;
});
};
const observer =
typeof IntersectionObserver === "undefined"
? undefined
: new IntersectionObserver(([entry]) => {
hidden = !entry?.isIntersecting;
if (!hidden && !entered) enter();
sync();
if (!o.parallax) return;
if (hidden) removeEventListener("pointermove", pointer);
else addEventListener("pointermove", pointer);
});
if (observer) observer.observe(root);
else {
if (!entered) enter();
if (o.parallax) addEventListener("pointermove", pointer);
}
const listeners = [
["pointerover", hold(true)],
["pointerout", hold(false)],
["focusin", hold(true)],
["focusout", hold(false)],
] as [string, (e: Event) => void][];
for (const [type, fn] of listeners) root.addEventListener(type, fn);
return () => {
observer?.disconnect();
removeEventListener("pointermove", pointer);
for (const [type, fn] of listeners) root.removeEventListener(type, fn);
for (const loop of loops) loop?.cancel();
for (const el of items) el.style.translate = "";
};
}
// Each group runs its own loops, so it is a custom element: it also works for markup added
// later and for pages reached through view transitions.
class MarkasFloat extends HTMLElement {
private stop?: () => void;
connectedCallback() {
const root = this.firstElementChild;
if (this.stop || !(root instanceof HTMLElement) || still()) return;
const d = this.dataset;
this.stop = startFloat(root, {
motion: (d.motion ?? "drift") as FloatMotion,
amplitude: Number(d.amplitude),
duration: Number(d.duration),
seed: Number(d.seed),
parallax: Number(d.parallax),
entrance: d.entrance !== undefined,
});
}
disconnectedCallback() {
this.stop?.();
this.stop = undefined;
}
}
if (!customElements.get("markas-float")) customElements.define("markas-float", MarkasFloat);
</script>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/app/markas/float.component.ts.
import {
afterRenderEffect,
booleanAttribute,
ChangeDetectionStrategy,
Component,
computed,
type ElementRef,
input,
numberAttribute,
viewChild,
} from "@angular/core";
const base =
"[&>*]:transition-[translate] [&>*]:duration-700 [&>*]:ease-out motion-reduce:[&>*]:transition-none";
export type FloatMotion = "drift" | "bob" | "orbit" | "breathe";
type Options = {
motion: FloatMotion;
amplitude: number;
duration: number;
seed: number;
parallax: number;
entrance: boolean;
};
const STEPS = 12;
const TURN = Math.PI * 2;
const MS = 1000;
const STAGGER_MS = 90;
const ENTRANCE_MS = 600;
/** One loop of each motion: phase t (0 to 1) and amplitude a give x, y (px), rotation (deg), and scale. */
const PATHS: Record<FloatMotion, (t: number, a: number) => number[]> = {
drift: (t, a) => [
a * 0.6 * Math.sin(TURN * t),
a * 0.5 * Math.sin(TURN * 2 * t),
a * 0.3 * Math.sin(TURN * t),
1,
],
bob: (t, a) => [0, (-a * (1 - Math.cos(TURN * t))) / 2, 0, 1],
orbit: (t, a) => [a * Math.cos(TURN * t), a * Math.sin(TURN * t), 0, 1],
breathe: (t, a) => {
const k = (1 - Math.cos(TURN * t)) / 2;
return [0, -a * 0.3 * k, 0, 1 + (a / 100) * k];
},
};
/** Same number for the same seed and index in every framework. */
const rand = (seed: number, n: number) => {
const x = Math.sin(seed * 78.233 + n * 12.9898) * 43758.5453;
return x - Math.floor(x);
};
const still = () =>
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
/**
* Float each child on its own loop, pause one while it is hovered or focused, and pause all
* when off screen. With parallax, children shift toward the pointer by their depth.
*/
export function startFloat(root: HTMLElement, o: Options) {
const items = [...root.children] as HTMLElement[];
const path = PATHS[o.motion] ?? PATHS.drift;
const loops = items.map((el, i) => {
const amp = o.amplitude * (0.7 + 0.6 * rand(o.seed, i * 4));
const sign = rand(o.seed, i * 4 + 1) < 0.5 ? -1 : 1;
const ms = o.duration * MS * (0.8 + 0.4 * rand(o.seed, i * 4 + 2));
const frames = Array.from({ length: STEPS + 1 }, (_, s) => {
const [x, y, r, k] = path(s / STEPS, amp);
return {
transform: `translate(${x! * sign}px, ${y}px) rotate(${r! * sign}deg) scale(${k})`,
};
});
return el.animate?.(frames, {
duration: ms,
delay: -rand(o.seed, i * 4 + 3) * ms,
iterations: Infinity,
});
});
const held = new Set<number>();
let hidden = false;
let entered = !o.entrance;
/** Rise in one after another the first time the group scrolls into view. */
const enter = () => {
entered = true;
items.forEach((el, i) =>
el.animate?.(
[
{ opacity: 0, scale: 0.6 },
{ opacity: 1, scale: 1 },
],
{
duration: ENTRANCE_MS,
delay: i * STAGGER_MS,
easing: "cubic-bezier(0.34, 1.56, 0.64, 1)",
fill: "backwards",
},
),
);
};
const sync = () =>
loops.forEach((loop, i) =>
hidden || held.has(i) ? loop?.pause() : loop?.play(),
);
const hold = (on: boolean) => (e: Event) => {
const i = items.findIndex((el) => el.contains(e.target as Node));
const to = (e as FocusEvent).relatedTarget as Node | null;
if (i < 0 || (!on && items[i]!.contains(to))) return;
if (on) held.add(i);
else held.delete(i);
sync();
};
const pointer = (e: PointerEvent) => {
const r = root.getBoundingClientRect();
const nx = Math.max(
-1,
Math.min(1, ((e.clientX - r.left) / r.width) * 2 - 1),
);
const ny = Math.max(
-1,
Math.min(1, ((e.clientY - r.top) / r.height) * 2 - 1),
);
items.forEach((el, i) => {
const depth = Number(
el.dataset.depth ?? 0.3 + 0.7 * rand(o.seed, i * 4 + 1),
);
el.style.translate = `${nx * depth * o.parallax}px ${ny * depth * o.parallax}px`;
});
};
const observer =
typeof IntersectionObserver === "undefined"
? undefined
: new IntersectionObserver(([entry]) => {
hidden = !entry?.isIntersecting;
if (!hidden && !entered) enter();
sync();
if (!o.parallax) return;
if (hidden) removeEventListener("pointermove", pointer);
else addEventListener("pointermove", pointer);
});
if (observer) observer.observe(root);
else {
if (!entered) enter();
if (o.parallax) addEventListener("pointermove", pointer);
}
const listeners = [
["pointerover", hold(true)],
["pointerout", hold(false)],
["focusin", hold(true)],
["focusout", hold(false)],
] as [string, (e: Event) => void][];
for (const [type, fn] of listeners) root.addEventListener(type, fn);
return () => {
observer?.disconnect();
removeEventListener("pointermove", pointer);
for (const [type, fn] of listeners) root.removeEventListener(type, fn);
for (const loop of loops) loop?.cancel();
for (const el of items) el.style.translate = "";
};
}
/**
* Every projected child floats. Host stays out of layout; aria-hidden and class move to the
* group.
*/
@Component({
selector: "markas-float",
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: "contents", "[attr.aria-hidden]": "null" },
template: `
<div
#groupEl
[attr.aria-hidden]="ariaHidden() ?? null"
[class]="rootClasses()"
>
<ng-content />
</div>
`,
})
export class Float {
/** Path each child follows: wander, rise and fall, circle, or swell. */
readonly motion = input<FloatMotion>("drift");
/** Distance in px each child travels, varied a little per child. For breathe, also the growth in percent. */
readonly amplitude = input(10, { transform: numberAttribute });
/** Seconds for one loop, varied a little per child. */
readonly duration = input(6, { transform: numberAttribute });
/** Changes the per-child timing, size, and direction. */
readonly seed = input(1, { transform: numberAttribute });
/** Largest shift in px toward the pointer. 0 turns it off. */
readonly parallax = input(0, { transform: numberAttribute });
/** Children pop in one after another the first time the group scrolls into view. */
readonly entrance = input(false, { transform: booleanAttribute });
readonly ariaHidden = input<string | undefined>(undefined, {
alias: "aria-hidden",
});
readonly userClass = input("", { alias: "class" });
protected readonly rootClasses = computed(() =>
[base, this.userClass()].filter(Boolean).join(" "),
);
private readonly groupEl =
viewChild.required<ElementRef<HTMLDivElement>>("groupEl");
constructor() {
// Runs after the children are in the DOM, and again when an option changes.
afterRenderEffect((onCleanup) => {
const options = {
motion: this.motion(),
amplitude: this.amplitude(),
duration: this.duration(),
seed: this.seed(),
parallax: this.parallax(),
entrance: this.entrance(),
};
if (still()) return;
onCleanup(startFloat(this.groupEl().nativeElement, options));
});
}
}Pemakaian
<div class="relative grid h-80 place-items-center overflow-hidden rounded-xl bg-canvas">
<x-markas.float :parallax="14" aria-hidden="true" class="absolute inset-0">
<span class="absolute top-[12%] left-[10%] rounded-xl bg-surface p-3">...</span>
<span class="absolute right-[12%] bottom-[16%] rounded-xl bg-surface p-3">...</span>
</x-markas.float>
<h1 class="relative text-2xl font-semibold">Luncurkan idenya minggu ini</h1>
</div>Butuh Alpine.js.
import { Float } from "@/components/markas/Float";
<Float
motion="bob"
amplitude={6}
duration={3}
className="absolute -top-3 right-5"
>
<span className="rounded-full bg-primary px-3 py-1 text-xs text-on-primary">
Hemat 20%
</span>
</Float>;<template>
<Float
motion="orbit"
:amplitude="8"
entrance
aria-hidden="true"
class="absolute inset-0"
>
<span
class="absolute top-[14%] left-[18%] size-12 rounded-full bg-primary-soft"
>RP</span
>
<span
class="absolute right-[14%] bottom-[18%] size-14 rounded-full bg-primary"
>DP</span
>
</Float>
</template><script lang="ts">
import Float from "$lib/components/markas/Float.svelte";
</script>
<Float motion="bob" amplitude={6} duration={3} class="absolute -top-3 right-5">
<span class="rounded-full bg-primary px-3 py-1 text-xs text-on-primary">
Save 20%
</span>
</Float>---
import Float from "@/components/markas/Float.astro";
---
<Float motion="bob" amplitude={6} duration={3} class="absolute -top-3 right-5">
<span class="rounded-full bg-primary px-3 py-1 text-xs text-on-primary">
Save 20%
</span>
</Float>Setiap grup adalah custom element kecil, jadi tetap jalan setelah view transition.
import { Component } from "@angular/core";
import { Float } from "./markas/float.component";
@Component({
selector: "app-save-badge",
imports: [Float],
template: `
<markas-float
motion="bob"
[amplitude]="6"
[duration]="3"
class="absolute -top-3 right-5"
>
<span class="rounded-full bg-primary px-3 py-1 text-xs text-on-primary">
Save 20%
</span>
</markas-float>
`,
})
export class SaveBadge {}aria-hidden dan class pindah dari host ke grup.
- Setiap anak langsung melayang dengan ritmenya sendiri.
motionmemilih jalurnya:drift(angka delapan dengan sedikit goyang),bob(naik turun),orbit(lingkaran kecil), ataubreathe(membesar lembut). - Waktu, ukuran, dan arah berbeda per anak dari
seed, sehingga seed yang sama terlihat sama di Blade, React, dan Vue. parallaxmenggeser anak ke arah kursor. Pasangdata-depth="0.2"sampai"1"pada anak untuk mengatur seberapa jauh ia bergerak.entrancememunculkan anak satu per satu saat grup pertama kali masuk layar.- Anak berhenti saat disorot kursor atau difokus, dan semua putaran berhenti di luar layar. Putaran menganimasikan
transformpada setiap anak; bungkus anak yang butuh utilitas transform sendiri.
Props
| Nama | Tipe | Default | Keterangan |
|---|---|---|---|
motion | "drift" | "bob" | "orbit" | "breathe" | "drift" | Jalur yang diikuti setiap anak: angka delapan pelan dengan sedikit goyang, naik turun, lingkaran kecil, atau membesar lembut. |
amplitude | number | 10 | Jarak tempuh setiap anak dalam px, sedikit berbeda per anak. Untuk breathe juga besar pembesaran dalam persen. |
duration | number | 6 | Detik untuk satu putaran, sedikit berbeda per anak supaya tidak pernah bergerak serempak. |
seed | number | 1 | Mengubah waktu, ukuran, dan arah per anak. Seed yang sama selalu menghasilkan gerakan yang sama. |
parallax | number | 0 | Pergeseran terbesar dalam px ke arah kursor. Setiap anak bergerak sesuai kedalamannya: data-depth="0.2" sampai "1", atau kedalaman dari seed. 0 mematikannya. |
entrance | boolean | false | Anak-anak muncul satu per satu saat grup pertama kali masuk layar. |
children / slot | ReactNode / slot | - | Item yang melayang. Setiap anak langsung bergerak sendiri; atur posisinya dengan class sendiri, misalnya absolute top-[12%] left-[10%]. |
Aksesibilitas
- Gerakan melayang hanya dekorasi; tandai grup yang murni dekoratif dengan aria-hidden="true".
- Anak berhenti bergerak saat disorot kursor atau memegang fokus keyboard, sehingga tombol dan tautan yang melayang tetap mudah dikenai.
- Semua putaran berhenti saat grup di luar layar.
- Dengan reduced motion tidak ada yang bergerak: tanpa putaran, parallax, atau kemunculan.
Komponen terkait
Komponen markasui lain dengan class yang sama di setiap framework.
- Bottom NavigationBar bawah gaya aplikasi mobile. Pill meluncur ke item terpilih, labelnya muncul, dan bar bisa menciut jadi ikon saat konten discroll.
- Card StackTumpukan kartu bertingkat. Geser, tombol panah, atau tombol navigasi membuang kartu teratas lalu kartu berikutnya naik. Berputar, dengan indikator posisi.
- Chat MessagePesan dalam percakapan AI. Gelembung user di kanan, balasan asisten dengan avatar, aksi saat hover, indikator mengetik, dan efek streaming token opsional.
- Currency InputKolom uang yang memformat saat mengetik (Rp 12.500.000), menjaga posisi kursor, dan mengirim angka murni. Opsional chip nominal cepat.
- DockDock ala macOS. Ikon membesar halus mengikuti kursor atau fokus, label muncul di atas, item terbuka bertitik, dan memantul saat dibuka.
- Drag ElementsArea kartu atau stiker yang bisa diseret dengan momentum ringan di dalam batasnya. Panah menggeser item yang fokus, Escape mengembalikannya.