<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Workodoro</title>
    <description>The latest articles on DEV Community by Workodoro (@workodoro).</description>
    <link>https://dev.to/workodoro</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1538311%2F4f967e06-5729-4abf-bd58-b2b932011712.png</url>
      <title>DEV Community: Workodoro</title>
      <link>https://dev.to/workodoro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/workodoro"/>
    <language>en</language>
    <item>
      <title>Solving the Radix Integration Issue in Next.js</title>
      <dc:creator>Workodoro</dc:creator>
      <pubDate>Tue, 28 May 2024 09:56:28 +0000</pubDate>
      <link>https://dev.to/workodoro/solving-the-radix-integration-issue-in-nextjs-4cme</link>
      <guid>https://dev.to/workodoro/solving-the-radix-integration-issue-in-nextjs-4cme</guid>
      <description>&lt;p&gt;I am Leo Hoang. Currently, I am working on my next startup project: Workodoro. While working with the Workodoro application, I encountered an issue integrating Radix into Next.js.&lt;/p&gt;

&lt;p&gt;From version 13.0 to 14.1, Next.js has an issue with the import order of CSS files in app/**/layout.tsx. This can result in Radix Themes overwriting your custom styles, even when the import statements are correctly structured:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@radix-ui/themes/styles.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./my-styles.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This problem can occur sporadically, affecting either development or production environments, leading to inconsistencies. Fortunately, there are effective solutions to ensure your styles are applied as intended.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Merging CSS Files with postcss-import&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most reliable method is to merge all CSS into a single file using the postcss-import plugin. This approach ensures a consistent import order by consolidating all your styles into one unified file.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step-by-Step Guide:
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;1. Install postcss-import:&lt;/strong&gt; First, install the postcss-import plugin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;postcss-import
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Configure postcss.config.js:&lt;/strong&gt; Add postcss-import to your postcss.config.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;postcss-import&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
    &lt;span class="na"&gt;tailwindcss&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
    &lt;span class="na"&gt;autoprefixer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Update Your CSS File:&lt;/strong&gt; Import Tailwind's base styles first, followed by Radix Themes, and then your components and utilities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"tailwindcss/base"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"@radix-ui/themes/styles.css"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup ensures that Tailwind’s base styles load first, followed by Radix Themes, and then your custom components and utilities, maintaining a proper and predictable order.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;These brief notes hope to help someone facing a similar issue save time.&lt;/p&gt;

&lt;h3&gt;
  
  
  About Workodoro
&lt;/h3&gt;

&lt;p&gt;This project focuses on solving time management issues and increasing individual work efficiency in an era of distractions. The application is in the development stage, so if you don't mind trying it out, you can visit &lt;a href="https://beta.workodoro.com"&gt;beta.workodoro.com&lt;/a&gt; or &lt;a href="https://app.workodoro.com"&gt;app.workodoro.com&lt;/a&gt;, or follow us on &lt;a href="https://x.com/workodoro"&gt;Twitter&lt;/a&gt; and join our &lt;a href="https://workodoro.slack.com"&gt;Slack&lt;/a&gt; to provide feedback.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>radix</category>
      <category>webdev</category>
      <category>buildinpublic</category>
    </item>
  </channel>
</rss>
