Cómo funciona
A folder seen from the front: a back panel with a tab, two papers and a summary sheet inside, and a front cover a little shorter than the back with the title and caption on a label band. Hover or focus tips the cover forward and the sheet rises far enough to show its label. A press lifts the sheet out, passes it over the cover and lays it on top, where it reads as a short document: heading, meta line, key figures and an action. The folder never changes size, so nearby content stays put.
Úsalo para
- A documents or files view in a dashboard, where each folder holds a report, contracts or invoices and a summary helps decide what to open.
- A press kit or a deliverables page on a landing page, where the folder itself is part of the story.
- Show three or four folders in a row at most, in tones that sit together: the accent, ink and one chart colour.
Busca otra opción cuando
- Long lists of files: use a table or a list, which scan faster than many folders.
- Content the viewer must see without acting: a peek is a hint, not the content.
Uso
import { FolderReveal } from './FolderReveal.jsx'
export function BoardPack({ onOpenReport }) {
return (
<FolderReveal
title="Q3 board pack"
caption="Confidential"
edgeLabel="Summary"
heading="Q3 results"
meta="Board · 14 Oct"
figures={[
{ label: 'Revenue', value: '$2.4M' },
{ label: 'Retention', value: '96%' },
{ label: 'Margin', value: '31%' },
]}
action={<button type="button" onClick={onOpenReport}>Open report</button>}
/>
)
}Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
title | string | 'Document' | Name on the cover. It also names the trigger and preview region. |
caption | string | 'Preview available' | Short cover caption and accessible description. Pass an empty string to omit it. |
icon | ReactNode | <DocumentIcon /> | Decorative mark at the top of the cover, drawn in the cover text colour. Pass null to omit it. |
edgeLabel | string | 'Preview' | Label on the top edge of the sheet: the first line the peek shows, beside a dot in the folder colour. |
heading | string | — | Title of the document on the sheet. |
meta | string | — | Small line under the heading, such as a source and a date. |
figures | { label: string, value: string, unit?: string }[] | — | Two or three key figures. Values are set in the mono face with tabular digits; an optional unit follows in the sans face, for languages that write it after the number. On a sheet wider than 220 px they form columns, otherwise a ledger. |
action | ReactNode | — | Action under a hairline at the foot of the sheet, usually a small button. |
children | ReactNode | — | Free content between the figures and the action. When the sheet has no other content, it reads "The document summary appears here." |
open | boolean | — | Controlled visibility. Omit to let the folder keep its own state. |
defaultOpen | boolean | false | Initial visibility for an uncontrolled folder. |
onOpenChange | (open: boolean) => void | — | Called when activation, Escape or an outside press requests a change. Share one active folder ID to coordinate a group. |
tone | 'accent' | 'ink' | 'chart-1' through 'chart-8' | 'accent' | Folder colour. The accent is used as it is; ink is a near-black with a trace of the accent; chart colours are taken deeper so that light text reads on them and a group of tones sits together. |
size | 'sm' | 'md' | 'lg' | 'md' | Maximum width: 200, 280 or 360 px. The folder fills narrower containers, and its height follows the sheet. |
labels | { opened?: (title: string) => string, closed?: (title: string) => string } | — | Polite live announcements for each visibility change. |
Accesibilidad
- The whole folder is one native button named by the title and described by the caption. Enter, Space or a tap toggles it, and a visible focus ring appears for the keyboard.
- aria-expanded and aria-controls tie the button to the sheet. The closed sheet is inert, so its action enters the Tab order only once it lies on the cover.
- Escape closes the sheet and returns focus to the folder; a press outside also closes it. Screen readers hear a polite announcement on each change.
- Touch has no hover: the first tap opens the sheet. Keyboard focus shows the same peek as hover.
- Under reduced motion the cover does not tip and nothing travels; the peek and the sheet on the cover are shown in place.
Movimiento
One phase drives the folder. Peek (360 ms): the cover tips 14° toward the viewer, then the sheet rises 16 px on a damped spring and the two papers behind follow 40 ms apart, so the stack fans and the index tab clears the edge. Open (720 ms): the cover falls open to about 66° while the sheet lifts 36 px toward the viewer, growing 4% under a deepening shadow; once the cover is low the sheet passes in front, then drops onto the closing cover with one small overshoot and settles at a 1.6° tilt. Putting it back retraces the path a little faster, and any change can interrupt another without a jump.
Añádelo a tu proyecto
Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.
FolderReveal.jsxfolder-reveal.csstokens.cssREADME.md
Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.







