# Bottom Navigation

Bar bawah gaya aplikasi mobile. Pill meluncur ke item terpilih, labelnya muncul, dan bar bisa menciut jadi ikon saat konten discroll.

- Kategori: MarkasUI
- Status: stable
- Registry: https://markas.jenderalcorp.com/r/bottom-navigation.json
- CLI: `npx markasui@latest add bottom-navigation`

## Kapan dipakai

Navigasi utama antara tiga sampai lima tampilan utama di tata letak mobile atau web bergaya aplikasi.

- Pakai tiga sampai lima item dengan label pendek satu kata
- Beri setiap item value dan path ikon
- Nyalakan shrinkOnScroll bila bar melayang di atas konten yang discroll
- Pakai tombol aksi untuk satu tugas paling sering, misalnya Transfer baru

## Kode

### Blade

Simpan di `resources/views/components/markas/bottom-navigation.blade.php`. Dependensi: alpinejs.

```blade
@props([
    'items' => [],
    'defaultValue' => null,
    'shrinkOnScroll' => false,
    'navLabel' => 'Main',
    'actionLabel' => 'Create',
    'badgeLabel' => '{count} new',
])

@php
    $root = 'flex items-center gap-2 transition-transform duration-300 ease-out data-[state=collapsed]:translate-y-1 motion-reduce:transition-none';
    $nav = 'relative min-w-0 flex-1 rounded-full border border-line bg-surface/85 p-1.5 shadow-overlay backdrop-blur-md';
    $pill = 'absolute inset-y-1.5 left-1.5 w-[calc((100%-0.75rem)/var(--bn-count))] translate-x-[calc(var(--bn-index)*100%)] rounded-full bg-primary-soft transition-transform duration-500 ease-[cubic-bezier(0.34,1.36,0.5,1)] motion-reduce:transition-none';
    $list = 'relative grid auto-cols-fr grid-flow-col';
    $itemClass = 'group/item relative flex h-14 w-full items-center justify-center rounded-full text-muted transition-[color,height] duration-300 ease-out select-none hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-[current=page]:text-ink motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:h-11';
    $iconWrap = 'relative transition-transform duration-300 ease-out group-active/item:scale-90 motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:-translate-y-2.5';
    $iconClass = 'size-6';
    $badgeClass = 'absolute -top-1 -right-2 h-4 min-w-4 rounded-full bg-danger px-1 text-center text-[10px] leading-4 font-semibold text-on-primary';
    $labelClass = 'pointer-events-none absolute inset-x-1 bottom-1.5 translate-y-1 truncate text-center text-xs leading-4 font-medium opacity-0 transition-[opacity,translate] duration-300 ease-out motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:translate-y-0 [[data-bottom-nav=expanded]_[aria-current=page]_&]:opacity-100';
    $srOnly = 'sr-only';
    $actionClass = 'grid size-14 shrink-0 place-items-center rounded-full bg-primary text-on-primary shadow-overlay transition-[background-color,width,height,scale] duration-300 ease-out hover:bg-primary-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-95 motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:size-11';

    // Href with a scheme other than http, https, mailto, or tel (such as javascript:) becomes "#".
    $safeHref = fn (string $href): string => preg_match('/^(?!https?:|mailto:|tel:)[a-z][\w+.\-]*:/i', preg_replace('/[\x00-\x20]/', '', $href)) === 1 ? '#' : $href;
    $items = array_values($items);
    $values = array_map(fn ($item) => (string) $item['value'], $items);
    $active = $defaultValue ?? ($values[0] ?? null);
    $index = max(0, (int) array_search($active, $values, true));
    $action = $__laravel_slots['action'] ?? null;
@endphp

{{-- Scrolling down inside the parent element (or the page) collapses the bar to icons when shrink-on-scroll is set. --}}
<div
    x-data="{
        active: @js($active),
        values: @js($values),
        collapsed: false,
        last: null,
        lastTop: 0,
        {{-- Scroll distance before the bar reacts, and how far down the content must be before it collapses. --}}
        delta: 4,
        collapseAfter: 32,
        get state() {
            return this.collapsed ? 'collapsed' : 'expanded';
        },
        select(value) {
            this.active = value;
            this.collapsed = false;
            this.$dispatch('change', value);
        },
        onScroll(event) {
            const target = event.target;
            if (target !== document && !this.$root.parentElement?.contains(target)) return;
            const top = target === document ? scrollY : target.scrollTop;
            if (target !== this.last) [this.last, this.lastTop] = [target, 0];
            if (Math.abs(top - this.lastTop) < this.delta) return;
            this.collapsed = top > this.lastTop && top > this.collapseAfter;
            this.lastTop = top;
        },
        init() {
            this.handler = (event) => this.onScroll(event);
            if (@js((bool) $shrinkOnScroll)) document.addEventListener('scroll', this.handler, { capture: true, passive: true });
        },
        destroy() {
            document.removeEventListener('scroll', this.handler, { capture: true });
        },
    }"
    data-state="expanded"
    data-bottom-nav="expanded"
    x-bind:data-state="state"
    x-bind:data-bottom-nav="state"
    {{ $attributes->class([$root]) }}
>
    <nav
        aria-label="{{ $navLabel }}"
        class="{{ $nav }}"
        style="--bn-count: {{ count($items) }}; --bn-index: {{ $index }}"
        x-bind:style="{ '--bn-index': Math.max(values.indexOf(active), 0) }"
    >
        <span aria-hidden="true" class="{{ $pill }}"></span>
        <ul class="{{ $list }}">
            @foreach ($items as $item)
                @php
                    $value = (string) $item['value'];
                    $tag = isset($item['href']) ? 'a' : 'button';
                    $hasBadge = isset($item['badge']);
                @endphp
                <li>
                    <{{ $tag }}
                        @if ($tag === 'a') href="{{ $safeHref($item['href']) }}" @else type="button" @endif
                        @if ($value === $active) aria-current="page" @endif
                        x-bind:aria-current="active === @js($value) ? 'page' : null"
                        x-on:click="select(@js($value))"
                        class="{{ $itemClass }}"
                    >
                        <span class="{{ $iconWrap }}">
                            <svg class="{{ $iconClass }}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="{{ $item['icon'] }}" /></svg>
                            @if ($hasBadge)
                                <span aria-hidden="true" class="{{ $badgeClass }}">{{ $item['badge'] }}</span>
                            @endif
                        </span>
                        <span class="{{ $labelClass }}">{{ $item['label'] }}</span>
                        @if ($hasBadge)
                            <span class="{{ $srOnly }}">{{ str_replace('{count}', (string) $item['badge'], $badgeLabel) }}</span>
                        @endif
                    </{{ $tag }}>
                </li>
            @endforeach
        </ul>
    </nav>
    @if ($action)
        <button type="button" aria-label="{{ $actionLabel }}" class="{{ $actionClass }}" x-on:click="$dispatch('action')">{{ $action }}</button>
    @endif
</div>
```

