# Dynamic Island

Black pill inspired by the iPhone Dynamic Island. It morphs smoothly between idle, compact, and expanded states while its content crossfades.

- Category: MarkasUI
- Status: stable
- Registry: https://markas.jenderalcorp.com/r/dynamic-island.json
- CLI: `npx markasui@latest add dynamic-island`

## When to use

A playful status pill for timers, music, calls, uploads, or payments at the top of a mobile layout or app shell.

- Keep compact content to an icon on the left and a short value on the right
- Use expanded only for something that needs attention or actions
- Fill announcements for state changes people should hear, such as an incoming call
- Override --island-expanded-width and --island-expanded-height when the card content needs more room

## Code

### Blade

Save at `resources/views/components/markas/dynamic-island.blade.php`. Dependencies: alpinejs.

```blade
@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>
```

```blade
<div x-data="{ island: 'compact' }">
    <x-markas.dynamic-island
        state="compact"
        x-model="island"
        :announcements="['expanded' => 'Focus timer, 12 minutes left']"
    >
        <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>Focus timer</p>
            <button type="button" x-on:click="island = 'idle'">End</button>
        </x-slot:expanded>
    </x-markas.dynamic-island>
    <button type="button" x-on:click="island = 'expanded'">Show timer</button>
</div>
```

### React

Save at `src/components/markas/DynamicIsland.tsx`. No extra dependencies.

```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>
  );
}
```

```tsx
import { DynamicIsland } from "@/components/markas/DynamicIsland";

const [state, setState] = useState<"idle" | "compact" | "expanded">("compact");

<DynamicIsland
  state={state}
  leading={<TimerIcon />}
  trailing={<span className="tabular-nums">12:48</span>}
  expanded={<TimerCard onEnd={() => setState("idle")} />}
  announcements={{ expanded: "Focus timer, 12 minutes left" }}
/>;
```

### Vue

Save at `src/components/markas/DynamicIsland.vue`. No extra dependencies.

```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>
```

```vue
<script setup lang="ts">
import DynamicIsland from "@/components/markas/DynamicIsland.vue";

const state = ref<"idle" | "compact" | "expanded">("compact");
</script>

<template>
  <DynamicIsland :state="state" :announcements="{ expanded: 'Focus timer' }">
    <template #leading><TimerIcon /></template>
    <template #trailing><span class="tabular-nums">12:48</span></template>
    <template #expanded><TimerCard @end="state = 'idle'" /></template>
  </DynamicIsland>
</template>
```

### Svelte

Save at `src/lib/components/markas/DynamicIsland.svelte`. No extra dependencies.

```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>
```

```svelte
<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>
```

### Astro

Save at `src/components/markas/DynamicIsland.astro`. No extra dependencies.

```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>
```

```astro
---
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>
```

The island renders its first state on the server. Change it later by setting the `state` attribute on `markas-dynamic-island`; the panels, inert, and announcement follow.

### Angular

Save at `src/app/markas/dynamic-island.component.ts`. No extra dependencies.

```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";
  }
}
```

```ts
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" };
}
```

Elements with the `idle`, `leading`, `trailing`, or `expanded` attribute fill the matching slot. An `ng-container` works too.

## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `state` | `"idle" \| "compact" \| "expanded"` | idle | Current state, controlled by you. Blade also follows a parent value bound with x-model. |
| `idle` | `ReactNode / slot` | - | Content of the small idle pill, usually empty. |
| `leading` | `ReactNode / slot` | - | Left side of the compact pill, such as an icon or album art. |
| `trailing` | `ReactNode / slot` | - | Right side of the compact pill, such as a timer or short value. |
| `expanded` | `ReactNode / slot` | - | Content of the large card, with room for text and buttons. |
| `announcements` | `{ idle?: string; compact?: string; expanded?: string }` | {} | Text a polite live region reads when the island moves to that state. Only fill the states that matter. |
| `islandLabel` | `string` | Live activity | Accessible name of the island region. |
| `state attribute` | `idle \| compact \| expanded` | - | Astro only. Set the state attribute on markas-dynamic-island from a script to morph the island after the first render. |

## Accessibility

- The island is a region named by islandLabel. Content of the states that are not shown is inert, so it cannot be focused or read.
- A visually hidden aria-live="polite" paragraph reads the announcement of the current state, so important changes are heard without moving focus.
- Size changes and the crossfade are pure CSS transitions. With reduced motion the island jumps straight to the new size.
- Give icon-only buttons inside the slots an aria-label, and keep the controls that change the state outside the island.

## Notes

- Width, height, and corner radius move with one springy CSS transition. The incoming content fades and sharpens in a beat later.
- Each state's content keeps its final size and is revealed by the growing pill, so text never reflows mid-animation.
- The island adds the dark class to itself, so it is a black pill on light pages and a ringed one on dark pages, and nested components use dark tokens.
- Sizes come from `--island-idle-width`, `--island-compact-width`, `--island-expanded-width`, and `--island-expanded-height` (defaults 7.5rem, 15rem, 22rem, 9.5rem).
- The island never grows wider than its parent. Its content is capped at the nearest size container, or the screen when there is none, so give a narrow parent the `@container` class (as the examples do) and the content fits too.
