A cardboard file box of five tabbed folders. Hover a folder to lift it out by its tab; click it to give it a tug.
$ npx shadcn-vue@latest add "https://nxui.geoql.in/r/file-box.json"Keep in mind
This component is inspired by various open-source projects and patterns. Please verify licenses and implementation details before using in production.
A cardboard file box holding five colourful folders, drawn as one SVG in an oblique projection. Hover or focus a folder and it is pulled up by its tab, leaning a little toward that side. Its front flap falls open a beat later, the three sheets inside trail behind on looser springs, and the neighbouring folders give way. Click it, or press Enter or Space, to tug it up past the hover height. The scene tilts a few degrees with the pointer and the shadow answers it. On a theme change every face and folder cross-fades and the box settles under the new light.
<script setup lang="ts">
import { computed } from 'vue';
import FileBox from '~/components/ui/file-box/FileBox.vue';
import type { FileBoxPull } from '~/components/ui/file-box/types';
const colorMode = useColorMode();
const theme = computed(() => (colorMode.value === 'dark' ? 'dark' : 'light'));
function onPull(folder: FileBoxPull) {
console.log(folder.color, folder.position);
}
</script>
<template>
<div class="h-100 w-full">
<FileBox fill :theme="theme" @pull="onPull" />
</div>
</template>
Without fill the box is a square that takes the full width of its parent. With fill it fills the parent edge to edge, and the scene centres in the largest square that fits.
| Prop | Type | Default | Description |
|---|---|---|---|
theme | 'light' | 'dark' | 'light' | Colour theme. Pass your site's colour mode. |
fill | boolean | false | Fill the parent edge to edge instead of keeping a square. |
class | string | '' | Extra classes for the root element. |
| Event | Payload | Description |
|---|---|---|
pull | (folder: FileBoxPull) | Fires when a folder is tugged, with its color and its position counted from the front (1–5). |
| Method | Signature | Description |
|---|---|---|
hover | (position: number | null) => void | Lift the folder at position (1 = front), or drop them all. |
pull | (position: number) => void | Tug the folder at position. |
release | () => void | Drop a folder lifted through hover. A real hover is left alone. |
replay | () => void | Play the intro again. |
role="button" with a label such as "Pull out the pink folder, middle from the front". Tab moves through the folders from back to front.role="group". The paper grain is hidden from assistive tech.Ported from File Box by Pin UI, MIT licence.