```blade
<div class="relative h-dvh overflow-hidden">
    <main class="h-full overflow-y-auto pb-28">...</main>
    <x-markas.bottom-navigation
        shrink-on-scroll
        default-value="beranda"
        nav-label="Navigasi utama"
        action-label="Transfer baru"
        badge-label="{count} baru"
        class="absolute inset-x-4 bottom-4"
        :items="[
            ['value' => 'beranda', 'label' => 'Beranda', 'icon' => 'M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z'],
            ['value' => 'aktivitas', 'label' => 'Aktivitas', 'icon' => 'M3 3v18h18M7 15l4-4 3 3 5-6', 'badge' => 2],
            ['value' => 'profil', 'label' => 'Profil', 'href' => '/profil', 'icon' => 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0'],
        ]"
    >
        <x-slot:action>
            <svg class="size-6" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M12 5v14M5 12h14" /></svg>
        </x-slot:action>
    </x-markas.bottom-navigation>
</div>
```

### React

Simpan di `src/components/markas/BottomNavigation.tsx`. Tanpa dependensi tambahan.

```tsx
"use client";

import {
  useEffect,
  useRef,
  useState,
  type ComponentProps,
  type CSSProperties,
  type ReactNode,
} from "react";

const root =
  "flex items-center gap-2 transition-transform duration-300 ease-out data-[state=collapsed]:translate-y-1 motion-reduce:transition-none";
const nav =
  "relative min-w-0 flex-1 rounded-full border border-line bg-surface/85 p-1.5 shadow-overlay backdrop-blur-md";
const pill =
  "absolute inset-y-1.5 left-1.5 w-[calc((100%-0.75rem)/var(--bn-count))] translate-x-[calc(var(--bn-index)*100%)] rounded-full bg-primary-soft transition-transform duration-500 ease-[cubic-bezier(0.34,1.36,0.5,1)] motion-reduce:transition-none";
const list = "relative grid auto-cols-fr grid-flow-col";
const itemClass =
  "group/item relative flex h-14 w-full items-center justify-center rounded-full text-muted transition-[color,height] duration-300 ease-out select-none hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-[current=page]:text-ink motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:h-11";
const iconWrap =
  "relative transition-transform duration-300 ease-out group-active/item:scale-90 motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:-translate-y-2.5";
const iconClass = "size-6";
const badgeClass =
  "absolute -top-1 -right-2 h-4 min-w-4 rounded-full bg-danger px-1 text-center text-[10px] leading-4 font-semibold text-on-primary";
const labelClass =
  "pointer-events-none absolute inset-x-1 bottom-1.5 translate-y-1 truncate text-center text-xs leading-4 font-medium opacity-0 transition-[opacity,translate] duration-300 ease-out motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:translate-y-0 [[data-bottom-nav=expanded]_[aria-current=page]_&]:opacity-100";
const srOnly = "sr-only";
const actionClass =
  "grid size-14 shrink-0 place-items-center rounded-full bg-primary text-on-primary shadow-overlay transition-[background-color,width,height,scale] duration-300 ease-out hover:bg-primary-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-95 motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:size-11";

/** Scroll distance before the bar reacts, and how far down the content must be before it collapses. */
const SCROLL_DELTA = 4;
const COLLAPSE_AFTER = 32;

/** Href with a scheme other than http, https, mailto, or tel (such as javascript:) becomes "#". */
const safeHref = (href: string) =>
  /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
    ? "#"
    : href;

const cx = (...c: (string | false | null | undefined)[]) =>
  c.filter(Boolean).join(" ");

export type BottomNavigationItem = {
  value: string;
  label: string;
  /** Path data (the d attribute) for a 24x24 stroked icon. */
  icon: string;
  href?: string;
  /** Small count shown on the icon. */
  badge?: number | string;
};

export type BottomNavigationProps = Omit<
  ComponentProps<"div">,
  "defaultValue"
> & {
  items: BottomNavigationItem[];
  value?: string;
  defaultValue?: string;
  onValueChange?: (value: string) => void;
  /** Collapse to icons while the content around the bar scrolls down. */
  shrinkOnScroll?: boolean;
  /** Icon for the round action button. The button only renders when set. */
  action?: ReactNode;
  onAction?: () => void;
  navLabel?: string;
  actionLabel?: string;
  badgeLabel?: string;
};

export function BottomNavigation({
  items,
  value,
  defaultValue,
  onValueChange,
  shrinkOnScroll = false,
  action,
  onAction,
  navLabel = "Main",
  actionLabel = "Create",
  badgeLabel = "{count} new",
  className,
  ...props
}: BottomNavigationProps) {
  const rootRef = useRef<HTMLDivElement>(null);
  const [inner, setInner] = useState(defaultValue ?? items[0]?.value);
  const [collapsed, setCollapsed] = useState(false);
  const active = value ?? inner;
  const index = Math.max(
    items.findIndex((item) => item.value === active),
    0,
  );
  const state = collapsed ? "collapsed" : "expanded";

  useEffect(() => {
    if (!shrinkOnScroll) return;
    let last: EventTarget | null = null;
    let lastTop = 0;
    const onScroll = (event: Event) => {
      const target = event.target as Element | Document;
      const scope = rootRef.current?.parentElement;
      if (target !== document && !scope?.contains(target as Element)) return;
      const top = target === document ? scrollY : (target as Element).scrollTop;
      if (target !== last) [last, lastTop] = [target, 0];
      if (Math.abs(top - lastTop) < SCROLL_DELTA) return;
      setCollapsed(top > lastTop && top > COLLAPSE_AFTER);
      lastTop = top;
    };
    const options = { capture: true, passive: true };
    document.addEventListener("scroll", onScroll, options);
    return () => document.removeEventListener("scroll", onScroll, options);
  }, [shrinkOnScroll]);

  const select = (next: string) => {
    setInner(next);
    setCollapsed(false);
    onValueChange?.(next);
  };

  return (
    <div
      ref={rootRef}
      data-state={state}
      data-bottom-nav={state}
      className={cx(root, className)}
      {...props}
    >
      <nav
        aria-label={navLabel}
        className={nav}
        style={
          { "--bn-count": items.length, "--bn-index": index } as CSSProperties
        }
      >
        <span aria-hidden="true" className={pill} />
        <ul className={list}>
          {items.map((item) => {
            const current = item.value === active ? "page" : undefined;
            const content = (
              <>
                <span className={iconWrap}>
                  <svg
                    className={iconClass}
                    viewBox="0 0 24 24"
                    fill="none"
                    stroke="currentColor"
                    strokeWidth="1.5"
                    strokeLinecap="round"
                    strokeLinejoin="round"
                    aria-hidden="true"
                  >
                    <path d={item.icon} />
                  </svg>
                  {item.badge !== undefined && (
                    <span aria-hidden="true" className={badgeClass}>
                      {item.badge}
                    </span>
                  )}
                </span>
                <span className={labelClass}>{item.label}</span>
                {item.badge !== undefined && (
                  <span className={srOnly}>
                    {badgeLabel.replace("{count}", String(item.badge))}
                  </span>
                )}
              </>
            );
            return (
              <li key={item.value}>
                {item.href ? (
                  <a
                    href={safeHref(item.href)}
                    aria-current={current}
                    className={itemClass}
                    onClick={() => select(item.value)}
                  >
                    {content}
                  </a>
                ) : (
                  <button
                    type="button"
                    aria-current={current}
                    className={itemClass}
                    onClick={() => select(item.value)}
                  >
                    {content}
                  </button>
                )}
              </li>
            );
          })}
        </ul>
      </nav>
      {action && (
        <button
          type="button"
          aria-label={actionLabel}
          className={actionClass}
          onClick={onAction}
        >
          {action}
        </button>
      )}
    </div>
  );
}
```

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

