# Plasma Wave

> Two ribbons of plasma curling through each other, with soft glow and white-hot cores.

Two raymarched ribbons of plasma curl through each other with a soft glow and white-hot cores. The plasma unfolds and fades in on mount, and moving the cursor along it makes it swell and brighten under the pointer.

<demo-plasma-wave>



</demo-plasma-wave>

## Installation

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

## Usage

```vue
<script setup lang="ts">
  import PlasmaWave from '~/components/ui/plasma-wave/PlasmaWave.vue';
</script>

<template>
  <div class="relative h-125 w-full overflow-hidden bg-black">
    <PlasmaWave
      :colors="['#A855F7', '#06B6D4']"
      :speed="1"
      :bend-1="1"
      :bend-2="0.5"
      :core="0.6"
    />
  </div>
</template>
```

The plasma renders into a transparent WebGL2 canvas, so the container's
background shows through. Set `light-mode` on light pages: the plasma is then
drawn as glowing glass with white cores. Use darker, more saturated colors
there (for example `['#8B2CFF', '#00CFF5']`).

## Props

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

<tbody>
  <tr>
    <td>
      <code>
        colors
      </code>
    </td>
    
    <td>
      <code>
        string[]
      </code>
    </td>
    
    <td>
      <code>
        ['#A855F7', '#06B6D4']
      </code>
    </td>
    
    <td>
      Colors of the two waves of plasma.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        speed
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Overall speed of the animation.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        speed-1
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.05
      </code>
    </td>
    
    <td>
      How fast the first wave travels.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        speed-2
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.05
      </code>
    </td>
    
    <td>
      How fast the second wave travels.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        dir-2
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Direction of the second wave. Use -1 to make it travel against the first.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        bend-1
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      How far the first wave curls around its path.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        bend-2
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.5
      </code>
    </td>
    
    <td>
      How far the second wave curls around its path.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        thickness
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.3
      </code>
    </td>
    
    <td>
      Thickness of the plasma ribbons.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        focal-length
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1.25
      </code>
    </td>
    
    <td>
      Camera lens. Lower values give a wider, deeper view.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rotation-deg
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Rotation of the whole effect, in degrees.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        x-offset
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Horizontal shift of the view, in px.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        y-offset
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Vertical shift of the view, in px.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        brightness
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Brightness of the plasma.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        glow
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Strength of the soft light spilling around the plasma.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        core
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.6
      </code>
    </td>
    
    <td>
      How white-hot the brightest parts get, from 0 to 1.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        grain
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.03
      </code>
    </td>
    
    <td>
      Strength of the film grain.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        quality
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Detail of the plasma, from 0.25 to 1. Lower values render faster.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        mouse-interaction
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Swells and brightens the plasma near the cursor.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        intro
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Unfolds the plasma and fades it in on mount.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        fade
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0
      </code>
    </td>
    
    <td>
      Fades the edges into the page, from 0 to 1.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        opacity
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        1
      </code>
    </td>
    
    <td>
      Opacity of the whole effect.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        light-mode
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Draws the plasma as glowing glass with white cores for light pages.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        paused
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Freezes the animation.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        dpr
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      auto
    </td>
    
    <td>
      Maximum device pixel ratio, capped at 2.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        class
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        ''
      </code>
    </td>
    
    <td>
      Extra classes for the container.
    </td>
  </tr>
</tbody>
</table>

## Accessibility

- The canvas is decorative and marked `aria-hidden="true"`.
- With `prefers-reduced-motion: reduce` the plasma holds still, the intro is
skipped and the cursor does not stir it.
- The render loop pauses when the canvas is off screen or the tab is hidden,
and stops once the plasma has settled while `paused` is set.
- Ported from [React Bits](https://reactbits.dev/backgrounds/plasma-wave) by David Haz.
