# Folder Float

> Folder whose notes spring out into a floating cloud when it opens on hover or press.

A folder that holds a handful of notes. Hover it (or press it, with `trigger="click"`) and the flap tilts, a sheet of paper rises, and the notes spring out one by one into a cloud above it. Once they land, a zero-gravity Matter.js world takes over: the notes drift and bump into each other, and you can drag and throw them. Click a note to pick it.

<demo-folder-float>



</demo-folder-float>

## Installation

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

## Usage

```vue
<script setup lang="ts">
  import FolderFloat from '~/components/ui/folder-float/FolderFloat.vue';
  import type { FolderFloatItem } from '~/components/ui/folder-float/types';

  const notes: FolderFloatItem[] = [
    'Try a warmer palette',
    'Tighten the spacing',
    { label: 'Logo feels small', value: 'logo' },
    'Love the new hero',
  ];

  function onSelect(value: string, index: number) {
    console.log(value, index);
  }
</script>

<template>
  <FolderFloat :items="notes" label="Design feedback" @select="onSelect" />
</template>
```

The cloud rises above the folder, so leave room on top (about `lift + rows × 52px`).

## Props

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

<tbody>
  <tr>
    <td>
      <code>
        items
      </code>
    </td>
    
    <td>
      <code>
        Array<string | { label, value }>
      </code>
    </td>
    
    <td>
      4 feedback notes
    </td>
    
    <td>
      The pills that float out. A string is its own value.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        label
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'Design feedback'
      </code>
    </td>
    
    <td>
      The line on the flap.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        sublabel
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        ''
      </code>
    </td>
    
    <td>
      The dimmer line under it. Empty counts the notes.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        trigger
      </code>
    </td>
    
    <td>
      <code>
        'hover' | 'click'
      </code>
    </td>
    
    <td>
      <code>
        'hover'
      </code>
    </td>
    
    <td>
      Open on hover, or toggle on press.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        default-open
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Start open.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        close-on-select
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Picking a pill closes the folder.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        physics
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Once the pills land, a zero-gravity world takes over: they float, collide, and can be dragged and thrown inside the cloud.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        drift
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.5
      </code>
    </td>
    
    <td>
      Strength of the floating currents in the world. 0 holds still.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        folder-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#3f3f46'
      </code>
    </td>
    
    <td>
      The back panel and its tab.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        front-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#52525b'
      </code>
    </td>
    
    <td>
      The flap.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        paper-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#f5f5f5'
      </code>
    </td>
    
    <td>
      The paper edge that rises as it opens.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        item-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#f5f5f5'
      </code>
    </td>
    
    <td>
      The pills.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        item-text-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#18181b'
      </code>
    </td>
    
    <td>
      The pill text.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        label-color
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        '#f5f5f5'
      </code>
    </td>
    
    <td>
      The flap text.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        width
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        200
      </code>
    </td>
    
    <td>
      Folder width in px.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        height
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        148
      </code>
    </td>
    
    <td>
      Folder height in px, below the tab.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        radius
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        14
      </code>
    </td>
    
    <td>
      Corner radius in px.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        spread
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        180
      </code>
    </td>
    
    <td>
      Half the widest the cloud may be, in px. Pills pack into rows within it.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        lift
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        26
      </code>
    </td>
    
    <td>
      Gap between the folder and the lowest row, in px.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        tilt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        8
      </code>
    </td>
    
    <td>
      Most a pill leans, in degrees.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        flap-angle
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        34
      </code>
    </td>
    
    <td>
      How far the flap tilts toward you when open, in degrees.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rest-angle
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        16
      </code>
    </td>
    
    <td>
      The flap tilt when closed, in degrees.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        open-duration
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        520
      </code>
    </td>
    
    <td>
      A pill's rise, in ms. The close is 60% of it.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        stagger
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        45
      </code>
    </td>
    
    <td>
      Delay between pills, in ms. The close reverses the order.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        bounce
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        0.3
      </code>
    </td>
    
    <td>
      Overshoot of the rise. 0 lands dead.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        class
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        ''
      </code>
    </td>
    
    <td>
      Extra classes for the root.
    </td>
  </tr>
</tbody>
</table>

## Events

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

<tbody>
  <tr>
    <td>
      <code>
        select
      </code>
    </td>
    
    <td>
      <code>
        (value: string, index: number)
      </code>
    </td>
    
    <td>
      A pill was picked.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        update:open
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      The folder opened or closed.
    </td>
  </tr>
</tbody>
</table>

## Accessibility

- The folder face is a button with `aria-expanded` and the label plus note count as its name; Enter or Space toggles it in either trigger mode.
- Closed pills are `aria-hidden` and out of the tab order; once open they are buttons you can Tab to and press. Escape closes the folder.
- Pills and the folder button show a focus ring on keyboard focus.
- With reduced motion, the flap stays at rest, pills fade instead of springing, and the physics world never starts.
- Ported from [React Bits](https://reactbits.dev/micro/folder-float) by David Haz.
