# Dynamic Island Header

> Navbar that collapses into a compact pill on scroll, morphing to show the active section and reading progress.

<demo-dynamic-island-header>



</demo-dynamic-island-header>

## Installation

```bash
npx shadcn-vue@latest add "https://nxui.geoql.in/r/dynamic-island-header.json"
```

## Usage

```vue
<script setup lang="ts">
  import DynamicIslandHeader from '~/components/ui/dynamic-island-header/DynamicIslandHeader.vue';

  const links = [
    { label: 'Programming', href: '#programming' },
    { label: 'Nutrition', href: '#nutrition' },
    { label: 'Pricing', href: '#pricing' },
  ];
</script>

<template>
  <div class="sticky top-4 z-50 flex justify-center px-4">
    <DynamicIslandHeader class="w-full max-w-3xl" :links="links" />
  </div>
</template>
```

Scroll past `threshold` and the full navbar springs into a compact island
showing the section currently in view plus a circular reading-progress
indicator. Anchor links (`#id`) are resolved against the scroll container.

Use the `#logo` and `#brand` slots to swap in your own mark and wordmark.
Pass a `container` element ref when the page scrolls inside a custom
scrollable element instead of the window.

## Props

<table>
<thead>
  <tr>
    <th>
      Prop
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        links
      </code>
    </td>
    
    <td>
      <code>
        DynamicIslandLink[]
      </code>
    </td>
    
    <td>
      —
    </td>
    
    <td>
      Nav links (<code>
        label
      </code>
      
      , <code>
        href
      </code>
      
       anchors)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        threshold
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        80
      </code>
    </td>
    
    <td>
      Scroll offset (px) that triggers the collapse
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        compact-width
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        260
      </code>
    </td>
    
    <td>
      Width (px) of the collapsed island
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        default-label
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'Overview'
      </code>
    </td>
    
    <td>
      Island label before any section is reached
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        sign-in-label
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'Sign in'
      </code>
    </td>
    
    <td>
      Sign-in text (empty string hides it)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cta-label
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'Start free trial'
      </code>
    </td>
    
    <td>
      CTA button text (empty string hides it)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        container
      </code>
    </td>
    
    <td>
      <code>
        HTMLElement | null
      </code>
    </td>
    
    <td>
      <code>
        null
      </code>
    </td>
    
    <td>
      Scroll container (defaults to the window)
    </td>
  </tr>
</tbody>
</table>

## Events

<table>
<thead>
  <tr>
    <th>
      Event
    </th>
    
    <th>
      Payload
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        navigate
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Fired with the href on logo/link clicks
    </td>
  </tr>
</tbody>
</table>
