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
velvet-ui/sheetSheet and SheetStack onlyvelvet-ui/sheet.css
velvet-ui/motionFramework-free springs, WAAPI, and travel interpolationnone
velvet-ui/motion/reactLifecycle-owned motion hooksnone
velvet-ui/utilitiesScroll, accessibility, fixed, island, and overlay helpersvelvet-ui/sheet.css
velvet-ui/sheet-morphShared-origin geometryvelvet-ui/sheet.css
velvet-ui/theme-backdropBackdrop plus browser theme tintvelvet-ui/sheet.css
velvet-ui/bottom-sheetStyled mobile/task sheetsheet.css + bottom-sheet.css
velvet-ui/depth-sheetRecursive iOS-like depth stacksheet.css + depth-sheet.css
velvet-ui/card-expansionTrigger-to-modal expansionsheet.css + card-expansion.css
velvet-ui/persistent-sheetNon-modal collapsed surfacesheet.css + persistent-sheet.css
velvet-ui/lightboxFull-screen media surfacesheet.css + lightbox.css
velvet-ui/toastToaster and imperative toast APItoast.css or toast-theme.css
velvet-uiEvery public exportImport the CSS you use

Smallest reliable imports

tsx
import { Sheet } from "velvet-ui/sheet";
import { animate } from "velvet-ui/motion";
import { CardExpansion } from "velvet-ui/card-expansion";
import { toast, Toaster } from "velvet-ui/toast";

import "velvet-ui/sheet.css";
import "velvet-ui/card-expansion.css";

Use the root velvet-ui 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.