const [tab, setTab] = useState("beranda");

<BottomNavigation
  items={items}
  value={tab}
  onValueChange={setTab}
  shrinkOnScroll
  navLabel="Navigasi utama"
  badgeLabel="{count} baru"
  action={<PlusIcon className="size-6" />}
  actionLabel="Transfer baru"
  onAction={bukaTransfer}
  className="absolute inset-x-4 bottom-4"
/>;
```

### Vue

Simpan di `src/components/markas/BottomNavigation.vue`. Tanpa dependensi tambahan.

```vue
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref, useSlots } from "vue";

export type BottomNavigationItem = {
  value: string;
  label: string;
  /** Path data (the d attribute) for a 24x24 stroked icon. */
  icon: string;
  href?: string;
  /** Small count shown on the icon. */
  badge?: number | string;
};

const props = withDefaults(
  defineProps<{
    items: BottomNavigationItem[];
    defaultValue?: string;
    /** Collapse to icons while the content around the bar scrolls down. */
    shrinkOnScroll?: boolean;
    navLabel?: string;
    actionLabel?: string;
    badgeLabel?: string;
  }>(),
  {
    defaultValue: undefined,
    shrinkOnScroll: false,
    navLabel: "Main",
    actionLabel: "Create",
    badgeLabel: "{count} new",
  },
);
const model = defineModel<string>();
const emit = defineEmits<{ action: [] }>();
const slots = useSlots();

const root =
  "flex items-center gap-2 transition-transform duration-300 ease-out data-[state=collapsed]:translate-y-1 motion-reduce:transition-none";
const nav =
  "relative min-w-0 flex-1 rounded-full border border-line bg-surface/85 p-1.5 shadow-overlay backdrop-blur-md";
const pill =
  "absolute inset-y-1.5 left-1.5 w-[calc((100%-0.75rem)/var(--bn-count))] translate-x-[calc(var(--bn-index)*100%)] rounded-full bg-primary-soft transition-transform duration-500 ease-[cubic-bezier(0.34,1.36,0.5,1)] motion-reduce:transition-none";
const list = "relative grid auto-cols-fr grid-flow-col";
const itemClass =
  "group/item relative flex h-14 w-full items-center justify-center rounded-full text-muted transition-[color,height] duration-300 ease-out select-none hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-[current=page]:text-ink motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:h-11";
const iconWrap =
  "relative transition-transform duration-300 ease-out group-active/item:scale-90 motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:-translate-y-2.5";
const iconClass = "size-6";
const badgeClass =
  "absolute -top-1 -right-2 h-4 min-w-4 rounded-full bg-danger px-1 text-center text-[10px] leading-4 font-semibold text-on-primary";
const labelClass =
  "pointer-events-none absolute inset-x-1 bottom-1.5 translate-y-1 truncate text-center text-xs leading-4 font-medium opacity-0 transition-[opacity,translate] duration-300 ease-out motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:translate-y-0 [[data-bottom-nav=expanded]_[aria-current=page]_&]:opacity-100";
const srOnly = "sr-only";
const actionClass =
  "grid size-14 shrink-0 place-items-center rounded-full bg-primary text-on-primary shadow-overlay transition-[background-color,width,height,scale] duration-300 ease-out hover:bg-primary-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-95 motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:size-11";

/** Scroll distance before the bar reacts, and how far down the content must be before it collapses. */
const SCROLL_DELTA = 4;
const COLLAPSE_AFTER = 32;

/** Href with a scheme other than http, https, mailto, or tel (such as javascript:) becomes "#". */
const safeHref = (href: string) =>
  /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
    ? "#"
    : href;

