This library is a template for building UI library npm package with Vite Library mode and supercharged with Tailwind CSS.
Please check this ๐ blog post ๐ for a step by step walkthrough on how this library is built.
The components are located in the lib
folder.
If you want to showcase a component in Storybook, you can add a story file next to the component. see the example component
To develop the components, follow these steps:
lib
folder.lib/main.ts
file.npm run storybook
to view your developed component live on the Storybook viewer.package.json
file according to this pattern: @your-scope/package-name
..npmrc
file at the root of this package with the following content:@your-scope:registry=https://gitlab.com/api/v4/projects/your_project_id/packages/npm/
//gitlab.com/api/v4/projects/your_project_id/packages/npm/:_authToken="${NPM_TOKEN}"
Replace your_project_id
with the Project ID that can be found in the GitLab repository.
NPM_TOKEN=token npm publish
to publish the package to the npm registry.To publish the package on GitHub Package Registry, follow these steps:
package.json
file according to this pattern: @your-scope/package-name
.write:packages
scope. You can create a PAT by going to your GitHub account settings and navigating to "Developer settings" > "Personal access tokens"..npmrc
file at the root of this package with the following content:@NAMESPACE:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_PAT
Replace NAMESPACE
with your GitHub username and YOUR_PAT
with your personal access token.
$ npm login --scope=@NAMESPACE --auth-type=legacy --registry=https://npm.pkg.github.com
> Username: USERNAME
> Password: TOKEN
npm publish
to publish the package to the GitHub Package Registry.The library does not bundle the Tailwind CSS library, Therefore, you need to configure Tailwind CSS on your project to use this component library
For more information, refer to the Tailwind CSS installation guide.
To use the UI Library in your project, follow these steps:
.npmrc
file with the following credentials on the target repository.npm i @your-scope/ui-kit
.tailwind.config.js
.content: [
...
'./node_modules/@your-scope/ui-kit/dist/ui-kit.umd.js',
],
import {Button} from '@scope/ui-kit'
.<Button color="blue" > Click me! </Button>
.