This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Faency is a React component library and design system for Traefik Labs, built with React, TypeScript, vanilla-extract, and Radix UI Primitives. It provides accessible, themed components with light/dark mode support.
All components are styled with vanilla-extract (Stitches was removed in v14). See CONTRIBUTING.md for the contribution workflow, docs/COMPONENT_REFERENCE.md for the component rules, and docs/MIGRATION.md for the v13 → v14 upgrade guide.
yarn install- Install dependenciesyarn storybook- Start Storybook development server at http://localhost:6006yarn build- Build the library for productionyarn lint- Lint TypeScript/React files in components and styles directoriesyarn lint:fix- Auto-fix linting issuesyarn typecheck- Type-check the whole project withtsc(also runs in CI)yarn test- Run Jest tests in watch modeyarn test:ci- Run tests in CI mode (silent, non-watch)
Releases are automated. .github/workflows/release.yaml runs yarn semantic-release
on every push to master; there is no local release command.
- vanilla-extract: Build-time styling with design tokens, recipes and a
cssprop (seedocs/COMPONENT_REFERENCE.md) - Build Tool: Vite with vanilla-extract plugin
- Design Tokens: Theme contract in
styles/tokens.css.ts, light/dark implementations instyles/themes.css.ts - Theme Support: Light/dark themes with customizable primary colors
- Component Themes: Components with their own tokens have a
ComponentName.theme.tsfile (e.g.,Button.theme.ts), merged instyles/themes.css.ts
Components follow a consistent pattern:
ComponentName.tsx- Main component implementationComponentName.css.ts- Styles and recipesComponentName.stories.tsx- Storybook storiesComponentName.test.tsx- Jest testsComponentName.theme.ts- Component theme tokens for light/dark modes (if needed)index.ts- Exports
styles/tokens.css.ts- Theme contract (design tokens)styles/themes.css.ts- Light/dark theme classes per primary colorstyles/themeContext.tsx-FaencyProviderroot provider anduseFaencyThemehookcolors/- Color palette definitions (light/dark variants)index.ts- Main library exports (explicit named exports)
- Primary colors:
neon,blue,orange,red,green,deepBlue,grayBlue - Dynamic theme generation based on primary color selection
- Component themes support both light and dark variants
- Colors are defined in
/colors/with systematic naming
- Built on Radix UI Primitives for accessibility
- Uses vanilla-extract for build-time styling
- React 18+ and TypeScript 5+ required
- No Unnecessary Comments: Do not add obvious or redundant comments. Code should be self-explanatory through clear naming and structure. Only add comments when explaining complex logic, non-obvious decisions, or documenting public APIs.
- No Unnecessary Emojis: OK for console warnings/errors, but avoid in code comments or commit messages.
- Create component directory in
/components/ - Add
ComponentName.css.tsandComponentName.tsx(withcssprop support) - If needed, add
ComponentName.theme.tsand register its tokens instyles/tokens.css.tsandstyles/themes.css.ts - Add Storybook stories with all variants
- Write Jest tests
- Export from the component's
index.tsand the mainindex.ts
- Component theme files export light and dark token objects (e.g.
buttonLightTheme,buttonDarkTheme) - Add new tokens to the
colorscontract instyles/tokens.css.tsand spread the objects into the light and dark colors instyles/themes.css.ts - Use semantic color tokens for consistency
- Jest with React Testing Library configured
- jsdom environment for DOM testing
- Focus on accessibility and component behavior
- Run tests before submitting changes
- Test coverage is currently being developed
- Pin all versions: All dependencies must use exact pinned versions (no
^or~). This applies to bothdependenciesanddevDependencies. - 3-day rule: When updating or adding dependencies, only use versions released more than 3 days ago. Check the npm release date before pinning a version.
- Node Version: Use the version in
.nvmrc, kept up to date by Renovate.engines.nodeinpackage.jsonis the minimum for apps that install Faency and is raised by hand - Conventional Commits: Follow conventional commit format for semantic releases
- Accessibility: All components must be accessible and support keyboard navigation
- Storybook: Every component requires comprehensive stories showing all variants
Follow docs/COMPONENT_REFERENCE.md when writing or changing a component: css prop support, variant typing with RecipeVariantProps and splitVariants, polymorphic as and Radix parts, state layers, theme tokens, required test coverage and known test pitfalls.