Skip to content

Component library setup with Vite, Rollup, React and tailwindcss 4 #17715

Answered by wongjn
romankoho asked this question in Help
Discussion options

You must be logged in to vote

As it stands currently, you have two sets of Tailwind-generated CSS, one from the library and one from the consumer. Some of this would be duplicate or interfere with each other. Instead, consider having consumers compile Tailwind CSS for their own code as well as the library's.

In ui-components:

  • Remove @imports in ui-components/src/lib/tailwind/theme.css:
    -@import 'tailwindcss';
    -@import 'tailwindcss/preflight.css' layer(base);
    -
     @theme {
       --font-sans: 'Inter', ui-sans-serif, system-ui;
       --font-weight-light: 300;
    This removes the duplication.
  • Add @source directive in ui-components/src/lib/tailwind/theme.css:
       --color-greyscale-medium-3: #808080;
       --color-greyscale-white: #fffff…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@romankoho
Comment options

Answer selected by romankoho
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants