Traefik Labs Faency
This is the React component library and design system for Traefik Labs.
Built with React, Typescript, Stitches, vanilla-extract (migration in progress), and Radix UI Primitives.
Demo (Storybook)
You can find the Storybook with an example for every component in this library here.
Getting started
How to use Faency
npm install @traefik-labs/faency@next
# or
yarn add @traefik-labs/faency@next
Using Stitches Components (Current)
Wire up the FaencyProvider which will hold the context with the Theme configuration:
The provider accepts one parameter besides the children, which is the primaryColor, that will be used to build the colors used on the Theme. This color can be one of the colors exported by the Stitches config, just by adding $ as a prefix, or can be any string that represents a CSS color.
import { FaencyProvider } from '@traefik-labs/faency';
const App = () => <FaencyProvider primaryColor="$blue8">{/* your app */}</FaencyProvider>;
Then you are ready to import components and use them on your project:
import { Flex, styled } from '@traefik-labs/faency';
const Container = styled(Flex, {
padding: '$3',
bg: '$black', // alias for backgroundColor
mx: '$2', // alias for margin left and right
});
const MyComponent = () => <Container>{children}</Container>;
Using Vanilla Extract Components (Migration in Progress)
For better performance with static CSS, you can use the new Vanilla Extract components (many components are available, more being migrated).
- Import the CSS file in your app's entry point:
import '@traefik-labs/faency/style.css';
- Wrap your app with the VanillaExtractThemeProvider:
import { VanillaExtractThemeProvider } from '@traefik-labs/faency';
import { BoxVanilla, BadgeVanilla } from '@traefik-labs/faency';
const App = () => (
<VanillaExtractThemeProvider defaultTheme="light" primaryColor="blue">
<BoxVanilla css={{ p: '$4' }}>
<BadgeVanilla variant="blue">Hello Faency!</BadgeVanilla>
</BoxVanilla>
</VanillaExtractThemeProvider>
);
Note: Vanilla Extract components use static CSS generated at build time, providing better performance than runtime CSS-in-JS. CSS is automatically included when you import components - no separate CSS import needed. Components with the Vanilla suffix (e.g., BadgeVanilla, BoxVanilla) are available. Not all components have Vanilla Extract versions yet - check the component documentation or use the Stitches version if a Vanilla version is not available.
How to contribute
- Make sure you have the Node version in
.nvmrc (nvm use), or if you prefer, you can work in a Docker container:
docker run -it --rm -v $(pwd):/usr/local/src/ -v faency-node-modules:/usr/local/src/node_modules -w /usr/local/src/ -p 6006:6006 -p 24678:24678 node:$(sed 's/^v//' .nvmrc) bash
- Enable Corepack, so
yarn runs the Yarn version set in package.json
corepack enable
- Install the project dependencies
yarn install
Stitches package needs to be patched after the upgrade to TypeScript version 5. You can run this script after installing the dependencies to apply the patch:
yarn patch-package
yarn storybook
Storybook opens in your browser and hot reloads whenever the code changes.
In the Docker container, run yarn storybook --host 0.0.0.0 instead. Nothing opens by itself there, so open http://localhost:6006 on your machine.
Writing stories
We use Stories to demonstrate how components can behave and which variants they can take, so it's expected that every component has a Story.
Check out how to create stories in the Storybook Docs.
Opening Pull requests
Pull requests are always welcome, but if you have a big change that you would like to work on, it's recommended to open an issue, so we can discuss it beforehand.
A good PR is small, focuses on a single feature or improvement, and clearly communicates the problem it solves.
Try not to include more than one issue in a single PR. It's much easier for us to review multiple small pull requests than one that is large and unwieldy.
Note we follow conventional commits.
Please follow the provided PR template.
Release process
We use semantic-release/semantic-release to automagically release any commit on the master branch.
Recommended conventional commit types:
["build", "chore", "ci", "docs", "feat", "fix", "revert", "test"]
build/chore: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
ci: Changes to CI configuration files and scripts (examples: CircleCi, SauceLabs)
docs: Documentation (comments) only changes
feat: A new feature
fix: A bug fix
revert: Reverts a previous commit
test: Adding missing tests or correcting existing tests
Breaking change syntax:
<type>!: <description>
Matching between commit type and release
[
{ breaking: true, release: 'major' },
// types impacting release version
{ revert: true, release: 'patch' },
{ type: 'feat', release: 'minor' },
{ type: 'fix', release: 'patch' },
{ type: 'perf', release: 'patch' },
];
See semantic-release/commit-analyzer for more information.