# Aero Shards

> Silk ribbons of thick glass shards streaming on layered depths among survey markers, catching light along their edges.

Thousands of ray-traced glass shards stream along silk-like ribbons at five depths, soften with depth of field and glint with bloom. Move the cursor to part the shards and lean the camera, click to send a ring of light through every depth, or press and hold to gather nearby shards into a swirl that scatters on release.

<demo-aero-shards>



</demo-aero-shards>

## Installation

```bash
npx shadcn-vue@latest add "https://nxui.geoql.in/r/aero-shards.json"
```

## Usage

```vue
<script setup lang="ts">
  import AeroShards from '~/components/ui/aero-shards/AeroShards.vue';
</script>

<template>
  <div class="relative h-125 w-full overflow-hidden">
    <AeroShards
      shard-color="#896ABD"
      accent-color="#A855F7"
      placement="full"
      material="glass"
      markers="plus"
      :count="1300"
      :depth-of-field="0.75"
      :glow="0.35"
    />
  </div>
</template>
```

AeroShards fills its parent, so give the parent a real height. It renders with WebGL2 and listens for `error` if the browser cannot create a context, so you can show a fallback. On light pages, set `light-mode` and use deeper shard colors (for example `#7c5cbf` and `#a855f7`).

## Props

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

<tbody>
  <tr>
    <td>
      <code>
        shard-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#896ABD'
      </code>
    </td>
    
    <td>
      Main color of the shards.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        accent-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#A855F7'
      </code>
    </td>
    
    <td>
      Color of the light the shards catch, their rim light and the markers.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        background-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'transparent'
      </code>
    </td>
    
    <td>
      Fills the canvas behind the shards. Transparent lets the page show through.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        light-mode
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Draws the shards as soft tinted glass for light backgrounds.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        placement
      </code>
    </td>
    
    <td>
      <code>
        'full' | 'left' | 'right' | 'center'
      </code>
    </td>
    
    <td>
      <code>
        'full'
      </code>
    </td>
    
    <td>
      Where the ribbons flow: across the whole view, down one side, or in a ring around the center.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        material
      </code>
    </td>
    
    <td>
      <code>
        'glass' | 'chrome'
      </code>
    </td>
    
    <td>
      <code>
        'glass'
      </code>
    </td>
    
    <td>
      Surface of the shards: thick glass that catches light along its edges, or polished chrome.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        markers
      </code>
    </td>
    
    <td>
      <code>
        'plus' | 'dots' | 'none'
      </code>
    </td>
    
    <td>
      <code>
        'plus'
      </code>
    </td>
    
    <td>
      Survey markers floating at each depth. A few blink, and the one nearest the cursor gets a target frame.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        count
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1300
      </code>
    </td>
    
    <td>
      Number of shards across all the ribbons.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        shard-size
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Size of the shards.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        spread
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Width of the ribbons.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        twist
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      How much the ribbons twist along their length.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billow
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      How much the ribbons ripple like silk.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        speed
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      How fast the shards flow.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        scale
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Zoom of the whole scene.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        depth-of-field
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.75
      </code>
    </td>
    
    <td>
      How soft the farther ribbons get. 0 keeps everything sharp.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        glow
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.35
      </code>
    </td>
    
    <td>
      Soft bloom around the brightest glints.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        grain
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.06
      </code>
    </td>
    
    <td>
      Film grain on the shards. 0 turns it off.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vignette
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.3
      </code>
    </td>
    
    <td>
      Fades everything out toward the edges of the frame. 0 runs edge to edge.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        intro
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      The ribbons draw in from the left, front to back, on mount.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        mouse-interaction
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      The cursor parts the shards it passes through and leans the camera toward it.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        mouse-strength
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.6
      </code>
    </td>
    
    <td>
      How strongly the cursor parts the shards.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        parallax
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.5
      </code>
    </td>
    
    <td>
      How far the camera leans toward the cursor.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        pulse-on-click
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Clicking sends a ring of light out through every depth, flipping the shards it passes.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        hold-to-gather
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Pressing and holding gathers nearby shards into a swirl that scatters back on release.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        paused
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Freezes the flow.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        dpr
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        2
      </code>
    </td>
    
    <td>
      Maximum device pixel ratio of the canvas.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        class
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        ''
      </code>
    </td>
    
    <td>
      Extra class names for the container.
    </td>
  </tr>
</tbody>
</table>

## Events

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

<tbody>
  <tr>
    <td>
      <code>
        error
      </code>
    </td>
    
    <td>
      <code>
        Error
      </code>
    </td>
    
    <td>
      Fires if WebGL2 is unavailable or a shader fails, so you can show a fallback.
    </td>
  </tr>
</tbody>
</table>

## Accessibility

- The canvas is decorative and carries `aria-hidden="true"`. Put real content in front of it.
- Pointer presses that start on links, buttons, inputs, labels or `role="button"` elements are ignored, so controls on top keep working.
- With `prefers-reduced-motion: reduce`, the flow, intro, cursor, click and hold effects all stop and the scene renders still.
- The render loop pauses when the canvas is offscreen, when the tab is hidden, and once a paused scene has settled.
- Ported from [React Bits](https://reactbits.dev/backgrounds/aero-shards) by David Haz.