const rootEl = ref<HTMLElement>();
const inner = ref(props.defaultValue ?? props.items[0]?.value);
const collapsed = ref(false);
const active = computed(() => model.value ?? inner.value);
const index = computed(() =>
  Math.max(
    props.items.findIndex((item) => item.value === active.value),
    0,
  ),
);
const state = computed(() => (collapsed.value ? "collapsed" : "expanded"));

function select(next: string) {
  inner.value = next;
  model.value = next;
  collapsed.value = false;
}

let last: EventTarget | null = null;
let lastTop = 0;
function onScroll(event: Event) {
  const target = event.target as Element | Document;
  const scope = rootEl.value?.parentElement;
  if (target !== document && !scope?.contains(target as Element)) return;
  const top = target === document ? scrollY : (target as Element).scrollTop;
  if (target !== last) [last, lastTop] = [target, 0];
  if (Math.abs(top - lastTop) < SCROLL_DELTA) return;
  collapsed.value = top > lastTop && top > COLLAPSE_AFTER;
  lastTop = top;
}
const options = { capture: true, passive: true };
onMounted(() => {
  if (props.shrinkOnScroll)
    document.addEventListener("scroll", onScroll, options);
});
onBeforeUnmount(() =>
  document.removeEventListener("scroll", onScroll, options),
);
</script>

<template>
  <div ref="rootEl" :data-state="state" :data-bottom-nav="state" :class="root">
    <nav
      :aria-label="props.navLabel"
      :class="nav"
      :style="{ '--bn-count': props.items.length, '--bn-index': index }"
    >
      <span aria-hidden="true" :class="pill" />
      <ul :class="list">
        <li v-for="item in props.items" :key="item.value">
          <component
            :is="item.href ? 'a' : 'button'"
            :href="item.href ? safeHref(item.href) : undefined"
            :type="item.href ? undefined : 'button'"
            :aria-current="item.value === active ? 'page' : undefined"
            :class="itemClass"
            @click="select(item.value)"
          >
            <span :class="iconWrap">
              <svg
                :class="iconClass"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="1.5"
                stroke-linecap="round"
                stroke-linejoin="round"
                aria-hidden="true"
              >
                <path :d="item.icon" />
              </svg>
              <span
                v-if="item.badge !== undefined"
                aria-hidden="true"
                :class="badgeClass"
                >{{ item.badge }}</span
              >
            </span>
            <span :class="labelClass">{{ item.label }}</span>
            <span v-if="item.badge !== undefined" :class="srOnly">{{
              props.badgeLabel.replace("{count}", String(item.badge))
            }}</span>
          </component>
        </li>
      </ul>
    </nav>
    <button
      v-if="slots.action"
      type="button"
      :aria-label="props.actionLabel"
      :class="actionClass"
      @click="emit('action')"
    >
      <slot name="action" />
    </button>
  </div>
</template>
```

```vue
<script setup lang="ts">
import { ref } from "vue";
import BottomNavigation from "@/components/markas/BottomNavigation.vue";

const tab = ref("beranda");
</script>

<template>
  <BottomNavigation
    v-model="tab"
    :items="items"
    shrink-on-scroll
    nav-label="Navigasi utama"
    action-label="Transfer baru"
    badge-label="{count} baru"
    class="absolute inset-x-4 bottom-4"
    @action="bukaTransfer"
  >
    <template #action><PlusIcon class="size-6" /></template>
  </BottomNavigation>
</template>
```

### Svelte

Simpan di `src/lib/components/markas/BottomNavigation.svelte`. Tanpa dependensi tambahan.

```svelte
<script lang="ts" module>
  export type BottomNavigationItem = {
    value: string;
    label: string;
    /** Path data (the d attribute) for a 24x24 stroked icon. */
    icon: string;
    href?: string;
    /** Small count shown on the icon. */
    badge?: number | string;
  };
</script>

<script lang="ts">
  import type { Snippet } from "svelte";
  import type { HTMLAttributes } from "svelte/elements";

  const root =
    "flex items-center gap-2 transition-transform duration-300 ease-out data-[state=collapsed]:translate-y-1 motion-reduce:transition-none";
  const nav =
    "relative min-w-0 flex-1 rounded-full border border-line bg-surface/85 p-1.5 shadow-overlay backdrop-blur-md";
  const pill =
    "absolute inset-y-1.5 left-1.5 w-[calc((100%-0.75rem)/var(--bn-count))] translate-x-[calc(var(--bn-index)*100%)] rounded-full bg-primary-soft transition-transform duration-500 ease-[cubic-bezier(0.34,1.36,0.5,1)] motion-reduce:transition-none";
  const list = "relative grid auto-cols-fr grid-flow-col";
  const itemClass =
    "group/item relative flex h-14 w-full items-center justify-center rounded-full text-muted transition-[color,height] duration-300 ease-out select-none hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-[current=page]:text-ink motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:h-11";
  const iconWrap =
    "relative transition-transform duration-300 ease-out group-active/item:scale-90 motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:-translate-y-2.5";
  const iconClass = "size-6";
  const badgeClass =
    "absolute -top-1 -right-2 h-4 min-w-4 rounded-full bg-danger px-1 text-center text-[10px] leading-4 font-semibold text-on-primary";
  const labelClass =
    "pointer-events-none absolute inset-x-1 bottom-1.5 translate-y-1 truncate text-center text-xs leading-4 font-medium opacity-0 transition-[opacity,translate] duration-300 ease-out motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:translate-y-0 [[data-bottom-nav=expanded]_[aria-current=page]_&]:opacity-100";
  const srOnly = "sr-only";
  const actionClass =
    "grid size-14 shrink-0 place-items-center rounded-full bg-primary text-on-primary shadow-overlay transition-[background-color,width,height,scale] duration-300 ease-out hover:bg-primary-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-95 motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:size-11";

  /** Scroll distance before the bar reacts, and how far down the content must be before it collapses. */
  const SCROLL_DELTA = 4;
  const COLLAPSE_AFTER = 32;

  /** Href with a scheme other than http, https, mailto, or tel (such as javascript:) becomes "#". */
  const safeHref = (href: string) =>
    /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
      ? "#"
      : href;

  type Props = HTMLAttributes<HTMLDivElement> & {
    items: BottomNavigationItem[];
    /** Current item, bindable with bind:value. */
    value?: string;
    defaultValue?: string;
    onValueChange?: (value: string) => void;
    /** Collapse to icons while the content around the bar scrolls down. */
    shrinkOnScroll?: boolean;
    /** Icon for the round action button. The button only renders when set. */
    action?: Snippet;
    onaction?: () => void;
    navLabel?: string;
    actionLabel?: string;
    badgeLabel?: string;
  };

  let {
    items,
    value = $bindable(),
    defaultValue,
    onValueChange,
    shrinkOnScroll = false,
    action,
    onaction,
    navLabel = "Main",
    actionLabel = "Create",
    badgeLabel = "{count} new",
    class: className,
    ...rest
  }: Props = $props();

  let rootEl = $state<HTMLDivElement>();
  let collapsed = $state(false);
  const active = $derived(value ?? defaultValue ?? items[0]?.value);
  const index = $derived(
    Math.max(
      items.findIndex((item) => item.value === active),
      0,
    ),
  );
  const navState = $derived(collapsed ? "collapsed" : "expanded");

  $effect(() => {
    if (!shrinkOnScroll) return;
    let last: EventTarget | null = null;
    let lastTop = 0;
    const onScroll = (event: Event) => {
      const target = event.target as Element | Document;
      const scope = rootEl?.parentElement;
      if (target !== document && !scope?.contains(target as Element)) return;
      const top = target === document ? scrollY : (target as Element).scrollTop;
      if (target !== last) [last, lastTop] = [target, 0];
      if (Math.abs(top - lastTop) < SCROLL_DELTA) return;
      collapsed = top > lastTop && top > COLLAPSE_AFTER;
      lastTop = top;
    };
    const options = { capture: true, passive: true };
    document.addEventListener("scroll", onScroll, options);
    return () => document.removeEventListener("scroll", onScroll, options);
  });

  function select(next: string) {
    value = next;
    collapsed = false;
    onValueChange?.(next);
  }
