Getting started

Package exports

Choose focused JavaScript and CSS entry points for smaller bundles, predictable style order, and server-rendered React applications.

View as Markdown

Velvet ships focused ESM and CommonJS entry points. Importing a composition does not pull every other composition into the application bundle.

Public entry points

ImportWhat it containsCSS
@velvetui/react/sheetSheet and SheetStack only@velvetui/react/sheet.css
@velvetui/react/motionFramework-free springs, WAAPI, and travel interpolationnone
@velvetui/react/motion/reactLifecycle-owned motion hooksnone
@velvetui/react/utilitiesScroll, accessibility, fixed, island, and overlay helpers@velvetui/react/sheet.css
@velvetui/react/sheet-morphShared-origin geometry@velvetui/react/sheet.css
@velvetui/react/theme-backdropBackdrop plus browser theme tint@velvetui/react/sheet.css
@velvetui/react/bottom-sheetStyled mobile/task sheetsheet.css + bottom-sheet.css
@velvetui/react/depth-sheetRecursive iOS-like depth stacksheet.css + depth-sheet.css
@velvetui/react/card-expansionTrigger-to-modal expansionsheet.css + card-expansion.css
@velvetui/react/persistent-sheetNon-modal collapsed surfacesheet.css + persistent-sheet.css
@velvetui/react/lightboxFull-screen media surfacesheet.css + lightbox.css
@velvetui/react/toastToaster and imperative toast APItoast.css or toast-theme.css
@velvetui/reactEvery public exportImport the CSS you use

Smallest reliable imports

tsx
import { Sheet } from "@velvetui/react/sheet";
import { animate } from "@velvetui/react/motion";
import { CardExpansion } from "@velvetui/react/card-expansion";
import { toast, Toaster } from "@velvetui/react/toast";

import "@velvetui/react/sheet.css";
import "@velvetui/react/card-expansion.css";

Use the root @velvetui/react entry when convenience matters more than the last few bytes. motion has no React import; motion/react adds hooks; sheet does not pull either React hooks or optional compositions. CSS remains explicit because it is a side effect and bundlers must preserve its order.

React and server rendering

React 18 and 19 are peer dependencies. Trigger markup renders on the server. Portalled surfaces and document managers activate after hydration.

Call toast() from client code or an event handler. The Toaster itself can appear in an SSR tree because its portal host is discovered after mount.

Tree-shaking checklist

  • Import from focused subpaths.
  • Use motion, not motion/react, outside React components.
  • Import sheet.css or toast.css instead of base.css when only one primitive family is present.
  • Import only the composition CSS you use.
  • Do not re-export the entire root package from a local barrel.
  • Keep sideEffects: ['**/*.css'] when repackaging Velvet.
  • Measure a minified consumer build, not the dev graph or raw source chunks.