Dynamic Island
Pill hitam terinspirasi Dynamic Island iPhone. Memuai mulus antara keadaan idle, compact, dan expanded sambil kontennya crossfade.
Focus timer
12:48
Focus timer running
9:41
Wednesday, 5 November
Focus timer
12:48
Focus timer running
9:41
Wednesday, 5 November
Focus timer
12:48
Focus timer running
9:41
Wednesday, 5 November
Focus timer
12:48
Focus timer running
9:41
Wednesday, 5 November
Focus timer
12:48
Focus timer running
9:41
Wednesday, 5 November
@php
$panel = 'grid gap-4';
$stage = 'relative h-[220px] overflow-hidden rounded-[2rem] border border-line bg-surface';
$top = '@container absolute inset-x-0 top-3 px-3';
$clock = 'pt-24 text-center text-5xl font-semibold text-ink tabular-nums';
$date = 'pt-1 text-center text-sm text-muted';
$controls = 'flex justify-center gap-1.5';
$demoButton = 'h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none';
$timerIcon = 'size-4 text-warning';
$timerText = 'text-warning tabular-nums';
$card = 'flex h-full flex-col justify-between';
$cardHead = 'flex items-center gap-3';
$badge = 'grid size-11 place-items-center rounded-full bg-warning/15 text-warning';
$badgeIcon = 'size-5';
$label = 'text-xs text-muted';
$big = 'text-2xl leading-tight font-semibold tabular-nums';
$actions = 'grid grid-cols-2 gap-2';
$soft = 'h-9 rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none';
$stop = 'h-9 rounded-full bg-danger/15 text-sm font-medium text-danger transition-colors duration-150 ease-out hover:bg-danger/25 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none';
$timer = 'M12 8v5l3 2M9 2h6M12 21a8 8 0 1 0 0-16 8 8 0 0 0 0 16z';
$states = ['idle' => 'Idle', 'compact' => 'Compact', 'expanded' => 'Expanded'];
@endphp
<div x-data="{ island: 'compact' }" class="{{ $panel }}">
<div class="{{ $stage }}">
<div class="{{ $top }}">
<x-markas.dynamic-island
state="compact"
x-model="island"
:announcements="['compact' => 'Focus timer running', 'expanded' => 'Focus timer, 12 minutes 48 seconds left']"
>
<x-slot:leading>
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="{{ $timerIcon }}"><path d="{{ $timer }}" /></svg>
</x-slot:leading>
<x-slot:trailing>
<span class="{{ $timerText }}">12:48</span>
</x-slot:trailing>
<x-slot:expanded>
<div class="{{ $card }}">
<div class="{{ $cardHead }}">
<span class="{{ $badge }}">
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="{{ $badgeIcon }}"><path d="{{ $timer }}" /></svg>
</span>
<div>
<p class="{{ $label }}">Focus timer</p>
<p class="{{ $big }}">12:48</p>
</div>
</div>
<div class="{{ $actions }}">
<button type="button" x-on:click="island = 'compact'" class="{{ $soft }}">Minimize</button>
<button type="button" x-on:click="island = 'idle'" class="{{ $stop }}">End</button>
</div>
</div>
</x-slot:expanded>
</x-markas.dynamic-island>
</div>
<p class="{{ $clock }}">9:41</p>
<p class="{{ $date }}">Wednesday, 5 November</p>
</div>
<div role="group" aria-label="Island state" class="{{ $controls }}">
@foreach ($states as $value => $text)
<button
type="button"
aria-pressed="{{ $value === 'compact' ? 'true' : 'false' }}"
x-bind:aria-pressed="island === '{{ $value }}'"
x-on:click="island = '{{ $value }}'"
class="{{ $demoButton }}"
>{{ $text }}</button>
@endforeach
</div>
</div>import { useState } from "react";
import {
DynamicIsland,
type DynamicIslandState,
} from "@/components/markas/DynamicIsland";
const panel = "grid gap-4";
const stage =
"relative h-[220px] overflow-hidden rounded-[2rem] border border-line bg-surface";
const top = "@container absolute inset-x-0 top-3 px-3";
const clock = "pt-24 text-center text-5xl font-semibold text-ink tabular-nums";
const date = "pt-1 text-center text-sm text-muted";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const timerIcon = "size-4 text-warning";
const timerText = "text-warning tabular-nums";
const card = "flex h-full flex-col justify-between";
const cardHead = "flex items-center gap-3";
const badge =
"grid size-11 place-items-center rounded-full bg-warning/15 text-warning";
const badgeIcon = "size-5";
const label = "text-xs text-muted";
const big = "text-2xl leading-tight font-semibold tabular-nums";
const actions = "grid grid-cols-2 gap-2";
const soft =
"h-9 rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const stop =
"h-9 rounded-full bg-danger/15 text-sm font-medium text-danger transition-colors duration-150 ease-out hover:bg-danger/25 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const TIMER = "M12 8v5l3 2M9 2h6M12 21a8 8 0 1 0 0-16 8 8 0 0 0 0 16z";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
const Icon = ({ className }: { className: string }) => (
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
className={className}
>
<path d={TIMER} />
</svg>
);
export default function DynamicIslandExample() {
const [island, setIsland] = useState<DynamicIslandState>("compact");
return (
<div className={panel}>
<div className={stage}>
<div className={top}>
<DynamicIsland
state={island}
announcements={{
compact: "Focus timer running",
expanded: "Focus timer, 12 minutes 48 seconds left",
}}
leading={<Icon className={timerIcon} />}
trailing={<span className={timerText}>12:48</span>}
expanded={
<div className={card}>
<div className={cardHead}>
<span className={badge}>
<Icon className={badgeIcon} />
</span>
<div>
<p className={label}>Focus timer</p>
<p className={big}>12:48</p>
</div>
</div>
<div className={actions}>
<button
type="button"
className={soft}
onClick={() => setIsland("compact")}
>
Minimize
</button>
<button
type="button"
className={stop}
onClick={() => setIsland("idle")}
>
End
</button>
</div>
</div>
}
/>
</div>
<p className={clock}>9:41</p>
<p className={date}>Wednesday, 5 November</p>
</div>
<div role="group" aria-label="Island state" className={controls}>
{states.map((item) => (
<button
key={item.value}
type="button"
aria-pressed={island === item.value}
className={demoButton}
onClick={() => setIsland(item.value)}
>
{item.label}
</button>
))}
</div>
</div>
);
}<script setup lang="ts">
import { ref } from "vue";
import DynamicIsland, {
type DynamicIslandState,
} from "@/components/markas/DynamicIsland.vue";
const panel = "grid gap-4";
const stage =
"relative h-[220px] overflow-hidden rounded-[2rem] border border-line bg-surface";
const top = "@container absolute inset-x-0 top-3 px-3";
const clock = "pt-24 text-center text-5xl font-semibold text-ink tabular-nums";
const date = "pt-1 text-center text-sm text-muted";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const timerIcon = "size-4 text-warning";
const timerText = "text-warning tabular-nums";
const card = "flex h-full flex-col justify-between";
const cardHead = "flex items-center gap-3";
const badge =
"grid size-11 place-items-center rounded-full bg-warning/15 text-warning";
const badgeIcon = "size-5";
const label = "text-xs text-muted";
const big = "text-2xl leading-tight font-semibold tabular-nums";
const actions = "grid grid-cols-2 gap-2";
const soft =
"h-9 rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const stop =
"h-9 rounded-full bg-danger/15 text-sm font-medium text-danger transition-colors duration-150 ease-out hover:bg-danger/25 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const TIMER = "M12 8v5l3 2M9 2h6M12 21a8 8 0 1 0 0-16 8 8 0 0 0 0 16z";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
const island = ref<DynamicIslandState>("compact");
</script>
<template>
<div :class="panel">
<div :class="stage">
<div :class="top">
<DynamicIsland
:state="island"
:announcements="{
compact: 'Focus timer running',
expanded: 'Focus timer, 12 minutes 48 seconds left',
}"
>
<template #leading>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
:class="timerIcon"
>
<path :d="TIMER" />
</svg>
</template>
<template #trailing>
<span :class="timerText">12:48</span>
</template>
<template #expanded>
<div :class="card">
<div :class="cardHead">
<span :class="badge">
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
:class="badgeIcon"
>
<path :d="TIMER" />
</svg>
</span>
<div>
<p :class="label">Focus timer</p>
<p :class="big">12:48</p>
</div>
</div>
<div :class="actions">
<button type="button" :class="soft" @click="island = 'compact'">
Minimize
</button>
<button type="button" :class="stop" @click="island = 'idle'">
End
</button>
</div>
</div>
</template>
</DynamicIsland>
</div>
<p :class="clock">9:41</p>
<p :class="date">Wednesday, 5 November</p>
</div>
<div role="group" aria-label="Island state" :class="controls">
<button
v-for="item in states"
:key="item.value"
type="button"
:aria-pressed="island === item.value"
:class="demoButton"
@click="island = item.value"
>
{{ item.label }}
</button>
</div>
</div>
</template><script lang="ts">
import DynamicIsland, {
type DynamicIslandState,
} from "$lib/components/markas/DynamicIsland.svelte";
const panel = "grid gap-4";
const stage =
"relative h-[220px] overflow-hidden rounded-[2rem] border border-line bg-surface";
const top = "@container absolute inset-x-0 top-3 px-3";
const clock =
"pt-24 text-center text-5xl font-semibold text-ink tabular-nums";
const date = "pt-1 text-center text-sm text-muted";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const timerIcon = "size-4 text-warning";
const timerText = "text-warning tabular-nums";
const card = "flex h-full flex-col justify-between";
const cardHead = "flex items-center gap-3";
const badge =
"grid size-11 place-items-center rounded-full bg-warning/15 text-warning";
const badgeIcon = "size-5";
const label = "text-xs text-muted";
const big = "text-2xl leading-tight font-semibold tabular-nums";
const actions = "grid grid-cols-2 gap-2";
const soft =
"h-9 rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const stop =
"h-9 rounded-full bg-danger/15 text-sm font-medium text-danger transition-colors duration-150 ease-out hover:bg-danger/25 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const TIMER = "M12 8v5l3 2M9 2h6M12 21a8 8 0 1 0 0-16 8 8 0 0 0 0 16z";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
let island = $state<DynamicIslandState>("compact");
</script>
{#snippet icon(className: string)}
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={className}
>
<path d={TIMER} />
</svg>
{/snippet}
<div class={panel}>
<div class={stage}>
<div class={top}>
<DynamicIsland
state={island}
announcements={{
compact: "Focus timer running",
expanded: "Focus timer, 12 minutes 48 seconds left",
}}
>
{#snippet leading()}
{@render icon(timerIcon)}
{/snippet}
{#snippet trailing()}
<span class={timerText}>12:48</span>
{/snippet}
{#snippet expanded()}
<div class={card}>
<div class={cardHead}>
<span class={badge}>
{@render icon(badgeIcon)}
</span>
<div>
<p class={label}>Focus timer</p>
<p class={big}>12:48</p>
</div>
</div>
<div class={actions}>
<button
type="button"
class={soft}
onclick={() => (island = "compact")}>Minimize</button
>
<button
type="button"
class={stop}
onclick={() => (island = "idle")}>End</button
>
</div>
</div>
{/snippet}
</DynamicIsland>
</div>
<p class={clock}>9:41</p>
<p class={date}>Wednesday, 5 November</p>
</div>
<div role="group" aria-label="Island state" class={controls}>
{#each states as item (item.value)}
<button
type="button"
aria-pressed={island === item.value}
class={demoButton}
onclick={() => (island = item.value)}>{item.label}</button
>
{/each}
</div>
</div>---
import DynamicIsland, { type DynamicIslandState } from "@/components/markas/DynamicIsland.astro";
const panel = "grid gap-4";
const stage =
"relative h-[220px] overflow-hidden rounded-[2rem] border border-line bg-surface";
const top = "@container absolute inset-x-0 top-3 px-3";
const clock =
"pt-24 text-center text-5xl font-semibold text-ink tabular-nums";
const date = "pt-1 text-center text-sm text-muted";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const timerIcon = "size-4 text-warning";
const timerText = "text-warning tabular-nums";
const card = "flex h-full flex-col justify-between";
const cardHead = "flex items-center gap-3";
const badge =
"grid size-11 place-items-center rounded-full bg-warning/15 text-warning";
const badgeIcon = "size-5";
const label = "text-xs text-muted";
const big = "text-2xl leading-tight font-semibold tabular-nums";
const actions = "grid grid-cols-2 gap-2";
const soft =
"h-9 rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const stop =
"h-9 rounded-full bg-danger/15 text-sm font-medium text-danger transition-colors duration-150 ease-out hover:bg-danger/25 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const TIMER = "M12 8v5l3 2M9 2h6M12 21a8 8 0 1 0 0-16 8 8 0 0 0 0 16z";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
---
<div class={panel} data-island-demo>
<div class={stage}>
<div class={top}>
<DynamicIsland
state="compact"
announcements={{
compact: "Focus timer running",
expanded: "Focus timer, 12 minutes 48 seconds left",
}}
>
<Fragment slot="leading">
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={timerIcon}
>
<path d={TIMER}></path>
</svg>
</Fragment>
<span slot="trailing" class={timerText}>12:48</span>
<div slot="expanded" class={card}>
<div class={cardHead}>
<span class={badge}>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={badgeIcon}
>
<path d={TIMER}></path>
</svg>
</span>
<div>
<p class={label}>Focus timer</p>
<p class={big}>12:48</p>
</div>
</div>
<div class={actions}>
<button type="button" class={soft} data-island-set="compact">Minimize</button>
<button type="button" class={stop} data-island-set="idle">End</button>
</div>
</div>
</DynamicIsland>
</div>
<p class={clock}>9:41</p>
<p class={date}>Wednesday, 5 November</p>
</div>
<div role="group" aria-label="Island state" class={controls}>
{
states.map((item) => (
<button
type="button"
aria-pressed={item.value === "compact" ? "true" : "false"}
data-island-set={item.value}
class={demoButton}
>
{item.label}
</button>
))
}
</div>
</div>
<script>
// Demo wiring: buttons with data-island-set move the island to that state.
document.addEventListener("click", (event) => {
const button = (event.target as Element).closest<HTMLElement>(
"[data-island-set]",
);
const demo = button?.closest("[data-island-demo]");
if (!button || !demo) return;
const state = button.dataset.islandSet ?? "idle";
demo.querySelector("markas-dynamic-island")?.setAttribute("state", state);
demo.querySelectorAll("[aria-pressed]").forEach((other) =>
other.setAttribute(
"aria-pressed",
String(other.getAttribute("data-island-set") === state),
),
);
});
</script>import { Component, signal } from "@angular/core";
import {
DynamicIsland,
type DynamicIslandState,
} from "./markas/dynamic-island.component";
@Component({
selector: "markas-example",
imports: [DynamicIsland],
template: `
<div [class]="panel">
<div [class]="stage">
<div [class]="top">
<markas-dynamic-island
[state]="island()"
[announcements]="announcements"
>
<ng-container leading>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
[class]="timerIcon"
>
<path [attr.d]="TIMER" />
</svg>
</ng-container>
<span trailing [class]="timerText">12:48</span>
<div expanded [class]="card">
<div [class]="cardHead">
<span [class]="badge">
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
[class]="badgeIcon"
>
<path [attr.d]="TIMER" />
</svg>
</span>
<div>
<p [class]="label">Focus timer</p>
<p [class]="big">12:48</p>
</div>
</div>
<div [class]="actions">
<button
type="button"
[class]="soft"
(click)="island.set('compact')"
>
Minimize
</button>
<button
type="button"
[class]="stop"
(click)="island.set('idle')"
>
End
</button>
</div>
</div>
</markas-dynamic-island>
</div>
<p [class]="clock">9:41</p>
<p [class]="date">Wednesday, 5 November</p>
</div>
<div role="group" aria-label="Island state" [class]="controls">
@for (item of states; track item.value) {
<button
type="button"
[attr.aria-pressed]="island() === item.value"
[class]="demoButton"
(click)="island.set(item.value)"
>
{{ item.label }}
</button>
}
</div>
</div>
`,
})
export default class DynamicIslandExample {
protected readonly panel = "grid gap-4";
protected readonly stage =
"relative h-[220px] overflow-hidden rounded-[2rem] border border-line bg-surface";
protected readonly top = "@container absolute inset-x-0 top-3 px-3";
protected readonly clock =
"pt-24 text-center text-5xl font-semibold text-ink tabular-nums";
protected readonly date = "pt-1 text-center text-sm text-muted";
protected readonly controls = "flex justify-center gap-1.5";
protected readonly demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
protected readonly timerIcon = "size-4 text-warning";
protected readonly timerText = "text-warning tabular-nums";
protected readonly card = "flex h-full flex-col justify-between";
protected readonly cardHead = "flex items-center gap-3";
protected readonly badge =
"grid size-11 place-items-center rounded-full bg-warning/15 text-warning";
protected readonly badgeIcon = "size-5";
protected readonly label = "text-xs text-muted";
protected readonly big = "text-2xl leading-tight font-semibold tabular-nums";
protected readonly actions = "grid grid-cols-2 gap-2";
protected readonly soft =
"h-9 rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
protected readonly stop =
"h-9 rounded-full bg-danger/15 text-sm font-medium text-danger transition-colors duration-150 ease-out hover:bg-danger/25 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
protected readonly TIMER =
"M12 8v5l3 2M9 2h6M12 21a8 8 0 1 0 0-16 8 8 0 0 0 0 16z";
protected readonly states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
protected readonly announcements = {
compact: "Focus timer running",
expanded: "Focus timer, 12 minutes 48 seconds left",
};
protected readonly island = signal<DynamicIslandState>("compact");
}Contoh
Sedang diputar
Hujan di Kota
Nadia Sukma
1:243:34
Hujan di Kota
Nadia Sukma
1:243:34
Hujan di Kota
Nadia Sukma
1:243:34
Hujan di Kota
Nadia Sukma
1:24 3:34
Hujan di Kota
Nadia Sukma
1:243:34
@php
$panel = 'grid gap-4';
$stage = '@container h-[220px] rounded-[2rem] border border-line bg-surface px-3 pt-3';
$island = '[--island-expanded-height:11rem]';
$controls = 'flex justify-center gap-1.5';
$demoButton = 'h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none';
$art = 'size-6 rounded-md bg-linear-to-br from-success to-warning';
$bigArt = 'size-12 shrink-0 rounded-lg bg-linear-to-br from-success to-warning';
$bars = 'flex h-4 items-end gap-0.5';
$bar = [
'h-2 w-0.5 animate-pulse rounded-full bg-success motion-reduce:animate-none',
'h-4 w-0.5 animate-pulse rounded-full bg-success [animation-delay:200ms] motion-reduce:animate-none',
'h-3 w-0.5 animate-pulse rounded-full bg-success [animation-delay:400ms] motion-reduce:animate-none',
'h-2.5 w-0.5 animate-pulse rounded-full bg-success [animation-delay:600ms] motion-reduce:animate-none',
];
$card = 'grid h-full content-between';
$head = 'flex items-center gap-3';
$song = 'min-w-0 flex-1';
$title = 'truncate text-sm font-semibold';
$artist = 'truncate text-xs text-muted';
$track = 'h-1 overflow-hidden rounded-full bg-line';
$fill = 'h-full w-2/5 rounded-full bg-ink';
$times = 'flex justify-between pt-1 text-[11px] text-muted tabular-nums';
$buttons = 'flex items-center justify-center gap-6';
$iconButton = 'grid size-9 place-items-center rounded-full transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none';
$icon = 'size-5';
$media = [
['label' => 'Previous', 'd' => 'M18 6v12l-9-6zM6 6v12'],
['label' => 'Pause', 'd' => 'M8 5v14M16 5v14'],
['label' => 'Next', 'd' => 'M6 6v12l9-6zM18 6v12'],
];
$states = ['idle' => 'Idle', 'compact' => 'Compact', 'expanded' => 'Expanded'];
@endphp
<div x-data="{ island: 'expanded' }" class="{{ $panel }}">
<div class="{{ $stage }}">
<x-markas.dynamic-island state="expanded" x-model="island" class="{{ $island }}" island-label="Now playing">
<x-slot:leading>
<span aria-hidden="true" class="{{ $art }}"></span>
</x-slot:leading>
<x-slot:trailing>
<span aria-hidden="true" class="{{ $bars }}">
@foreach ($bar as $barClass)
<span class="{{ $barClass }}"></span>
@endforeach
</span>
</x-slot:trailing>
<x-slot:expanded>
<div class="{{ $card }}">
<div class="{{ $head }}">
<span aria-hidden="true" class="{{ $bigArt }}"></span>
<div class="{{ $song }}">
<p class="{{ $title }}">Hujan di Kota</p>
<p class="{{ $artist }}">Nadia Sukma</p>
</div>
</div>
<div>
<div class="{{ $track }}"><div class="{{ $fill }}"></div></div>
<p class="{{ $times }}"><span>1:24</span><span>3:34</span></p>
</div>
<div class="{{ $buttons }}">
@foreach ($media as $item)
<button type="button" aria-label="{{ $item['label'] }}" class="{{ $iconButton }}">
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="{{ $icon }}"><path d="{{ $item['d'] }}" /></svg>
</button>
@endforeach
</div>
</div>
</x-slot:expanded>
</x-markas.dynamic-island>
</div>
<div role="group" aria-label="Island state" class="{{ $controls }}">
@foreach ($states as $value => $text)
<button
type="button"
aria-pressed="{{ $value === 'expanded' ? 'true' : 'false' }}"
x-bind:aria-pressed="island === '{{ $value }}'"
x-on:click="island = '{{ $value }}'"
class="{{ $demoButton }}"
>{{ $text }}</button>
@endforeach
</div>
</div>import { useState } from "react";
import {
DynamicIsland,
type DynamicIslandState,
} from "@/components/markas/DynamicIsland";
const panel = "grid gap-4";
const stage =
"@container h-[220px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const island = "[--island-expanded-height:11rem]";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const art = "size-6 rounded-md bg-linear-to-br from-success to-warning";
const bigArt =
"size-12 shrink-0 rounded-lg bg-linear-to-br from-success to-warning";
const bars = "flex h-4 items-end gap-0.5";
const bar = [
"h-2 w-0.5 animate-pulse rounded-full bg-success motion-reduce:animate-none",
"h-4 w-0.5 animate-pulse rounded-full bg-success [animation-delay:200ms] motion-reduce:animate-none",
"h-3 w-0.5 animate-pulse rounded-full bg-success [animation-delay:400ms] motion-reduce:animate-none",
"h-2.5 w-0.5 animate-pulse rounded-full bg-success [animation-delay:600ms] motion-reduce:animate-none",
];
const card = "grid h-full content-between";
const head = "flex items-center gap-3";
const song = "min-w-0 flex-1";
const title = "truncate text-sm font-semibold";
const artist = "truncate text-xs text-muted";
const track = "h-1 overflow-hidden rounded-full bg-line";
const fill = "h-full w-2/5 rounded-full bg-ink";
const times = "flex justify-between pt-1 text-[11px] text-muted tabular-nums";
const buttons = "flex items-center justify-center gap-6";
const iconButton =
"grid size-9 place-items-center rounded-full transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const icon = "size-5";
const media = [
{ label: "Previous", d: "M18 6v12l-9-6zM6 6v12" },
{ label: "Pause", d: "M8 5v14M16 5v14" },
{ label: "Next", d: "M6 6v12l9-6zM18 6v12" },
];
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
export default function Example() {
const [state, setState] = useState<DynamicIslandState>("expanded");
return (
<div className={panel}>
<div className={stage}>
<DynamicIsland
state={state}
className={island}
islandLabel="Now playing"
leading={<span aria-hidden="true" className={art} />}
trailing={
<span aria-hidden="true" className={bars}>
{bar.map((c) => (
<span key={c} className={c} />
))}
</span>
}
expanded={
<div className={card}>
<div className={head}>
<span aria-hidden="true" className={bigArt} />
<div className={song}>
<p className={title}>Hujan di Kota</p>
<p className={artist}>Nadia Sukma</p>
</div>
</div>
<div>
<div className={track}>
<div className={fill} />
</div>
<p className={times}>
<span>1:24</span>
<span>3:34</span>
</p>
</div>
<div className={buttons}>
{media.map((item) => (
<button
key={item.label}
type="button"
aria-label={item.label}
className={iconButton}
>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
className={icon}
>
<path d={item.d} />
</svg>
</button>
))}
</div>
</div>
}
/>
</div>
<div role="group" aria-label="Island state" className={controls}>
{states.map((item) => (
<button
key={item.value}
type="button"
aria-pressed={state === item.value}
className={demoButton}
onClick={() => setState(item.value)}
>
{item.label}
</button>
))}
</div>
</div>
);
}<script setup lang="ts">
import { ref } from "vue";
import DynamicIsland, {
type DynamicIslandState,
} from "@/components/markas/DynamicIsland.vue";
const panel = "grid gap-4";
const stage =
"@container h-[220px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const island = "[--island-expanded-height:11rem]";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const art = "size-6 rounded-md bg-linear-to-br from-success to-warning";
const bigArt =
"size-12 shrink-0 rounded-lg bg-linear-to-br from-success to-warning";
const bars = "flex h-4 items-end gap-0.5";
const bar = [
"h-2 w-0.5 animate-pulse rounded-full bg-success motion-reduce:animate-none",
"h-4 w-0.5 animate-pulse rounded-full bg-success [animation-delay:200ms] motion-reduce:animate-none",
"h-3 w-0.5 animate-pulse rounded-full bg-success [animation-delay:400ms] motion-reduce:animate-none",
"h-2.5 w-0.5 animate-pulse rounded-full bg-success [animation-delay:600ms] motion-reduce:animate-none",
];
const card = "grid h-full content-between";
const head = "flex items-center gap-3";
const song = "min-w-0 flex-1";
const title = "truncate text-sm font-semibold";
const artist = "truncate text-xs text-muted";
const track = "h-1 overflow-hidden rounded-full bg-line";
const fill = "h-full w-2/5 rounded-full bg-ink";
const times = "flex justify-between pt-1 text-[11px] text-muted tabular-nums";
const buttons = "flex items-center justify-center gap-6";
const iconButton =
"grid size-9 place-items-center rounded-full transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const icon = "size-5";
const media = [
{ label: "Previous", d: "M18 6v12l-9-6zM6 6v12" },
{ label: "Pause", d: "M8 5v14M16 5v14" },
{ label: "Next", d: "M6 6v12l9-6zM18 6v12" },
];
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
const state = ref<DynamicIslandState>("expanded");
</script>
<template>
<div :class="panel">
<div :class="stage">
<DynamicIsland :state="state" :class="island" island-label="Now playing">
<template #leading>
<span aria-hidden="true" :class="art" />
</template>
<template #trailing>
<span aria-hidden="true" :class="bars">
<span v-for="c in bar" :key="c" :class="c" />
</span>
</template>
<template #expanded>
<div :class="card">
<div :class="head">
<span aria-hidden="true" :class="bigArt" />
<div :class="song">
<p :class="title">Hujan di Kota</p>
<p :class="artist">Nadia Sukma</p>
</div>
</div>
<div>
<div :class="track"><div :class="fill" /></div>
<p :class="times"><span>1:24</span><span>3:34</span></p>
</div>
<div :class="buttons">
<button
v-for="item in media"
:key="item.label"
type="button"
:aria-label="item.label"
:class="iconButton"
>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
:class="icon"
>
<path :d="item.d" />
</svg>
</button>
</div>
</div>
</template>
</DynamicIsland>
</div>
<div role="group" aria-label="Island state" :class="controls">
<button
v-for="item in states"
:key="item.value"
type="button"
:aria-pressed="state === item.value"
:class="demoButton"
@click="state = item.value"
>
{{ item.label }}
</button>
</div>
</div>
</template><script lang="ts">
import DynamicIsland, {
type DynamicIslandState,
} from "$lib/components/markas/DynamicIsland.svelte";
const panel = "grid gap-4";
const stage =
"@container h-[220px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const island = "[--island-expanded-height:11rem]";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const art = "size-6 rounded-md bg-linear-to-br from-success to-warning";
const bigArt =
"size-12 shrink-0 rounded-lg bg-linear-to-br from-success to-warning";
const bars = "flex h-4 items-end gap-0.5";
const bar = [
"h-2 w-0.5 animate-pulse rounded-full bg-success motion-reduce:animate-none",
"h-4 w-0.5 animate-pulse rounded-full bg-success [animation-delay:200ms] motion-reduce:animate-none",
"h-3 w-0.5 animate-pulse rounded-full bg-success [animation-delay:400ms] motion-reduce:animate-none",
"h-2.5 w-0.5 animate-pulse rounded-full bg-success [animation-delay:600ms] motion-reduce:animate-none",
];
const card = "grid h-full content-between";
const head = "flex items-center gap-3";
const song = "min-w-0 flex-1";
const title = "truncate text-sm font-semibold";
const artist = "truncate text-xs text-muted";
const track = "h-1 overflow-hidden rounded-full bg-line";
const fill = "h-full w-2/5 rounded-full bg-ink";
const times = "flex justify-between pt-1 text-[11px] text-muted tabular-nums";
const buttons = "flex items-center justify-center gap-6";
const iconButton =
"grid size-9 place-items-center rounded-full transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const icon = "size-5";
const media = [
{ label: "Previous", d: "M18 6v12l-9-6zM6 6v12" },
{ label: "Pause", d: "M8 5v14M16 5v14" },
{ label: "Next", d: "M6 6v12l9-6zM18 6v12" },
];
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
let state = $state<DynamicIslandState>("expanded");
</script>
<div class={panel}>
<div class={stage}>
<DynamicIsland {state} class={island} islandLabel="Now playing">
{#snippet leading()}
<span aria-hidden="true" class={art}></span>
{/snippet}
{#snippet trailing()}
<span aria-hidden="true" class={bars}>
{#each bar as c (c)}
<span class={c}></span>
{/each}
</span>
{/snippet}
{#snippet expanded()}
<div class={card}>
<div class={head}>
<span aria-hidden="true" class={bigArt}></span>
<div class={song}>
<p class={title}>Hujan di Kota</p>
<p class={artist}>Nadia Sukma</p>
</div>
</div>
<div>
<div class={track}>
<div class={fill}></div>
</div>
<p class={times}>
<span>1:24</span>
<span>3:34</span>
</p>
</div>
<div class={buttons}>
{#each media as item (item.label)}
<button type="button" aria-label={item.label} class={iconButton}>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={icon}
>
<path d={item.d} />
</svg>
</button>
{/each}
</div>
</div>
{/snippet}
</DynamicIsland>
</div>
<div role="group" aria-label="Island state" class={controls}>
{#each states as item (item.value)}
<button
type="button"
aria-pressed={state === item.value}
class={demoButton}
onclick={() => (state = item.value)}>{item.label}</button
>
{/each}
</div>
</div>---
import DynamicIsland, { type DynamicIslandState } from "@/components/markas/DynamicIsland.astro";
const panel = "grid gap-4";
const stage = "@container h-[220px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const island = "[--island-expanded-height:11rem]";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const art = "size-6 rounded-md bg-linear-to-br from-success to-warning";
const bigArt =
"size-12 shrink-0 rounded-lg bg-linear-to-br from-success to-warning";
const bars = "flex h-4 items-end gap-0.5";
const bar = [
"h-2 w-0.5 animate-pulse rounded-full bg-success motion-reduce:animate-none",
"h-4 w-0.5 animate-pulse rounded-full bg-success [animation-delay:200ms] motion-reduce:animate-none",
"h-3 w-0.5 animate-pulse rounded-full bg-success [animation-delay:400ms] motion-reduce:animate-none",
"h-2.5 w-0.5 animate-pulse rounded-full bg-success [animation-delay:600ms] motion-reduce:animate-none",
];
const card = "grid h-full content-between";
const head = "flex items-center gap-3";
const song = "min-w-0 flex-1";
const title = "truncate text-sm font-semibold";
const artist = "truncate text-xs text-muted";
const track = "h-1 overflow-hidden rounded-full bg-line";
const fill = "h-full w-2/5 rounded-full bg-ink";
const times =
"flex justify-between pt-1 text-[11px] text-muted tabular-nums";
const buttons = "flex items-center justify-center gap-6";
const iconButton =
"grid size-9 place-items-center rounded-full transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const icon = "size-5";
const media = [
{ label: "Previous", d: "M18 6v12l-9-6zM6 6v12" },
{ label: "Pause", d: "M8 5v14M16 5v14" },
{ label: "Next", d: "M6 6v12l9-6zM18 6v12" },
];
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
---
<div class={panel} data-island-demo>
<div class={stage}>
<DynamicIsland state="expanded" class={island} islandLabel="Now playing">
<span slot="leading" aria-hidden="true" class={art}></span>
<span slot="trailing" aria-hidden="true" class={bars}>
{bar.map((c) => <span class={c} />)}
</span>
<div slot="expanded" class={card}>
<div class={head}>
<span aria-hidden="true" class={bigArt}></span>
<div class={song}>
<p class={title}>Hujan di Kota</p>
<p class={artist}>Nadia Sukma</p>
</div>
</div>
<div>
<div class={track}>
<div class={fill}></div>
</div>
<p class={times}>
<span>1:24</span>
<span>3:34</span>
</p>
</div>
<div class={buttons}>
{
media.map((item) => (
<button type="button" aria-label={item.label} class={iconButton}>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={icon}
>
<path d={item.d}></path>
</svg>
</button>
))
}
</div>
</div>
</DynamicIsland>
</div>
<div role="group" aria-label="Island state" class={controls}>
{
states.map((item) => (
<button
type="button"
aria-pressed={item.value === "expanded" ? "true" : "false"}
data-island-set={item.value}
class={demoButton}
>
{item.label}
</button>
))
}
</div>
</div>
<script>
// Demo wiring: buttons with data-island-set move the island to that state.
document.addEventListener("click", (event) => {
const button = (event.target as Element).closest<HTMLElement>(
"[data-island-set]",
);
const demo = button?.closest("[data-island-demo]");
if (!button || !demo) return;
const state = button.dataset.islandSet ?? "idle";
demo.querySelector("markas-dynamic-island")?.setAttribute("state", state);
demo.querySelectorAll("[aria-pressed]").forEach((other) =>
other.setAttribute(
"aria-pressed",
String(other.getAttribute("data-island-set") === state),
),
);
});
</script>import { Component, signal } from "@angular/core";
import {
DynamicIsland,
type DynamicIslandState,
} from "./markas/dynamic-island.component";
@Component({
selector: "markas-example",
imports: [DynamicIsland],
template: `
<div [class]="panel">
<div [class]="stage">
<markas-dynamic-island
[state]="state()"
[class]="island"
islandLabel="Now playing"
>
<span leading aria-hidden="true" [class]="art"></span>
<span trailing aria-hidden="true" [class]="bars">
@for (c of bar; track c) {
<span [class]="c"></span>
}
</span>
<div expanded [class]="card">
<div [class]="head">
<span aria-hidden="true" [class]="bigArt"></span>
<div [class]="song">
<p [class]="title">Hujan di Kota</p>
<p [class]="artist">Nadia Sukma</p>
</div>
</div>
<div>
<div [class]="track">
<div [class]="fill"></div>
</div>
<p [class]="times">
<span>1:24</span>
<span>3:34</span>
</p>
</div>
<div [class]="buttons">
@for (item of media; track item.label) {
<button
type="button"
[attr.aria-label]="item.label"
[class]="iconButton"
>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
[class]="icon"
>
<path [attr.d]="item.d" />
</svg>
</button>
}
</div>
</div>
</markas-dynamic-island>
</div>
<div role="group" aria-label="Island state" [class]="controls">
@for (item of states; track item.value) {
<button
type="button"
[attr.aria-pressed]="state() === item.value"
[class]="demoButton"
(click)="state.set(item.value)"
>
{{ item.label }}
</button>
}
</div>
</div>
`,
})
export default class DynamicIslandMusicExample {
protected readonly panel = "grid gap-4";
protected readonly stage =
"@container h-[220px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
protected readonly island = "[--island-expanded-height:11rem]";
protected readonly controls = "flex justify-center gap-1.5";
protected readonly demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
protected readonly art =
"size-6 rounded-md bg-linear-to-br from-success to-warning";
protected readonly bigArt =
"size-12 shrink-0 rounded-lg bg-linear-to-br from-success to-warning";
protected readonly bars = "flex h-4 items-end gap-0.5";
protected readonly bar = [
"h-2 w-0.5 animate-pulse rounded-full bg-success motion-reduce:animate-none",
"h-4 w-0.5 animate-pulse rounded-full bg-success [animation-delay:200ms] motion-reduce:animate-none",
"h-3 w-0.5 animate-pulse rounded-full bg-success [animation-delay:400ms] motion-reduce:animate-none",
"h-2.5 w-0.5 animate-pulse rounded-full bg-success [animation-delay:600ms] motion-reduce:animate-none",
];
protected readonly card = "grid h-full content-between";
protected readonly head = "flex items-center gap-3";
protected readonly song = "min-w-0 flex-1";
protected readonly title = "truncate text-sm font-semibold";
protected readonly artist = "truncate text-xs text-muted";
protected readonly track = "h-1 overflow-hidden rounded-full bg-line";
protected readonly fill = "h-full w-2/5 rounded-full bg-ink";
protected readonly times =
"flex justify-between pt-1 text-[11px] text-muted tabular-nums";
protected readonly buttons = "flex items-center justify-center gap-6";
protected readonly iconButton =
"grid size-9 place-items-center rounded-full transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
protected readonly icon = "size-5";
protected readonly media = [
{ label: "Previous", d: "M18 6v12l-9-6zM6 6v12" },
{ label: "Pause", d: "M8 5v14M16 5v14" },
{ label: "Next", d: "M6 6v12l9-6zM18 6v12" },
];
protected readonly states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
protected readonly state = signal<DynamicIslandState>("expanded");
}Panggilan masuk
Mobile
Rina Santoso
Incoming call from Rina Santoso
Mobile
Rina Santoso
Incoming call from Rina Santoso
Mobile
Rina Santoso
Incoming call from Rina Santoso
Mobile
Rina Santoso
Incoming call from Rina Santoso
Mobile
Rina Santoso
Incoming call from Rina Santoso
@php
$panel = 'grid gap-4';
$stage = '@container h-[150px] rounded-[2rem] border border-line bg-surface px-3 pt-3';
$island = '[--island-expanded-height:4.75rem]';
$controls = 'flex justify-center gap-1.5';
$demoButton = 'h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none';
$caller = 'text-success';
$callIcon = 'size-4 text-success';
$timer = 'text-success tabular-nums';
$row = 'flex h-full items-center gap-3';
$avatar = 'grid size-11 shrink-0 place-items-center rounded-full bg-subtle text-sm font-semibold';
$who = 'min-w-0 flex-1';
$label = 'text-xs text-muted';
$name = 'truncate text-base font-semibold';
$round = 'grid size-11 shrink-0 place-items-center rounded-full text-canvas transition-[scale] duration-150 ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-90 motion-reduce:transition-none';
$decline = $round.' bg-danger';
$accept = $round.' bg-success';
$icon = 'size-5';
$phone = 'M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2';
$hangUp = 'M3 15.5c5-4.5 13-4.5 18 0l-1.5 2.5-4-1v-2.5a10 10 0 0 0-7 0V17l-4 1z';
$states = ['idle' => 'Idle', 'compact' => 'On call', 'expanded' => 'Ringing'];
@endphp
<div x-data="{ call: 'expanded' }" class="{{ $panel }}">
<div class="{{ $stage }}">
<x-markas.dynamic-island
state="expanded"
x-model="call"
class="{{ $island }}"
:announcements="['expanded' => 'Incoming call from Rina Santoso', 'compact' => 'Call connected']"
>
<x-slot:leading>
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="{{ $callIcon }}"><path d="{{ $phone }}" /></svg>
<span class="{{ $caller }}">Rina</span>
</x-slot:leading>
<x-slot:trailing>
<span class="{{ $timer }}">0:42</span>
</x-slot:trailing>
<x-slot:expanded>
<div class="{{ $row }}">
<span aria-hidden="true" class="{{ $avatar }}">RS</span>
<div class="{{ $who }}">
<p class="{{ $label }}">Mobile</p>
<p class="{{ $name }}">Rina Santoso</p>
</div>
<button type="button" aria-label="Decline" x-on:click="call = 'idle'" class="{{ $decline }}">
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="{{ $icon }}"><path d="{{ $hangUp }}" /></svg>
</button>
<button type="button" aria-label="Accept" x-on:click="call = 'compact'" class="{{ $accept }}">
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="{{ $icon }}"><path d="{{ $phone }}" /></svg>
</button>
</div>
</x-slot:expanded>
</x-markas.dynamic-island>
</div>
<div role="group" aria-label="Call state" class="{{ $controls }}">
@foreach ($states as $value => $text)
<button
type="button"
aria-pressed="{{ $value === 'expanded' ? 'true' : 'false' }}"
x-bind:aria-pressed="call === '{{ $value }}'"
x-on:click="call = '{{ $value }}'"
class="{{ $demoButton }}"
>{{ $text }}</button>
@endforeach
</div>
</div>import { useState } from "react";
import {
DynamicIsland,
type DynamicIslandState,
} from "@/components/markas/DynamicIsland";
const panel = "grid gap-4";
const stage =
"@container h-[150px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const island = "[--island-expanded-height:4.75rem]";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const caller = "text-success";
const callIcon = "size-4 text-success";
const timer = "text-success tabular-nums";
const row = "flex h-full items-center gap-3";
const avatar =
"grid size-11 shrink-0 place-items-center rounded-full bg-subtle text-sm font-semibold";
const who = "min-w-0 flex-1";
const label = "text-xs text-muted";
const name = "truncate text-base font-semibold";
const round =
"grid size-11 shrink-0 place-items-center rounded-full text-canvas transition-[scale] duration-150 ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-90 motion-reduce:transition-none";
const decline = `${round} bg-danger`;
const accept = `${round} bg-success`;
const icon = "size-5";
const PHONE =
"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2";
const HANG_UP =
"M3 15.5c5-4.5 13-4.5 18 0l-1.5 2.5-4-1v-2.5a10 10 0 0 0-7 0V17l-4 1z";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "On call" },
{ value: "expanded", label: "Ringing" },
];
const Icon = ({ d, className }: { d: string; className: string }) => (
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
className={className}
>
<path d={d} />
</svg>
);
export default function Example() {
const [state, setState] = useState<DynamicIslandState>("expanded");
return (
<div className={panel}>
<div className={stage}>
<DynamicIsland
state={state}
className={island}
announcements={{
expanded: "Incoming call from Rina Santoso",
compact: "Call connected",
}}
leading={
<>
<Icon d={PHONE} className={callIcon} />
<span className={caller}>Rina</span>
</>
}
trailing={<span className={timer}>0:42</span>}
expanded={
<div className={row}>
<span aria-hidden="true" className={avatar}>
RS
</span>
<div className={who}>
<p className={label}>Mobile</p>
<p className={name}>Rina Santoso</p>
</div>
<button
type="button"
aria-label="Decline"
className={decline}
onClick={() => setState("idle")}
>
<Icon d={HANG_UP} className={icon} />
</button>
<button
type="button"
aria-label="Accept"
className={accept}
onClick={() => setState("compact")}
>
<Icon d={PHONE} className={icon} />
</button>
</div>
}
/>
</div>
<div role="group" aria-label="Call state" className={controls}>
{states.map((item) => (
<button
key={item.value}
type="button"
aria-pressed={state === item.value}
className={demoButton}
onClick={() => setState(item.value)}
>
{item.label}
</button>
))}
</div>
</div>
);
}<script setup lang="ts">
import { ref } from "vue";
import DynamicIsland, {
type DynamicIslandState,
} from "@/components/markas/DynamicIsland.vue";
const panel = "grid gap-4";
const stage =
"@container h-[150px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const island = "[--island-expanded-height:4.75rem]";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const caller = "text-success";
const callIcon = "size-4 text-success";
const timer = "text-success tabular-nums";
const row = "flex h-full items-center gap-3";
const avatar =
"grid size-11 shrink-0 place-items-center rounded-full bg-subtle text-sm font-semibold";
const who = "min-w-0 flex-1";
const label = "text-xs text-muted";
const name = "truncate text-base font-semibold";
const round =
"grid size-11 shrink-0 place-items-center rounded-full text-canvas transition-[scale] duration-150 ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-90 motion-reduce:transition-none";
const decline = `${round} bg-danger`;
const accept = `${round} bg-success`;
const icon = "size-5";
const PHONE =
"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2";
const HANG_UP =
"M3 15.5c5-4.5 13-4.5 18 0l-1.5 2.5-4-1v-2.5a10 10 0 0 0-7 0V17l-4 1z";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "On call" },
{ value: "expanded", label: "Ringing" },
];
const state = ref<DynamicIslandState>("expanded");
</script>
<template>
<div :class="panel">
<div :class="stage">
<DynamicIsland
:state="state"
:class="island"
:announcements="{
expanded: 'Incoming call from Rina Santoso',
compact: 'Call connected',
}"
>
<template #leading>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
:class="callIcon"
>
<path :d="PHONE" />
</svg>
<span :class="caller">Rina</span>
</template>
<template #trailing>
<span :class="timer">0:42</span>
</template>
<template #expanded>
<div :class="row">
<span aria-hidden="true" :class="avatar">RS</span>
<div :class="who">
<p :class="label">Mobile</p>
<p :class="name">Rina Santoso</p>
</div>
<button
type="button"
aria-label="Decline"
:class="decline"
@click="state = 'idle'"
>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
:class="icon"
>
<path :d="HANG_UP" />
</svg>
</button>
<button
type="button"
aria-label="Accept"
:class="accept"
@click="state = 'compact'"
>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
:class="icon"
>
<path :d="PHONE" />
</svg>
</button>
</div>
</template>
</DynamicIsland>
</div>
<div role="group" aria-label="Call state" :class="controls">
<button
v-for="item in states"
:key="item.value"
type="button"
:aria-pressed="state === item.value"
:class="demoButton"
@click="state = item.value"
>
{{ item.label }}
</button>
</div>
</div>
</template><script lang="ts">
import DynamicIsland, {
type DynamicIslandState,
} from "$lib/components/markas/DynamicIsland.svelte";
const panel = "grid gap-4";
const stage =
"@container h-[150px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const island = "[--island-expanded-height:4.75rem]";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const caller = "text-success";
const callIcon = "size-4 text-success";
const timer = "text-success tabular-nums";
const row = "flex h-full items-center gap-3";
const avatar =
"grid size-11 shrink-0 place-items-center rounded-full bg-subtle text-sm font-semibold";
const who = "min-w-0 flex-1";
const label = "text-xs text-muted";
const name = "truncate text-base font-semibold";
const round =
"grid size-11 shrink-0 place-items-center rounded-full text-canvas transition-[scale] duration-150 ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-90 motion-reduce:transition-none";
const decline = `${round} bg-danger`;
const accept = `${round} bg-success`;
const icon = "size-5";
const PHONE =
"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2";
const HANG_UP =
"M3 15.5c5-4.5 13-4.5 18 0l-1.5 2.5-4-1v-2.5a10 10 0 0 0-7 0V17l-4 1z";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "On call" },
{ value: "expanded", label: "Ringing" },
];
let state = $state<DynamicIslandState>("expanded");
</script>
{#snippet svg(d: string, className: string)}
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={className}
>
<path {d} />
</svg>
{/snippet}
<div class={panel}>
<div class={stage}>
<DynamicIsland
{state}
class={island}
announcements={{
expanded: "Incoming call from Rina Santoso",
compact: "Call connected",
}}
>
{#snippet leading()}
{@render svg(PHONE, callIcon)}
<span class={caller}>Rina</span>
{/snippet}
{#snippet trailing()}
<span class={timer}>0:42</span>
{/snippet}
{#snippet expanded()}
<div class={row}>
<span aria-hidden="true" class={avatar}>RS</span>
<div class={who}>
<p class={label}>Mobile</p>
<p class={name}>Rina Santoso</p>
</div>
<button
type="button"
aria-label="Decline"
class={decline}
onclick={() => (state = "idle")}
>
{@render svg(HANG_UP, icon)}
</button>
<button
type="button"
aria-label="Accept"
class={accept}
onclick={() => (state = "compact")}
>
{@render svg(PHONE, icon)}
</button>
</div>
{/snippet}
</DynamicIsland>
</div>
<div role="group" aria-label="Call state" class={controls}>
{#each states as item (item.value)}
<button
type="button"
aria-pressed={state === item.value}
class={demoButton}
onclick={() => (state = item.value)}>{item.label}</button
>
{/each}
</div>
</div>---
import DynamicIsland, { type DynamicIslandState } from "@/components/markas/DynamicIsland.astro";
const panel = "grid gap-4";
const stage = "@container h-[150px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const island = "[--island-expanded-height:4.75rem]";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const caller = "text-success";
const callIcon = "size-4 text-success";
const timer = "text-success tabular-nums";
const row = "flex h-full items-center gap-3";
const avatar =
"grid size-11 shrink-0 place-items-center rounded-full bg-subtle text-sm font-semibold";
const who = "min-w-0 flex-1";
const label = "text-xs text-muted";
const name = "truncate text-base font-semibold";
const round =
"grid size-11 shrink-0 place-items-center rounded-full text-canvas transition-[scale] duration-150 ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-90 motion-reduce:transition-none";
const decline = `${round} bg-danger`;
const accept = `${round} bg-success`;
const icon = "size-5";
const PHONE =
"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2";
const HANG_UP =
"M3 15.5c5-4.5 13-4.5 18 0l-1.5 2.5-4-1v-2.5a10 10 0 0 0-7 0V17l-4 1z";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "On call" },
{ value: "expanded", label: "Ringing" },
];
---
<div class={panel} data-island-demo>
<div class={stage}>
<DynamicIsland
state="expanded"
class={island}
announcements={{
expanded: "Incoming call from Rina Santoso",
compact: "Call connected",
}}
>
<Fragment slot="leading">
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={callIcon}
>
<path d={PHONE}></path>
</svg>
<span class={caller}>Rina</span>
</Fragment>
<span slot="trailing" class={timer}>0:42</span>
<div slot="expanded" class={row}>
<span aria-hidden="true" class={avatar}>RS</span>
<div class={who}>
<p class={label}>Mobile</p>
<p class={name}>Rina Santoso</p>
</div>
<button type="button" aria-label="Decline" class={decline} data-island-set="idle">
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={icon}
>
<path d={HANG_UP}></path>
</svg>
</button>
<button type="button" aria-label="Accept" class={accept} data-island-set="compact">
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={icon}
>
<path d={PHONE}></path>
</svg>
</button>
</div>
</DynamicIsland>
</div>
<div role="group" aria-label="Call state" class={controls}>
{
states.map((item) => (
<button
type="button"
aria-pressed={item.value === "expanded" ? "true" : "false"}
data-island-set={item.value}
class={demoButton}
>
{item.label}
</button>
))
}
</div>
</div>
<script>
// Demo wiring: buttons with data-island-set move the island to that state.
document.addEventListener("click", (event) => {
const button = (event.target as Element).closest<HTMLElement>(
"[data-island-set]",
);
const demo = button?.closest("[data-island-demo]");
if (!button || !demo) return;
const state = button.dataset.islandSet ?? "idle";
demo.querySelector("markas-dynamic-island")?.setAttribute("state", state);
demo.querySelectorAll("[aria-pressed]").forEach((other) =>
other.setAttribute(
"aria-pressed",
String(other.getAttribute("data-island-set") === state),
),
);
});
</script>import { Component, signal } from "@angular/core";
import {
DynamicIsland,
type DynamicIslandState,
} from "./markas/dynamic-island.component";
@Component({
selector: "markas-example",
imports: [DynamicIsland],
template: `
<div [class]="panel">
<div [class]="stage">
<markas-dynamic-island
[state]="state()"
[class]="island"
[announcements]="announcements"
>
<ng-container leading>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
[class]="callIcon"
>
<path [attr.d]="PHONE" />
</svg>
<span [class]="caller">Rina</span>
</ng-container>
<span trailing [class]="timer">0:42</span>
<div expanded [class]="row">
<span aria-hidden="true" [class]="avatar">RS</span>
<div [class]="who">
<p [class]="label">Mobile</p>
<p [class]="name">Rina Santoso</p>
</div>
<button
type="button"
aria-label="Decline"
[class]="decline"
(click)="state.set('idle')"
>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
[class]="icon"
>
<path [attr.d]="HANG_UP" />
</svg>
</button>
<button
type="button"
aria-label="Accept"
[class]="accept"
(click)="state.set('compact')"
>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
[class]="icon"
>
<path [attr.d]="PHONE" />
</svg>
</button>
</div>
</markas-dynamic-island>
</div>
<div role="group" aria-label="Call state" [class]="controls">
@for (item of states; track item.value) {
<button
type="button"
[attr.aria-pressed]="state() === item.value"
[class]="demoButton"
(click)="state.set(item.value)"
>
{{ item.label }}
</button>
}
</div>
</div>
`,
})
export default class DynamicIslandCallExample {
protected readonly panel = "grid gap-4";
protected readonly stage =
"@container h-[150px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
protected readonly island = "[--island-expanded-height:4.75rem]";
protected readonly controls = "flex justify-center gap-1.5";
protected readonly demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
protected readonly caller = "text-success";
protected readonly callIcon = "size-4 text-success";
protected readonly timer = "text-success tabular-nums";
protected readonly row = "flex h-full items-center gap-3";
protected readonly avatar =
"grid size-11 shrink-0 place-items-center rounded-full bg-subtle text-sm font-semibold";
protected readonly who = "min-w-0 flex-1";
protected readonly label = "text-xs text-muted";
protected readonly name = "truncate text-base font-semibold";
private readonly round =
"grid size-11 shrink-0 place-items-center rounded-full text-canvas transition-[scale] duration-150 ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-90 motion-reduce:transition-none";
protected readonly decline = `${this.round} bg-danger`;
protected readonly accept = `${this.round} bg-success`;
protected readonly icon = "size-5";
protected readonly PHONE =
"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2";
protected readonly HANG_UP =
"M3 15.5c5-4.5 13-4.5 18 0l-1.5 2.5-4-1v-2.5a10 10 0 0 0-7 0V17l-4 1z";
protected readonly states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "On call" },
{ value: "expanded", label: "Ringing" },
];
protected readonly announcements = {
expanded: "Incoming call from Rina Santoso",
compact: "Call connected",
};
protected readonly state = signal<DynamicIslandState>("expanded");
}Pembayaran diterima
Payment received
Rp 2.500.000
PT Sinar Jaya, invoice INV-2041
Payment received, Rp 2.500.000
Payment received
Rp 2.500.000
PT Sinar Jaya, invoice INV-2041
Payment received, Rp 2.500.000
Payment received
Rp 2.500.000
PT Sinar Jaya, invoice INV-2041
Payment received, Rp 2.500.000
Payment received
Rp 2.500.000
PT Sinar Jaya, invoice INV-2041
Payment received, Rp 2.500.000
Payment received
Rp 2.500.000
PT Sinar Jaya, invoice INV-2041
Payment received, Rp 2.500.000
@php
$panel = 'grid gap-4';
$stage = '@container h-[190px] rounded-[2rem] border border-line bg-surface px-3 pt-3';
$controls = 'flex justify-center gap-1.5';
$demoButton = 'h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none';
$check = 'size-4 text-success';
$amount = 'text-success tabular-nums';
$card = 'grid h-full content-between';
$label = 'flex items-center gap-1.5 text-xs text-success';
$big = 'pt-1 text-2xl leading-tight font-semibold tabular-nums';
$from = 'text-xs text-muted';
$view = 'h-9 w-full rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none';
$checkPath = 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM8 12l3 3 5-6';
$states = ['idle' => 'Idle', 'compact' => 'Compact', 'expanded' => 'Expanded'];
@endphp
<div x-data="{ island: 'compact' }" class="{{ $panel }}">
<div class="{{ $stage }}">
<x-markas.dynamic-island
state="compact"
x-model="island"
:announcements="['compact' => 'Payment received, Rp 2.500.000', 'expanded' => 'Payment received, Rp 2.500.000 from PT Sinar Jaya for invoice INV-2041']"
>
<x-slot:leading>
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="{{ $check }}"><path d="{{ $checkPath }}" /></svg>
</x-slot:leading>
<x-slot:trailing>
<span class="{{ $amount }}">+Rp2,5jt</span>
</x-slot:trailing>
<x-slot:expanded>
<div class="{{ $card }}">
<div>
<p class="{{ $label }}"><svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="{{ $check }}"><path d="{{ $checkPath }}" /></svg>Payment received</p>
<p class="{{ $big }}">Rp 2.500.000</p>
<p class="{{ $from }}">PT Sinar Jaya, invoice INV-2041</p>
</div>
<button type="button" class="{{ $view }}">View invoice</button>
</div>
</x-slot:expanded>
</x-markas.dynamic-island>
</div>
<div role="group" aria-label="Island state" class="{{ $controls }}">
@foreach ($states as $value => $text)
<button
type="button"
aria-pressed="{{ $value === 'compact' ? 'true' : 'false' }}"
x-bind:aria-pressed="island === '{{ $value }}'"
x-on:click="island = '{{ $value }}'"
class="{{ $demoButton }}"
>{{ $text }}</button>
@endforeach
</div>
</div>import { useState } from "react";
import {
DynamicIsland,
type DynamicIslandState,
} from "@/components/markas/DynamicIsland";
const panel = "grid gap-4";
const stage =
"@container h-[190px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const check = "size-4 text-success";
const amount = "text-success tabular-nums";
const card = "grid h-full content-between";
const label = "flex items-center gap-1.5 text-xs text-success";
const big = "pt-1 text-2xl leading-tight font-semibold tabular-nums";
const from = "text-xs text-muted";
const view =
"h-9 w-full rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const CHECK = "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM8 12l3 3 5-6";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
const Check = () => (
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
className={check}
>
<path d={CHECK} />
</svg>
);
export default function Example() {
const [state, setState] = useState<DynamicIslandState>("compact");
return (
<div className={panel}>
<div className={stage}>
<DynamicIsland
state={state}
announcements={{
compact: "Payment received, Rp 2.500.000",
expanded:
"Payment received, Rp 2.500.000 from PT Sinar Jaya for invoice INV-2041",
}}
leading={<Check />}
trailing={<span className={amount}>+Rp2,5jt</span>}
expanded={
<div className={card}>
<div>
<p className={label}>
<Check />
Payment received
</p>
<p className={big}>Rp 2.500.000</p>
<p className={from}>PT Sinar Jaya, invoice INV-2041</p>
</div>
<button type="button" className={view}>
View invoice
</button>
</div>
}
/>
</div>
<div role="group" aria-label="Island state" className={controls}>
{states.map((item) => (
<button
key={item.value}
type="button"
aria-pressed={state === item.value}
className={demoButton}
onClick={() => setState(item.value)}
>
{item.label}
</button>
))}
</div>
</div>
);
}<script setup lang="ts">
import { ref } from "vue";
import DynamicIsland, {
type DynamicIslandState,
} from "@/components/markas/DynamicIsland.vue";
const panel = "grid gap-4";
const stage =
"@container h-[190px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const check = "size-4 text-success";
const amount = "text-success tabular-nums";
const card = "grid h-full content-between";
const label = "flex items-center gap-1.5 text-xs text-success";
const big = "pt-1 text-2xl leading-tight font-semibold tabular-nums";
const from = "text-xs text-muted";
const view =
"h-9 w-full rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const CHECK = "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM8 12l3 3 5-6";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
const state = ref<DynamicIslandState>("compact");
</script>
<template>
<div :class="panel">
<div :class="stage">
<DynamicIsland
:state="state"
:announcements="{
compact: 'Payment received, Rp 2.500.000',
expanded:
'Payment received, Rp 2.500.000 from PT Sinar Jaya for invoice INV-2041',
}"
>
<template #leading>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
:class="check"
>
<path :d="CHECK" />
</svg>
</template>
<template #trailing>
<span :class="amount">+Rp2,5jt</span>
</template>
<template #expanded>
<div :class="card">
<div>
<p :class="label">
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
:class="check"
>
<path :d="CHECK" /></svg
>Payment received
</p>
<p :class="big">Rp 2.500.000</p>
<p :class="from">PT Sinar Jaya, invoice INV-2041</p>
</div>
<button type="button" :class="view">View invoice</button>
</div>
</template>
</DynamicIsland>
</div>
<div role="group" aria-label="Island state" :class="controls">
<button
v-for="item in states"
:key="item.value"
type="button"
:aria-pressed="state === item.value"
:class="demoButton"
@click="state = item.value"
>
{{ item.label }}
</button>
</div>
</div>
</template><script lang="ts">
import DynamicIsland, {
type DynamicIslandState,
} from "$lib/components/markas/DynamicIsland.svelte";
const panel = "grid gap-4";
const stage =
"@container h-[190px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const check = "size-4 text-success";
const amount = "text-success tabular-nums";
const card = "grid h-full content-between";
const label = "flex items-center gap-1.5 text-xs text-success";
const big = "pt-1 text-2xl leading-tight font-semibold tabular-nums";
const from = "text-xs text-muted";
const view =
"h-9 w-full rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const CHECK = "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM8 12l3 3 5-6";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
let state = $state<DynamicIslandState>("compact");
</script>
{#snippet checkIcon()}
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={check}
>
<path d={CHECK} />
</svg>
{/snippet}
<div class={panel}>
<div class={stage}>
<DynamicIsland
{state}
announcements={{
compact: "Payment received, Rp 2.500.000",
expanded:
"Payment received, Rp 2.500.000 from PT Sinar Jaya for invoice INV-2041",
}}
>
{#snippet leading()}
{@render checkIcon()}
{/snippet}
{#snippet trailing()}
<span class={amount}>+Rp2,5jt</span>
{/snippet}
{#snippet expanded()}
<div class={card}>
<div>
<p class={label}>
{@render checkIcon()}
Payment received
</p>
<p class={big}>Rp 2.500.000</p>
<p class={from}>PT Sinar Jaya, invoice INV-2041</p>
</div>
<button type="button" class={view}>View invoice</button>
</div>
{/snippet}
</DynamicIsland>
</div>
<div role="group" aria-label="Island state" class={controls}>
{#each states as item (item.value)}
<button
type="button"
aria-pressed={state === item.value}
class={demoButton}
onclick={() => (state = item.value)}>{item.label}</button
>
{/each}
</div>
</div>---
import DynamicIsland, { type DynamicIslandState } from "@/components/markas/DynamicIsland.astro";
const panel = "grid gap-4";
const stage = "@container h-[190px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
const controls = "flex justify-center gap-1.5";
const demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
const check = "size-4 text-success";
const amount = "text-success tabular-nums";
const card = "grid h-full content-between";
const label = "flex items-center gap-1.5 text-xs text-success";
const big = "pt-1 text-2xl leading-tight font-semibold tabular-nums";
const from = "text-xs text-muted";
const view =
"h-9 w-full rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
const CHECK = "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM8 12l3 3 5-6";
const states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
---
<div class={panel} data-island-demo>
<div class={stage}>
<DynamicIsland
state="compact"
announcements={{
compact: "Payment received, Rp 2.500.000",
expanded:
"Payment received, Rp 2.500.000 from PT Sinar Jaya for invoice INV-2041",
}}
>
<Fragment slot="leading">
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={check}
>
<path d={CHECK}></path>
</svg>
</Fragment>
<span slot="trailing" class={amount}>+Rp2,5jt</span>
<div slot="expanded" class={card}>
<div>
<p class={label}>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
class={check}
>
<path d={CHECK}></path>
</svg>
Payment received
</p>
<p class={big}>Rp 2.500.000</p>
<p class={from}>PT Sinar Jaya, invoice INV-2041</p>
</div>
<button type="button" class={view}>View invoice</button>
</div>
</DynamicIsland>
</div>
<div role="group" aria-label="Island state" class={controls}>
{
states.map((item) => (
<button
type="button"
aria-pressed={item.value === "compact" ? "true" : "false"}
data-island-set={item.value}
class={demoButton}
>
{item.label}
</button>
))
}
</div>
</div>
<script>
// Demo wiring: buttons with data-island-set move the island to that state.
document.addEventListener("click", (event) => {
const button = (event.target as Element).closest<HTMLElement>(
"[data-island-set]",
);
const demo = button?.closest("[data-island-demo]");
if (!button || !demo) return;
const state = button.dataset.islandSet ?? "idle";
demo.querySelector("markas-dynamic-island")?.setAttribute("state", state);
demo.querySelectorAll("[aria-pressed]").forEach((other) =>
other.setAttribute(
"aria-pressed",
String(other.getAttribute("data-island-set") === state),
),
);
});
</script>import { Component, signal } from "@angular/core";
import {
DynamicIsland,
type DynamicIslandState,
} from "./markas/dynamic-island.component";
@Component({
selector: "markas-example",
imports: [DynamicIsland],
template: `
<div [class]="panel">
<div [class]="stage">
<markas-dynamic-island
[state]="state()"
[announcements]="announcements"
>
<ng-container leading>
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
[class]="check"
>
<path [attr.d]="CHECK" />
</svg>
</ng-container>
<span trailing [class]="amount">+Rp2,5jt</span>
<div expanded [class]="card">
<div>
<p [class]="label">
<svg
aria-hidden="true"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
[class]="check"
>
<path [attr.d]="CHECK" />
</svg>
Payment received
</p>
<p [class]="big">Rp 2.500.000</p>
<p [class]="from">PT Sinar Jaya, invoice INV-2041</p>
</div>
<button type="button" [class]="view">View invoice</button>
</div>
</markas-dynamic-island>
</div>
<div role="group" aria-label="Island state" [class]="controls">
@for (item of states; track item.value) {
<button
type="button"
[attr.aria-pressed]="state() === item.value"
[class]="demoButton"
(click)="state.set(item.value)"
>
{{ item.label }}
</button>
}
</div>
</div>
`,
})
export default class DynamicIslandPaymentExample {
protected readonly panel = "grid gap-4";
protected readonly stage =
"@container h-[190px] rounded-[2rem] border border-line bg-surface px-3 pt-3";
protected readonly controls = "flex justify-center gap-1.5";
protected readonly demoButton =
"h-8 rounded-full border border-line bg-surface px-3 text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-subtle focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-on-primary motion-reduce:transition-none";
protected readonly check = "size-4 text-success";
protected readonly amount = "text-success tabular-nums";
protected readonly card = "grid h-full content-between";
protected readonly label = "flex items-center gap-1.5 text-xs text-success";
protected readonly big =
"pt-1 text-2xl leading-tight font-semibold tabular-nums";
protected readonly from = "text-xs text-muted";
protected readonly view =
"h-9 w-full rounded-full bg-subtle text-sm font-medium text-ink transition-colors duration-150 ease-out hover:bg-line focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none";
protected readonly CHECK =
"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM8 12l3 3 5-6";
protected readonly states: { value: DynamicIslandState; label: string }[] = [
{ value: "idle", label: "Idle" },
{ value: "compact", label: "Compact" },
{ value: "expanded", label: "Expanded" },
];
protected readonly announcements = {
compact: "Payment received, Rp 2.500.000",
expanded:
"Payment received, Rp 2.500.000 from PT Sinar Jaya for invoice INV-2041",
};
protected readonly state = signal<DynamicIslandState>("compact");
}Instalasi
npx markasui@latest add dynamic-islandpnpm dlx markasui@latest add dynamic-islandyarn dlx markasui@latest add dynamic-islandbunx --bun markasui@latest add dynamic-island- 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/dynamic-island.blade.php.
@props([
'state' => 'idle',
'announcements' => [],
'islandLabel' => 'Live activity',
])
@php
// The island re-scopes the theme with the dark class, so it reads as a black pill in both modes.
$root = 'dark relative mx-auto max-w-full overflow-hidden bg-canvas text-ink ring-1 ring-line transition-[width,height,border-radius] duration-500 ease-[cubic-bezier(0.32,1.2,0.5,1)] motion-reduce:transition-none data-[state=compact]:h-9 data-[state=compact]:w-[var(--island-compact-width,15rem)] data-[state=compact]:rounded-[18px] data-[state=expanded]:h-[var(--island-expanded-height,9.5rem)] data-[state=expanded]:w-[var(--island-expanded-width,22rem)] data-[state=expanded]:rounded-[32px] data-[state=idle]:h-9 data-[state=idle]:w-[var(--island-idle-width,7.5rem)] data-[state=idle]:rounded-[18px]';
$panel = 'absolute top-0 left-1/2 max-w-[100cqw] origin-top -translate-x-1/2 transition-[opacity,scale,filter] duration-300 ease-out motion-reduce:transition-none data-[state=active]:delay-150 data-[state=inactive]:pointer-events-none data-[state=inactive]:scale-90 data-[state=inactive]:opacity-0 data-[state=inactive]:blur-sm';
$panels = [
'idle' => 'grid h-9 w-[var(--island-idle-width,7.5rem)] place-items-center',
'compact' => 'flex h-9 w-[var(--island-compact-width,15rem)] items-center justify-between gap-3 px-3 text-xs font-medium',
'expanded' => 'h-[var(--island-expanded-height,9.5rem)] w-[var(--island-expanded-width,22rem)] p-4',
];
$side = 'flex min-w-0 items-center gap-2';
$srOnly = 'sr-only';
$slots = $__laravel_slots ?? [];
@endphp
{{-- Controlled from outside: bind a parent value with x-model, it is the island's state. --}}
<div
x-data="{ state: @js($state), announcements: @js((object) $announcements) }"
x-modelable="state"
role="region"
aria-label="{{ $islandLabel }}"
data-state="{{ $state }}"
x-bind:data-state="state"
{{ $attributes->class([$root]) }}
>
@foreach (['idle', 'compact', 'expanded'] as $name)
<div
data-state="{{ $state === $name ? 'active' : 'inactive' }}"
@if ($state !== $name) inert @endif
x-bind:data-state="state === '{{ $name }}' ? 'active' : 'inactive'"
x-bind:inert="state !== '{{ $name }}'"
class="{{ $panel }} {{ $panels[$name] }}"
>
@if ($name === 'compact')
<div class="{{ $side }}">{{ $slots['leading'] ?? '' }}</div>
<div class="{{ $side }}">{{ $slots['trailing'] ?? '' }}</div>
@else
{{ $slots[$name] ?? '' }}
@endif
</div>
@endforeach
<p aria-live="polite" class="{{ $srOnly }}" x-text="announcements[state] ?? ''">{{ $announcements[$state] ?? '' }}</p>
</div>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/DynamicIsland.tsx.
import type { ComponentProps, ReactNode } from "react";
/** The island re-scopes the theme with the dark class, so it reads as a black pill in both modes. */
const root =
"dark relative mx-auto max-w-full overflow-hidden bg-canvas text-ink ring-1 ring-line transition-[width,height,border-radius] duration-500 ease-[cubic-bezier(0.32,1.2,0.5,1)] motion-reduce:transition-none data-[state=compact]:h-9 data-[state=compact]:w-[var(--island-compact-width,15rem)] data-[state=compact]:rounded-[18px] data-[state=expanded]:h-[var(--island-expanded-height,9.5rem)] data-[state=expanded]:w-[var(--island-expanded-width,22rem)] data-[state=expanded]:rounded-[32px] data-[state=idle]:h-9 data-[state=idle]:w-[var(--island-idle-width,7.5rem)] data-[state=idle]:rounded-[18px]";
const panel =
"absolute top-0 left-1/2 max-w-[100cqw] origin-top -translate-x-1/2 transition-[opacity,scale,filter] duration-300 ease-out motion-reduce:transition-none data-[state=active]:delay-150 data-[state=inactive]:pointer-events-none data-[state=inactive]:scale-90 data-[state=inactive]:opacity-0 data-[state=inactive]:blur-sm";
const panels = {
idle: "grid h-9 w-[var(--island-idle-width,7.5rem)] place-items-center",
compact:
"flex h-9 w-[var(--island-compact-width,15rem)] items-center justify-between gap-3 px-3 text-xs font-medium",
expanded:
"h-[var(--island-expanded-height,9.5rem)] w-[var(--island-expanded-width,22rem)] p-4",
};
const side = "flex min-w-0 items-center gap-2";
const srOnly = "sr-only";
const cx = (...c: (string | false | null | undefined)[]) =>
c.filter(Boolean).join(" ");
export type DynamicIslandState = "idle" | "compact" | "expanded";
export type DynamicIslandProps = ComponentProps<"div"> & {
state?: DynamicIslandState;
/** Content of the small idle pill, usually empty. */
idle?: ReactNode;
/** Left side of the compact pill, such as an icon. */
leading?: ReactNode;
/** Right side of the compact pill, such as a time or level. */
trailing?: ReactNode;
/** Content of the large card. */
expanded?: ReactNode;
/** Text read by screen readers when the island moves to a state. */
announcements?: Partial<Record<DynamicIslandState, string>>;
islandLabel?: string;
};
export function DynamicIsland({
state = "idle",
idle,
leading,
trailing,
expanded,
announcements = {},
islandLabel = "Live activity",
className,
...props
}: DynamicIslandProps) {
const panelProps = (name: DynamicIslandState) => ({
"data-state": state === name ? "active" : "inactive",
inert: state !== name,
className: cx(panel, panels[name]),
});
return (
<div
role="region"
aria-label={islandLabel}
data-state={state}
className={cx(root, className)}
{...props}
>
<div {...panelProps("idle")}>{idle}</div>
<div {...panelProps("compact")}>
<div className={side}>{leading}</div>
<div className={side}>{trailing}</div>
</div>
<div {...panelProps("expanded")}>{expanded}</div>
<p aria-live="polite" className={srOnly}>
{announcements[state] ?? ""}
</p>
</div>
);
}- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/DynamicIsland.vue.
<script setup lang="ts">
export type DynamicIslandState = "idle" | "compact" | "expanded";
const props = withDefaults(
defineProps<{
state?: DynamicIslandState;
/** Text read by screen readers when the island moves to a state. */
announcements?: Partial<Record<DynamicIslandState, string>>;
islandLabel?: string;
}>(),
{ state: "idle", announcements: () => ({}), islandLabel: "Live activity" },
);
/** The island re-scopes the theme with the dark class, so it reads as a black pill in both modes. */
const root =
"dark relative mx-auto max-w-full overflow-hidden bg-canvas text-ink ring-1 ring-line transition-[width,height,border-radius] duration-500 ease-[cubic-bezier(0.32,1.2,0.5,1)] motion-reduce:transition-none data-[state=compact]:h-9 data-[state=compact]:w-[var(--island-compact-width,15rem)] data-[state=compact]:rounded-[18px] data-[state=expanded]:h-[var(--island-expanded-height,9.5rem)] data-[state=expanded]:w-[var(--island-expanded-width,22rem)] data-[state=expanded]:rounded-[32px] data-[state=idle]:h-9 data-[state=idle]:w-[var(--island-idle-width,7.5rem)] data-[state=idle]:rounded-[18px]";
const panel =
"absolute top-0 left-1/2 max-w-[100cqw] origin-top -translate-x-1/2 transition-[opacity,scale,filter] duration-300 ease-out motion-reduce:transition-none data-[state=active]:delay-150 data-[state=inactive]:pointer-events-none data-[state=inactive]:scale-90 data-[state=inactive]:opacity-0 data-[state=inactive]:blur-sm";
const panels = {
idle: "grid h-9 w-[var(--island-idle-width,7.5rem)] place-items-center",
compact:
"flex h-9 w-[var(--island-compact-width,15rem)] items-center justify-between gap-3 px-3 text-xs font-medium",
expanded:
"h-[var(--island-expanded-height,9.5rem)] w-[var(--island-expanded-width,22rem)] p-4",
};
const side = "flex min-w-0 items-center gap-2";
const srOnly = "sr-only";
const stateOf = (name: DynamicIslandState) =>
props.state === name ? "active" : "inactive";
</script>
<template>
<div
role="region"
:aria-label="props.islandLabel"
:data-state="props.state"
:class="root"
>
<div
:data-state="stateOf('idle')"
:inert="props.state !== 'idle' || undefined"
:class="[panel, panels.idle]"
>
<slot name="idle" />
</div>
<div
:data-state="stateOf('compact')"
:inert="props.state !== 'compact' || undefined"
:class="[panel, panels.compact]"
>
<div :class="side"><slot name="leading" /></div>
<div :class="side"><slot name="trailing" /></div>
</div>
<div
:data-state="stateOf('expanded')"
:inert="props.state !== 'expanded' || undefined"
:class="[panel, panels.expanded]"
>
<slot name="expanded" />
</div>
<p aria-live="polite" :class="srOnly">
{{ props.announcements[props.state] ?? "" }}
</p>
</div>
</template>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/lib/components/markas/DynamicIsland.svelte.
<script lang="ts" module>
export type DynamicIslandState = "idle" | "compact" | "expanded";
</script>
<script lang="ts">
import type { Snippet } from "svelte";
import type { HTMLAttributes } from "svelte/elements";
/** The island re-scopes the theme with the dark class, so it reads as a black pill in both modes. */
const root =
"dark relative mx-auto max-w-full overflow-hidden bg-canvas text-ink ring-1 ring-line transition-[width,height,border-radius] duration-500 ease-[cubic-bezier(0.32,1.2,0.5,1)] motion-reduce:transition-none data-[state=compact]:h-9 data-[state=compact]:w-[var(--island-compact-width,15rem)] data-[state=compact]:rounded-[18px] data-[state=expanded]:h-[var(--island-expanded-height,9.5rem)] data-[state=expanded]:w-[var(--island-expanded-width,22rem)] data-[state=expanded]:rounded-[32px] data-[state=idle]:h-9 data-[state=idle]:w-[var(--island-idle-width,7.5rem)] data-[state=idle]:rounded-[18px]";
const panel =
"absolute top-0 left-1/2 max-w-[100cqw] origin-top -translate-x-1/2 transition-[opacity,scale,filter] duration-300 ease-out motion-reduce:transition-none data-[state=active]:delay-150 data-[state=inactive]:pointer-events-none data-[state=inactive]:scale-90 data-[state=inactive]:opacity-0 data-[state=inactive]:blur-sm";
const panels = {
idle: "grid h-9 w-[var(--island-idle-width,7.5rem)] place-items-center",
compact:
"flex h-9 w-[var(--island-compact-width,15rem)] items-center justify-between gap-3 px-3 text-xs font-medium",
expanded:
"h-[var(--island-expanded-height,9.5rem)] w-[var(--island-expanded-width,22rem)] p-4",
};
const side = "flex min-w-0 items-center gap-2";
const srOnly = "sr-only";
type Props = HTMLAttributes<HTMLDivElement> & {
state?: DynamicIslandState;
/** Content of the small idle pill, usually empty. */
idle?: Snippet;
/** Left side of the compact pill, such as an icon. */
leading?: Snippet;
/** Right side of the compact pill, such as a time or level. */
trailing?: Snippet;
/** Content of the large card. */
expanded?: Snippet;
/** Text read by screen readers when the island moves to a state. */
announcements?: Partial<Record<DynamicIslandState, string>>;
islandLabel?: string;
};
let {
state = "idle",
idle,
leading,
trailing,
expanded,
announcements = {},
islandLabel = "Live activity",
class: className,
...rest
}: Props = $props();
const stateOf = (name: DynamicIslandState) =>
state === name ? "active" : "inactive";
</script>
<div
role="region"
aria-label={islandLabel}
data-state={state}
class={[root, className]}
{...rest}
>
<div
data-state={stateOf("idle")}
inert={state !== "idle"}
class={[panel, panels.idle]}
>
{@render idle?.()}
</div>
<div
data-state={stateOf("compact")}
inert={state !== "compact"}
class={[panel, panels.compact]}
>
<div class={side}>{@render leading?.()}</div>
<div class={side}>{@render trailing?.()}</div>
</div>
<div
data-state={stateOf("expanded")}
inert={state !== "expanded"}
class={[panel, panels.expanded]}
>
{@render expanded?.()}
</div>
<p aria-live="polite" class={srOnly}>{announcements[state] ?? ""}</p>
</div>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/components/markas/DynamicIsland.astro.
---
import type { HTMLAttributes } from "astro/types";
export type DynamicIslandState = "idle" | "compact" | "expanded";
/** The island re-scopes the theme with the dark class, so it reads as a black pill in both modes. */
const root =
"dark relative mx-auto max-w-full overflow-hidden bg-canvas text-ink ring-1 ring-line transition-[width,height,border-radius] duration-500 ease-[cubic-bezier(0.32,1.2,0.5,1)] motion-reduce:transition-none data-[state=compact]:h-9 data-[state=compact]:w-[var(--island-compact-width,15rem)] data-[state=compact]:rounded-[18px] data-[state=expanded]:h-[var(--island-expanded-height,9.5rem)] data-[state=expanded]:w-[var(--island-expanded-width,22rem)] data-[state=expanded]:rounded-[32px] data-[state=idle]:h-9 data-[state=idle]:w-[var(--island-idle-width,7.5rem)] data-[state=idle]:rounded-[18px]";
const panel =
"absolute top-0 left-1/2 max-w-[100cqw] origin-top -translate-x-1/2 transition-[opacity,scale,filter] duration-300 ease-out motion-reduce:transition-none data-[state=active]:delay-150 data-[state=inactive]:pointer-events-none data-[state=inactive]:scale-90 data-[state=inactive]:opacity-0 data-[state=inactive]:blur-sm";
const panels = {
idle: "grid h-9 w-[var(--island-idle-width,7.5rem)] place-items-center",
compact:
"flex h-9 w-[var(--island-compact-width,15rem)] items-center justify-between gap-3 px-3 text-xs font-medium",
expanded:
"h-[var(--island-expanded-height,9.5rem)] w-[var(--island-expanded-width,22rem)] p-4",
};
const side = "flex min-w-0 items-center gap-2";
const srOnly = "sr-only";
type Props = HTMLAttributes<"div"> & {
/** First state. Change it later with setAttribute("state", ...) on markas-dynamic-island. */
state?: DynamicIslandState;
/** Text read by screen readers when the island moves to a state. */
announcements?: Partial<Record<DynamicIslandState, string>>;
islandLabel?: string;
};
const {
state = "idle",
announcements = {},
islandLabel = "Live activity",
class: className,
...rest
} = Astro.props;
const stateOf = (name: DynamicIslandState) => (state === name ? "active" : "inactive");
---
<markas-dynamic-island
class="contents"
state={state}
data-announcements={JSON.stringify(announcements)}
>
<div
role="region"
aria-label={islandLabel}
data-state={state}
class:list={[root, className]}
{...rest}
>
<div
data-state={stateOf("idle")}
data-panel="idle"
inert={state !== "idle"}
class:list={[panel, panels.idle]}
>
<slot name="idle" />
</div>
<div
data-state={stateOf("compact")}
data-panel="compact"
inert={state !== "compact"}
class:list={[panel, panels.compact]}
>
<div class={side}><slot name="leading" /></div>
<div class={side}><slot name="trailing" /></div>
</div>
<div
data-state={stateOf("expanded")}
data-panel="expanded"
inert={state !== "expanded"}
class:list={[panel, panels.expanded]}
>
<slot name="expanded" />
</div>
<p aria-live="polite" class={srOnly}>{announcements[state] ?? ""}</p>
</div>
</markas-dynamic-island>
<script>
// Controlled from outside: set the state attribute (island.setAttribute("state", "expanded"))
// and the island morphs. A custom element, so it also works for markup added later.
class MarkasDynamicIsland extends HTMLElement {
static observedAttributes = ["state"];
attributeChangedCallback() {
const state = this.getAttribute("state") ?? "idle";
const region = this.querySelector<HTMLElement>("[role=region]");
if (!region) return;
region.dataset.state = state;
this.querySelectorAll<HTMLElement>("[data-panel]").forEach((panel) => {
const active = panel.dataset.panel === state;
panel.dataset.state = active ? "active" : "inactive";
panel.inert = !active;
});
const announcements = JSON.parse(this.dataset.announcements ?? "{}");
const live = region.querySelector("[aria-live]");
if (live) live.textContent = announcements[state] ?? "";
}
}
if (!customElements.get("markas-dynamic-island"))
customElements.define("markas-dynamic-island", MarkasDynamicIsland);
</script>- Pastikan Tailwind CSS v4 dan markas.css sudah terpasang. Lihat Instalasi.
- Salin source komponen di bawah ini ke
src/app/markas/dynamic-island.component.ts.
import {
ChangeDetectionStrategy,
Component,
computed,
input,
} from "@angular/core";
export type DynamicIslandState = "idle" | "compact" | "expanded";
/** The island re-scopes the theme with the dark class, so it reads as a black pill in both modes. */
const root =
"dark relative mx-auto max-w-full overflow-hidden bg-canvas text-ink ring-1 ring-line transition-[width,height,border-radius] duration-500 ease-[cubic-bezier(0.32,1.2,0.5,1)] motion-reduce:transition-none data-[state=compact]:h-9 data-[state=compact]:w-[var(--island-compact-width,15rem)] data-[state=compact]:rounded-[18px] data-[state=expanded]:h-[var(--island-expanded-height,9.5rem)] data-[state=expanded]:w-[var(--island-expanded-width,22rem)] data-[state=expanded]:rounded-[32px] data-[state=idle]:h-9 data-[state=idle]:w-[var(--island-idle-width,7.5rem)] data-[state=idle]:rounded-[18px]";
const panel =
"absolute top-0 left-1/2 max-w-[100cqw] origin-top -translate-x-1/2 transition-[opacity,scale,filter] duration-300 ease-out motion-reduce:transition-none data-[state=active]:delay-150 data-[state=inactive]:pointer-events-none data-[state=inactive]:scale-90 data-[state=inactive]:opacity-0 data-[state=inactive]:blur-sm";
const panels = {
idle: "grid h-9 w-[var(--island-idle-width,7.5rem)] place-items-center",
compact:
"flex h-9 w-[var(--island-compact-width,15rem)] items-center justify-between gap-3 px-3 text-xs font-medium",
expanded:
"h-[var(--island-expanded-height,9.5rem)] w-[var(--island-expanded-width,22rem)] p-4",
};
const side = "flex min-w-0 items-center gap-2";
const srOnly = "sr-only";
/**
* Slots: elements with the `idle`, `leading`, `trailing`, or `expanded` attribute (an
* ng-container works). Host stays out of layout; class moves to the region.
*/
@Component({
selector: "markas-dynamic-island",
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: "contents" },
template: `
<div
role="region"
[attr.aria-label]="islandLabel()"
[attr.data-state]="state()"
[class]="rootClasses()"
>
<div
[attr.data-state]="stateOf('idle')"
[attr.inert]="state() !== 'idle' ? '' : null"
[class]="panelIdle"
>
<ng-content select="[idle]" />
</div>
<div
[attr.data-state]="stateOf('compact')"
[attr.inert]="state() !== 'compact' ? '' : null"
[class]="panelCompact"
>
<div [class]="side"><ng-content select="[leading]" /></div>
<div [class]="side"><ng-content select="[trailing]" /></div>
</div>
<div
[attr.data-state]="stateOf('expanded')"
[attr.inert]="state() !== 'expanded' ? '' : null"
[class]="panelExpanded"
>
<ng-content select="[expanded]" />
</div>
<p aria-live="polite" [class]="srOnly">{{ announcement() }}</p>
</div>
`,
})
export class DynamicIsland {
readonly state = input<DynamicIslandState>("idle");
/** Text read by screen readers when the island moves to a state. */
readonly announcements = input<Partial<Record<DynamicIslandState, string>>>(
{},
);
readonly islandLabel = input("Live activity");
readonly userClass = input("", { alias: "class" });
protected readonly panelIdle = `${panel} ${panels.idle}`;
protected readonly panelCompact = `${panel} ${panels.compact}`;
protected readonly panelExpanded = `${panel} ${panels.expanded}`;
protected readonly side = side;
protected readonly srOnly = srOnly;
protected readonly rootClasses = computed(() =>
[root, this.userClass()].filter(Boolean).join(" "),
);
protected readonly announcement = computed(
() => this.announcements()[this.state()] ?? "",
);
protected stateOf(name: DynamicIslandState) {
return this.state() === name ? "active" : "inactive";
}
}Pemakaian
<div x-data="{ island: 'compact' }">
<x-markas.dynamic-island
state="compact"
x-model="island"
island-label="Aktivitas langsung"
:announcements="['expanded' => 'Timer fokus, sisa 12 menit']"
>
<x-slot:leading><svg aria-hidden="true">...</svg></x-slot:leading>
<x-slot:trailing><span class="tabular-nums">12:48</span></x-slot:trailing>
<x-slot:expanded>
<p>Timer fokus</p>
<button type="button" x-on:click="island = 'idle'">Selesai</button>
</x-slot:expanded>
</x-markas.dynamic-island>
<button type="button" x-on:click="island = 'expanded'">Lihat timer</button>
</div>import { DynamicIsland } from "@/components/markas/DynamicIsland";
<DynamicIsland
state={state}
islandLabel="Aktivitas langsung"
leading={<IkonTimer />}
trailing={<span className="tabular-nums">12:48</span>}
expanded={<KartuTimer onSelesai={() => setState("idle")} />}
announcements={{ expanded: "Timer fokus, sisa 12 menit" }}
/>;<script setup lang="ts">
import DynamicIsland from "@/components/markas/DynamicIsland.vue";
</script>
<template>
<DynamicIsland
:state="state"
island-label="Aktivitas langsung"
:announcements="{ expanded: 'Timer fokus' }"
>
<template #leading><IkonTimer /></template>
<template #trailing><span class="tabular-nums">12:48</span></template>
<template #expanded><KartuTimer @selesai="state = 'idle'" /></template>
</DynamicIsland>
</template><script lang="ts">
import DynamicIsland, {
type DynamicIslandState,
} from "$lib/components/markas/DynamicIsland.svelte";
let state = $state<DynamicIslandState>("compact");
</script>
<DynamicIsland
{state}
announcements={{ expanded: "Focus timer, 12 minutes left" }}
>
{#snippet leading()}<TimerIcon />{/snippet}
{#snippet trailing()}<span class="tabular-nums">12:48</span>{/snippet}
{#snippet expanded()}
<TimerCard onEnd={() => (state = "idle")} />
{/snippet}
</DynamicIsland>---
import DynamicIsland from "@/components/markas/DynamicIsland.astro";
---
<DynamicIsland
state="compact"
announcements={{ expanded: "Focus timer, 12 minutes left" }}
>
<TimerIcon slot="leading" />
<span slot="trailing" class="tabular-nums">12:48</span>
<TimerCard slot="expanded" />
</DynamicIsland>
<script>
document
.querySelector("markas-dynamic-island")
?.setAttribute("state", "expanded");
</script>Island merender state pertama di server. Ubah setelahnya dengan mengatur atribut state di markas-dynamic-island; panel, inert, dan pengumuman ikut berubah.
import { Component, signal } from "@angular/core";
import {
DynamicIsland,
type DynamicIslandState,
} from "./markas/dynamic-island.component";
@Component({
selector: "app-timer-island",
imports: [DynamicIsland],
template: `
<markas-dynamic-island [state]="state()" [announcements]="announcements">
<span leading class="size-2 rounded-full bg-warning"></span>
<span trailing class="tabular-nums">12:48</span>
<div expanded>
<button type="button" (click)="state.set('idle')">End</button>
</div>
</markas-dynamic-island>
`,
})
export class TimerIsland {
state = signal<DynamicIslandState>("compact");
announcements = { expanded: "Focus timer, 12 minutes left" };
}Elemen dengan atribut idle, leading, trailing, atau expanded mengisi slot yang sesuai. ng-container juga bisa.
- Lebar, tinggi, dan radius sudut bergerak dengan satu transisi CSS yang memantul halus. Konten baru memudar masuk dan menajam sesaat kemudian.
- Isi setiap keadaan tetap di ukuran akhirnya dan terungkap oleh pill yang membesar, jadi teks tidak bergeser selama animasi.
- Island menambahkan class dark ke dirinya, jadi tampil sebagai pill hitam di halaman terang dan pill bercincin di halaman gelap, dan komponen di dalamnya memakai token gelap.
- Ukuran diambil dari
--island-idle-width,--island-compact-width,--island-expanded-width, dan--island-expanded-height(default 7.5rem, 15rem, 22rem, 9.5rem). - Island tidak pernah lebih lebar dari induknya. Isinya dibatasi oleh size container terdekat, atau layar kalau tidak ada, jadi beri induk yang sempit class
@container(seperti di contoh) supaya isinya ikut muat.
Props
| Nama | Tipe | Default | Keterangan |
|---|---|---|---|
state | "idle" | "compact" | "expanded" | idle | Keadaan saat ini, dikendalikan dari luar. Blade juga mengikuti nilai induk yang diikat dengan x-model. |
idle | ReactNode / slot | - | Isi pill idle kecil, biasanya kosong. |
leading | ReactNode / slot | - | Sisi kiri pill compact, misalnya ikon atau sampul album. |
trailing | ReactNode / slot | - | Sisi kanan pill compact, misalnya timer atau nilai singkat. |
expanded | ReactNode / slot | - | Isi kartu besar, cukup untuk teks dan tombol. |
announcements | { idle?: string; compact?: string; expanded?: string } | {} | Teks yang dibacakan live region polite saat island pindah ke keadaan itu. Isi hanya keadaan yang penting. |
islandLabel | string | Live activity | Nama aksesibel region island. Default "Live activity", isi misalnya "Aktivitas langsung". |
state attribute | idle | compact | expanded | - | Khusus Astro. Atur atribut state di markas-dynamic-island dari script untuk mengubah island setelah render pertama. |
Aksesibilitas
- Island adalah region bernama islandLabel. Isi keadaan yang tidak tampil bersifat inert, jadi tidak bisa difokus atau dibaca.
- Paragraf aria-live="polite" tersembunyi membacakan pengumuman keadaan saat ini, jadi perubahan penting terdengar tanpa memindah fokus.
- Perubahan ukuran dan crossfade murni transisi CSS. Dengan reduced motion island langsung melompat ke ukuran baru.
- Beri aria-label pada tombol ikon di dalam slot, dan letakkan kontrol yang mengubah keadaan di luar island.
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.