</script>

{#snippet content(item: BottomNavigationItem)}
  <span class={iconWrap}>
    <svg
      class={iconClass}
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      stroke-width="1.5"
      stroke-linecap="round"
      stroke-linejoin="round"
      aria-hidden="true"
    >
      <path d={item.icon} />
    </svg>
    {#if item.badge !== undefined}
      <span aria-hidden="true" class={badgeClass}>{item.badge}</span>
    {/if}
  </span>
  <span class={labelClass}>{item.label}</span>
  {#if item.badge !== undefined}
    <span class={srOnly}
      >{badgeLabel.replace("{count}", String(item.badge))}</span
    >
  {/if}
{/snippet}

<div
  bind:this={rootEl}
  data-state={navState}
  data-bottom-nav={navState}
  class={[root, className]}
  {...rest}
>
  <nav
    aria-label={navLabel}
    class={nav}
    style:--bn-count={items.length}
    style:--bn-index={index}
  >
    <span aria-hidden="true" class={pill}></span>
    <ul class={list}>
      {#each items as item (item.value)}
        {@const current = item.value === active ? "page" : undefined}
        <li>
          {#if item.href}
            <a
              href={safeHref(item.href)}
              aria-current={current}
              class={itemClass}
              onclick={() => select(item.value)}>{@render content(item)}</a
            >
          {:else}
            <button
              type="button"
              aria-current={current}
              class={itemClass}
              onclick={() => select(item.value)}>{@render content(item)}</button
            >
          {/if}
        </li>
      {/each}
    </ul>
  </nav>
  {#if action}
    <button
      type="button"
      aria-label={actionLabel}
      class={actionClass}
      onclick={onaction}>{@render action()}</button
    >
  {/if}
</div>
```

```svelte
<script lang="ts">
  import BottomNavigation from "$lib/components/markas/BottomNavigation.svelte";

  let tab = $state("home");
</script>

<BottomNavigation
  {items}
  bind:value={tab}
  shrinkOnScroll
  actionLabel="New transfer"
  onaction={openTransfer}
  class="absolute inset-x-4 bottom-4"
>
  {#snippet action()}
    <PlusIcon class="size-6" />
  {/snippet}
</BottomNavigation>
```

Tombol aksi hanya dirender kalau snippet `action` diisi.

### Astro

Simpan di `src/components/markas/BottomNavigation.astro`. Tanpa dependensi tambahan.

```astro
---
import type { HTMLAttributes } from "astro/types";

export type BottomNavigationItem = {
  value: string;
  label: string;
  /** Path data (the d attribute) for a 24x24 stroked icon. */
  icon: string;
  href?: string;
  /** Small count shown on the icon. */
  badge?: number | string;
};

const root =
  "flex items-center gap-2 transition-transform duration-300 ease-out data-[state=collapsed]:translate-y-1 motion-reduce:transition-none";
const nav =
  "relative min-w-0 flex-1 rounded-full border border-line bg-surface/85 p-1.5 shadow-overlay backdrop-blur-md";
const pill =
  "absolute inset-y-1.5 left-1.5 w-[calc((100%-0.75rem)/var(--bn-count))] translate-x-[calc(var(--bn-index)*100%)] rounded-full bg-primary-soft transition-transform duration-500 ease-[cubic-bezier(0.34,1.36,0.5,1)] motion-reduce:transition-none";
const list = "relative grid auto-cols-fr grid-flow-col";
const itemClass =
  "group/item relative flex h-14 w-full items-center justify-center rounded-full text-muted transition-[color,height] duration-300 ease-out select-none hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-[current=page]:text-ink motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:h-11";
const iconWrap =
  "relative transition-transform duration-300 ease-out group-active/item:scale-90 motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:-translate-y-2.5";
const iconClass = "size-6";
const badgeClass =
  "absolute -top-1 -right-2 h-4 min-w-4 rounded-full bg-danger px-1 text-center text-[10px] leading-4 font-semibold text-on-primary";
const labelClass =
  "pointer-events-none absolute inset-x-1 bottom-1.5 translate-y-1 truncate text-center text-xs leading-4 font-medium opacity-0 transition-[opacity,translate] duration-300 ease-out motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:translate-y-0 [[data-bottom-nav=expanded]_[aria-current=page]_&]:opacity-100";
const srOnly = "sr-only";
const actionClass =
  "grid size-14 shrink-0 place-items-center rounded-full bg-primary text-on-primary shadow-overlay transition-[background-color,width,height,scale] duration-300 ease-out hover:bg-primary-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-95 motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:size-11";

/** Href with a scheme other than http, https, mailto, or tel (such as javascript:) becomes "#". */
const safeHref = (href: string) =>
  /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
    ? "#"
    : href;

type Props = HTMLAttributes<"div"> & {
  items: BottomNavigationItem[];
  defaultValue?: string;
  /** Collapse to icons while the content around the bar scrolls down. */
  shrinkOnScroll?: boolean;
  navLabel?: string;
  actionLabel?: string;
  badgeLabel?: string;
};

const {
  items,
  defaultValue,
  shrinkOnScroll = false,
  navLabel = "Main",
  actionLabel = "Create",
  badgeLabel = "{count} new",
  class: className,
  ...rest
} = Astro.props;
const active = defaultValue ?? items[0]?.value;
const index = Math.max(
  items.findIndex((item) => item.value === active),
  0,
);
const hasAction = Astro.slots.has("action");
---

<markas-bottom-navigation
  class="contents"
  data-shrink-on-scroll={shrinkOnScroll ? "" : undefined}
>
  <div
    data-state="expanded"
    data-bottom-nav="expanded"
    class:list={[root, className]}
    {...rest}
  >
    <nav
      aria-label={navLabel}
      class={nav}
      style={`--bn-count: ${items.length}; --bn-index: ${index}`}
    >
      <span aria-hidden="true" class={pill}></span>
      <ul class={list}>
        {
          items.map((item) => {
            const Tag = item.href ? "a" : "button";
            return (
              <li>
                <Tag
                  href={item.href ? safeHref(item.href) : undefined}
                  type={item.href ? undefined : "button"}
                  aria-current={item.value === active ? "page" : undefined}
                  data-value={item.value}
                  class={itemClass}
                >
                  <span class={iconWrap}>
                    <svg
                      class={iconClass}
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      stroke-width="1.5"
                      stroke-linecap="round"
                      stroke-linejoin="round"
                      aria-hidden="true"
                    >
                      <path d={item.icon} />
                    </svg>
                    {item.badge !== undefined && (
                      <span aria-hidden="true" class={badgeClass}>
                        {item.badge}
                      </span>
                    )}
                  </span>
                  <span class={labelClass}>{item.label}</span>
                  {item.badge !== undefined && (
                    <span class={srOnly}>
                      {badgeLabel.replace("{count}", String(item.badge))}
                    </span>
                  )}
                </Tag>
              </li>
            );
          })
        }
      </ul>
    </nav>
    {
      hasAction && (
        <button
          type="button"
          aria-label={actionLabel}
          data-action
          class={actionClass}
        >
          <slot name="action" />
        </button>
      )
    }
  </div>
</markas-bottom-navigation>

<script>
  /** Scroll distance before the bar reacts, and how far down the content must be before it collapses. */
  const SCROLL_DELTA = 4;
  const COLLAPSE_AFTER = 32;

  // Each bar tracks its own scroll position, so it is a custom element: it also works for
  // markup added later and for pages reached through view transitions.
  class MarkasBottomNavigation extends HTMLElement {
    private last: EventTarget | null = null;
    private lastTop = 0;
    private readonly onScroll = (event: Event) => {
      const target = event.target as Element | Document;
      if (target !== document && !this.parentElement?.contains(target as Element))
        return;
      const top = target === document ? scrollY : (target as Element).scrollTop;
      if (target !== this.last) [this.last, this.lastTop] = [target, 0];
      if (Math.abs(top - this.lastTop) < SCROLL_DELTA) return;
      this.setCollapsed(top > this.lastTop && top > COLLAPSE_AFTER);
      this.lastTop = top;
    };
    private readonly options = { capture: true, passive: true };

    connectedCallback() {
      this.addEventListener("click", this.onClick);
      if (this.hasAttribute("data-shrink-on-scroll"))
        document.addEventListener("scroll", this.onScroll, this.options);
    }

    disconnectedCallback() {
      this.removeEventListener("click", this.onClick);
      document.removeEventListener("scroll", this.onScroll, this.options);
    }

    private setCollapsed(collapsed: boolean) {
      const bar = this.querySelector<HTMLElement>("[data-bottom-nav]");
      if (!bar) return;
      const state = collapsed ? "collapsed" : "expanded";
      bar.dataset.state = state;
      bar.dataset.bottomNav = state;
    }

    private readonly onClick = (event: Event) => {
      const target = event.target as Element;
      if (target.closest("[data-action]")) {
        this.dispatchEvent(new CustomEvent("markas-action", { bubbles: true }));
        return;
      }
      const item = target.closest<HTMLElement>("[data-value]");
      if (!item) return;
      const items = [...this.querySelectorAll<HTMLElement>("[data-value]")];
      items.forEach((other) =>
        other === item
          ? other.setAttribute("aria-current", "page")
          : other.removeAttribute("aria-current"),
      );
      this.querySelector("nav")?.style.setProperty(
        "--bn-index",
        String(items.indexOf(item)),
      );
      this.setCollapsed(false);
      this.dispatchEvent(
        new CustomEvent("markas-change", {
          detail: item.dataset.value,
          bubbles: true,
        }),
      );
    };
  }

  if (!customElements.get("markas-bottom-navigation"))
    customElements.define("markas-bottom-navigation", MarkasBottomNavigation);
</script>
```

```astro
---
import BottomNavigation from "@/components/markas/BottomNavigation.astro";
---

<BottomNavigation
  items={items}
  defaultValue="home"
  shrinkOnScroll
  actionLabel="New transfer"
  class="absolute inset-x-4 bottom-4"
>
  <PlusIcon slot="action" class="size-6" />
</BottomNavigation>
```

Custom element kecil menggeser pill dan mengecilkan bar. Ia mengirim `markas-change` (value sebagai detail) dan `markas-action`, keduanya menggelembung.

### Angular

Simpan di `src/app/markas/bottom-navigation.component.ts`. Tanpa dependensi tambahan.

```ts
import { NgTemplateOutlet } from "@angular/common";
import {
  afterNextRender,
  booleanAttribute,
  ChangeDetectionStrategy,
  Component,
  computed,
  DestroyRef,
  ElementRef,
  inject,
  input,
  model,
  output,
  signal,
  viewChild,
} from "@angular/core";

export type BottomNavigationItem = {
  value: string;
  label: string;
  /** Path data (the d attribute) for a 24x24 stroked icon. */
  icon: string;
  href?: string;
  /** Small count shown on the icon. */
  badge?: number | string;
};

const root =
  "flex items-center gap-2 transition-transform duration-300 ease-out data-[state=collapsed]:translate-y-1 motion-reduce:transition-none";
const nav =
  "relative min-w-0 flex-1 rounded-full border border-line bg-surface/85 p-1.5 shadow-overlay backdrop-blur-md";
const pill =
  "absolute inset-y-1.5 left-1.5 w-[calc((100%-0.75rem)/var(--bn-count))] translate-x-[calc(var(--bn-index)*100%)] rounded-full bg-primary-soft transition-transform duration-500 ease-[cubic-bezier(0.34,1.36,0.5,1)] motion-reduce:transition-none";
const list = "relative grid auto-cols-fr grid-flow-col";
const itemClass =
  "group/item relative flex h-14 w-full items-center justify-center rounded-full text-muted transition-[color,height] duration-300 ease-out select-none hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-[current=page]:text-ink motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:h-11";
const iconWrap =
  "relative transition-transform duration-300 ease-out group-active/item:scale-90 motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:-translate-y-2.5";
const iconClass = "size-6";
const badgeClass =
  "absolute -top-1 -right-2 h-4 min-w-4 rounded-full bg-danger px-1 text-center text-[10px] leading-4 font-semibold text-on-primary";
const labelClass =
  "pointer-events-none absolute inset-x-1 bottom-1.5 translate-y-1 truncate text-center text-xs leading-4 font-medium opacity-0 transition-[opacity,translate] duration-300 ease-out motion-reduce:transition-none [[data-bottom-nav=expanded]_[aria-current=page]_&]:translate-y-0 [[data-bottom-nav=expanded]_[aria-current=page]_&]:opacity-100";
const srOnly = "sr-only";
const actionClass =
  "grid size-14 shrink-0 place-items-center rounded-full bg-primary text-on-primary shadow-overlay transition-[background-color,width,height,scale] duration-300 ease-out hover:bg-primary-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-95 motion-reduce:transition-none [[data-bottom-nav=collapsed]_&]:size-11";

/** Scroll distance before the bar reacts, and how far down the content must be before it collapses. */
const SCROLL_DELTA = 4;
const COLLAPSE_AFTER = 32;

/** Href with a scheme other than http, https, mailto, or tel (such as javascript:) becomes "#". */
const safeHref = (href: string) =>
  /^(?!https?:|mailto:|tel:)[a-z][\w+.-]*:/i.test(href.replace(/[\0- ]/g, ""))
    ? "#"
    : href;

/**
 * Slot: an element with the `action` attribute (an icon) renders the round action button.
 * Host stays out of layout; class moves to the root element.
 */
@Component({
  selector: "markas-bottom-navigation",
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [NgTemplateOutlet],
  host: { class: "contents" },
  template: `
    <ng-template #content let-item>
      <span [class]="iconWrap">
        <svg
          [class]="iconClass"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="1.5"
          stroke-linecap="round"
          stroke-linejoin="round"
          aria-hidden="true"
        >
          <path [attr.d]="item.icon" />
        </svg>
        @if (item.badge !== undefined) {
          <span aria-hidden="true" [class]="badgeClass">{{ item.badge }}</span>
        }
      </span>
      <span [class]="labelClass">{{ item.label }}</span>
      @if (item.badge !== undefined) {
        <span [class]="srOnly">{{ badgeText(item.badge) }}</span>
      }
    </ng-template>
    <div
      [attr.data-state]="state()"
      [attr.data-bottom-nav]="state()"
      [class]="rootClasses()"
    >
      <nav
        [attr.aria-label]="navLabel()"
        [class]="nav"
        [style.--bn-count]="items().length"
        [style.--bn-index]="index()"
      >
        <span aria-hidden="true" [class]="pill"></span>
        <ul [class]="list">
          @for (item of items(); track item.value) {
            <li>
              @if (item.href) {
                <a
                  [attr.href]="safeHref(item.href)"
                  [attr.aria-current]="item.value === active() ? 'page' : null"
                  [class]="itemClass"
                  (click)="select(item.value)"
                  ><ng-container
                    [ngTemplateOutlet]="content"
                    [ngTemplateOutletContext]="{ $implicit: item }"
                /></a>
              } @else {
                <button
                  type="button"
                  [attr.aria-current]="item.value === active() ? 'page' : null"
                  [class]="itemClass"
                  (click)="select(item.value)"
                >
                  <ng-container
                    [ngTemplateOutlet]="content"
                    [ngTemplateOutletContext]="{ $implicit: item }"
                  />
                </button>
              }
            </li>
          }
        </ul>
      </nav>
      <button
        #actionEl
        type="button"
        [attr.aria-label]="actionLabel()"
        [class]="actionClass"
        [hidden]="!hasAction()"
        (click)="action.emit()"
      >
        <ng-content select="[action]" />
      </button>
    </div>
  `,
})
export class BottomNavigation {
  readonly items = input.required<BottomNavigationItem[]>();
  readonly defaultValue = input<string>();
  /** Current item. Emits valueChange on every change, so `[(value)]` works. */
  readonly value = model<string>();
  /** Collapse to icons while the content around the bar scrolls down. */
  readonly shrinkOnScroll = input(false, { transform: booleanAttribute });
  readonly navLabel = input("Main");
  readonly actionLabel = input("Create");
  readonly badgeLabel = input("{count} new");
  readonly userClass = input("", { alias: "class" });
  readonly action = output<void>();

  protected readonly nav = nav;
  protected readonly pill = pill;
  protected readonly list = list;
  protected readonly itemClass = itemClass;
  protected readonly iconWrap = iconWrap;
  protected readonly iconClass = iconClass;
  protected readonly badgeClass = badgeClass;
  protected readonly labelClass = labelClass;
  protected readonly srOnly = srOnly;
  protected readonly actionClass = actionClass;
  protected readonly safeHref = safeHref;
  protected readonly hasAction = signal(false);
  private readonly collapsed = signal(false);
  protected readonly state = computed(() =>
    this.collapsed() ? "collapsed" : "expanded",
  );
  protected readonly active = computed(
    () => this.value() ?? this.defaultValue() ?? this.items()[0]?.value,
  );
  protected readonly index = computed(() =>
    Math.max(
      this.items().findIndex((item) => item.value === this.active()),
      0,
    ),
  );
  protected readonly rootClasses = computed(() =>
    [root, this.userClass()].filter(Boolean).join(" "),
  );
  private readonly actionEl =
    viewChild.required<ElementRef<HTMLButtonElement>>("actionEl");

  constructor() {
    const host: HTMLElement = inject(ElementRef).nativeElement;
    const options = { capture: true, passive: true };
    let last: EventTarget | null = null;
    let lastTop = 0;
    const onScroll = (event: Event) => {
      const target = event.target as Element | Document;
      const scope = host.parentElement;
      if (target !== document && !scope?.contains(target as Element)) return;
      const top = target === document ? scrollY : (target as Element).scrollTop;
      if (target !== last) [last, lastTop] = [target, 0];
      if (Math.abs(top - lastTop) < SCROLL_DELTA) return;
      this.collapsed.set(top > lastTop && top > COLLAPSE_AFTER);
      lastTop = top;
    };
    afterNextRender(() => {
      this.hasAction.set(this.actionEl().nativeElement.childElementCount > 0);
      if (this.shrinkOnScroll())
        document.addEventListener("scroll", onScroll, options);
    });
    inject(DestroyRef).onDestroy(() =>
      document.removeEventListener("scroll", onScroll, options),
    );
  }

  protected badgeText(badge: number | string) {
    return this.badgeLabel().replace("{count}", String(badge));
  }

  protected select(next: string) {
    this.value.set(next);
    this.collapsed.set(false);
  }
}
```

```ts
import { Component, signal } from "@angular/core";
import { BottomNavigation } from "./markas/bottom-navigation.component";

@Component({
  selector: "app-wallet-nav",
  imports: [BottomNavigation],
  template: `
    <markas-bottom-navigation
      [items]="items"
      [(value)]="tab"
      shrinkOnScroll
      actionLabel="New transfer"
      (action)="openTransfer()"
      class="absolute inset-x-4 bottom-4"
    >
      <svg action class="size-6" viewBox="0 0 24 24" aria-hidden="true">
        <path d="M12 5v14M5 12h14" stroke="currentColor" />
      </svg>
    </markas-bottom-navigation>
  `,
})
export class WalletNav {
  items = [{ value: "home", label: "Home", icon: "M3 10.5 12 3l9 7.5V20H3z" }];
  tab = signal("home");
  openTransfer() {}
}
```

Elemen dengan atribut `action` mengisi tombol aksi bulat.

## Props

| Nama | Tipe | Default | Keterangan |
| --- | --- | --- | --- |
| `items` | `{ value: string; label: string; icon: string; href?: string; badge?: number \| string }[]` | [] | Daftar tujuan. icon adalah atribut d path SVG 24x24 bergaris. Item dengan href menjadi link, sisanya tombol. |
| `value / v-model` | `string` | - | Item terpilih yang dikendalikan di React (dengan onValueChange) dan Vue (v-model). |
| `defaultValue` | `string` | first item | Item terpilih saat render pertama. |
| `onValueChange / x-on:change` | `(value: string) => void` | - | Dipicu saat item dipilih. Blade mengirim event DOM change dengan value sebagai detail. |
| `shrinkOnScroll` | `boolean` | false | Menciut jadi ikon saat konten di sekitar bar (elemen induk atau halaman) discroll turun, kembali saat scroll naik. |
| `action / #action / x-slot:action` | `ReactNode \| slot` | - | Ikon untuk tombol aksi bulat di samping bar. Tombol hanya muncul bila ini diisi. |
| `onAction / @action / x-on:action` | `() => void` | - | Dipicu saat tombol aksi ditekan. |
| `navLabel` | `string` | Main | Nama aksesibel elemen nav. |
| `actionLabel` | `string` | Create | Nama aksesibel tombol aksi. |
| `badgeLabel` | `string` | {count} new | Teks tersembunyi yang dibacakan setelah item ber-badge. {count} diganti isi badge. |
| `bind:value` | `string` | - | Khusus Svelte. Binding dua arah item aktif. Svelte juga menerima onValueChange, onaction, dan snippet action. |
| `[(value)] / (action)` | `model<string> / output<void>` | - | Khusus Angular. Item aktif dengan binding dua arah, dan tekanan tombol aksi. Elemen dengan atribut action mengisi tombolnya. |
| `markas-change / markas-action` | `CustomEvent` | - | Khusus Astro. Event menggelembung dari markas-bottom-navigation: value terpilih sebagai detail, dan tekanan tombol aksi (slot="action"). |

## Aksesibilitas

- Bar adalah landmark nav bernama navLabel, berisi daftar link atau tombol sesuai urutan tab.
- Item terpilih memakai aria-current="page". Setiap label tetap menjadi nama aksesibel walau sedang disembunyikan secara visual.
- Badge disembunyikan dari screen reader dan dibacakan lewat badgeLabel.
- Dengan reduced motion, pill dan label berganti tanpa gerakan.

## Catatan

- Letakkan bar di dalam elemen yang discroll (atau di sebelahnya, dalam induk yang sama). shrinkOnScroll mendengarkan scroll di dalam elemen induk bar dan di halaman.
- Beri konten yang discroll padding bawah (sekitar pb-28) agar baris terakhir tidak tertutup bar.
- Pill dan label murni CSS berdasarkan indeks terpilih, jadi render pertama di server sudah menampilkan keadaan yang benar.
- Item dengan href tetap link sungguhan. Menekannya tetap memindahkan pill untuk aplikasi satu halaman.
