This is a minimal starter config for a UI library based on shadcn-ui React components. It includes:
File/s | Notes |
---|---|
/src/index.ts |
Component exports only |
/src/globals.css |
CSS variable definitions |
/src/components/*/*.tsx |
Actual component files |
/src/components/*/*.stories.tsx |
Storybook stories for development |
package.json |
Build scripts -- build:styles will use postcss-cli to combine CSS files |
postcss.config.js |
postcss plugin configuration, i.e. for postcss-import to combine CSS files |
tailwind.config.js |
Define entrypoints, plugins, global theme properties for Tailwind |
vite.config.ts |
Handles building package in /dist using Vite in library mode |
/src/components/MyComponent
(or write your own)/src/globals.css
/src/themes
tailwind.config.js
per the docsStorybook is set up for local development. Create a *.stories.tsx
file for component and npm run storybook
to work on it in the UI.
To consume component libraries built with this starter before publishing to a registry, you can:
npm link
in your library's working directorynpm link [my-library]
in the working directory of the consuming applicationmy-library/styles.css
) in the consuming app as normalpackage.json
and attached to a new global variable --font-code
in /src/globals.css
font-code
specified in tailwind.config.js
/src/components/Button/Button.tsx
applies the utility class/src/themes
is empty -- the build still passes