This file is the local project guide for work in this repository. Use it to avoid re-discovering the package layout and component conventions on each task.
package/: publishabletinywidgetslibrary.package/src/components/: one folder per component.package/src/css/: shared theme contracts, tokens, and global styles.package/src/stores/: TinyBase-backed UI state used byAppand stateful widgets.package/src/common/: shared helpers such asclassNamesandrenderComponentOrNode.site/: docs/demo app, including API generation from package source JSDoc.docs/: built site output.
- Package entrypoint:
package/src/index.ts. - CSS submodule entrypoint:
package/src/index.css.ts. - If you add a new public component, export it from
package/src/index.ts. - If you add a new public CSS object/token, export it from
package/src/index.css.ts.
- Each component lives in
package/src/components/<Name>/. - Standard files:
index.tsx: component behavior and JSDoc.index.css.ts: Vanilla Extract styles.
- Keep components small and DOM-light.
- Prefer shared helpers and shared tokens over ad hoc logic or hard-coded values.
- Props are usually typed inline on the exported component instead of with a separate exported interface.
- Use
readonlyprop fields. - Common prop shapes:
className?: stringchildren: ReactNodefor container componentsicon?: ComponentType<{className?: string}>for icon slotstitle?: ComponentType | ReactNodefor renderable slots
- Use
renderComponentOrNodewhen a prop can be either a component or a node. - Use
classNamesto compose CSS classes. - Put visual variants in
styleVariantswithinindex.css.tsand type the prop askeyof typeof ...Variants. - Reuse shared sizing tokens such as
iconSizewhere appropriate.
- Styling is done with Vanilla Extract.
- Shared tokens live in:
package/src/css/colors.css.tspackage/src/css/dimensions.css.tspackage/src/css/screens.ts
- Global style entrypoint is
package/src/index.css.ts, which importspackage/src/css/global.css.ts. - Prefer shared colors, dimensions, borders, and shadows instead of introducing new one-off values.
- TinyWidgets exposes CSS token objects publicly; preserve that pattern when extending shared styling primitives.
- Stateless primitives should stay simple and local.
- For transient controlled UI behavior, local React state is normal.
- For UI state that should persist across reloads or coordinate with
App, use the TinyBase stores underpackage/src/stores/. Appis the root provider forSessionStore,LocalStore, andRouteStore.- Existing persistence patterns:
- session state for collapsibles and side nav
- local state for dark mode preference
- hash-based route persistence
- The source of truth for API docs is JSDoc in
package/src/**. site/buildApi.tsparses exported declarations and their JSDoc to build the docs site.site/buildApi.tsgeneratessite/src/pages/_api.tsxfrom package source comments and examples.- For every public component or hook, include:
- a top-level description
@param propsor relevant params@returns- one or more
@exampleblocks @icon Lucide.*when applicable
- Document each prop with JSDoc on the inline prop type.
- Keep examples realistic and minimal; they are consumed by the docs generator.
package/README.mdis copied from the repo root README duringprePublishPackage.- Do not hand-maintain separate package README content unless the workflow changes.
- Package validation script in
package/package.jsoncurrently runs:- Prettier
- ESLint
- cspell
- TypeScript
- README copy
- There are currently no first-party package component tests in this repo.
- Usual verification for package changes is targeted source review plus:
npm run prePublishPackagefrompackage/when appropriate- or narrower checks such as
tsc,eslint, or formatting as needed
- Be careful not to assume a test suite exists for regressions.
- The docs/demo app lives in
site/. - The site depends on the local package via
tinywidgets: "file:../package". - Important scripts in
site/package.json:bun run buildApi: regeneratesite/src/pages/_api.tsxbun run buildApiWatch: watchpackage/srcand continuously regenerate API docsbun run dev: regenerate API docs once, then start Vitebun run prePublish: regenerate API docs, then run formatting, lint, typecheck, and production build
- If you change public package APIs or JSDoc, rebuild the site API output before assuming the docs are current.
- If a task touches docs rendering, API examples, or navigation, verify in
site/, not justpackage/.
When adding or updating a component in package/, verify:
- the component has
index.tsxandindex.css.ts - it uses shared helpers/tokens where possible
- it is exported from
package/src/index.ts - its JSDoc is complete enough for
site/buildApi.ts - variant names and props match the existing TinyWidgets style
- docs/examples reflect the actual API
- if the API surface or JSDoc changed,
site/src/pages/_api.tsxhas been regenerated