<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eubene Sa on Medium]]></title>
        <description><![CDATA[Stories by Eubene Sa on Medium]]></description>
        <link>https://medium.com/@EubeneSa?source=rss-7bbc31adb077------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*j_Y2Cx2_6Ru70q94R4bIOg@2x.jpeg</url>
            <title>Stories by Eubene Sa on Medium</title>
            <link>https://medium.com/@EubeneSa?source=rss-7bbc31adb077------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:26:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@EubeneSa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to ensure your Emotion ‍ CSS-in-JS styles are indeed overwriting existing and/or…]]></title>
            <link>https://medium.com/@EubeneSa/how-to-ensure-your-emotion-css-in-js-styles-are-indeed-overwriting-existing-and-or-c6a099c58010?source=rss-7bbc31adb077------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6a099c58010</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css-in-js]]></category>
            <category><![CDATA[css-modules]]></category>
            <category><![CDATA[styled-components]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Eubene Sa]]></dc:creator>
            <pubDate>Fri, 23 Mar 2018 18:38:02 GMT</pubDate>
            <atom:updated>2018-03-23T18:38:02.846Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to ensure your Emotion 👩‍🎤 CSS-in-JS styles are indeed overwriting existing and/or third-party CSS Module styles</h3><p>👋🏻 there! Was there ever a time in your career you were trying to overwrite Bootstrap / Foundation / something else styles as needed? Here at Brightcove 📹, we are currently using Emotion 👩‍🎤 CSS-in-JS, CSS Grid, React, etc. for rebuilding one of our modules. Unexpectedly and oddly only in production, the Emotion styles were not overwriting our component library styles (built using CSS Modules and flexbox) as needed. It turns out that the Emotion &lt;style data-emotion&gt; tag was above the CSS Module &lt;style&gt; tags, making CSS Module styles the “!important” ones 👿:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44496c08630c8e20c1b402583f147a7e/href">https://medium.com/media/44496c08630c8e20c1b402583f147a7e/href</a></iframe><p>To make sure the Emotion styles are overwriting the CSS Module styles in production, the Emotion &lt;style data-emotion&gt; tag needed to come after the CSS Module &lt;style&gt; tags. Here is what I did to solve this:</p><ol><li>yarn add create-emotion and then create a main emotion.js for Emotion inside the top-level src or similar directory. This is exactly what the Emotion index.js does (<a href="https://github.com/emotion-js/emotion/blob/master/packages/emotion/src/index.js">https://github.com/emotion-js/emotion/blob/master/packages/emotion/src/index.js</a>). Except, here, as shown in L5–7 and L21 below, we create a new container &lt;div&gt; element to insert before our React app’s entry &lt;div&gt; and tell Emotion to insert all of its styles in there (<a href="https://github.com/emotion-js/emotion/tree/master/packages/create-emotion#container-htmlelement">https://github.com/emotion-js/emotion/tree/master/packages/create-emotion#container-htmlelement</a>).</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/997635528e2b86bcb918a2988a4a8e06/href">https://medium.com/media/997635528e2b86bcb918a2988a4a8e06/href</a></iframe><p>2. Now that we have our own Emotion instance in our app, we also need react-emotion to use this Emotion instead. To do this, yarn add create-emotion-styled and then create a main react-emotion.js for react-emotion also inside our top-level src directory. This is exactly what the react-emotion index.js does as well (<a href="https://github.com/emotion-js/emotion/blob/master/packages/react-emotion/src/index.js">https://github.com/emotion-js/emotion/blob/master/packages/react-emotion/src/index.js</a>). Except, here, as shown in L4 and L8 below, we tell react-emotion to import Emotion from our own Emotion instance (emotion.js above):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5be6d6f9585e0b5d465740fb4125c87/href">https://medium.com/media/c5be6d6f9585e0b5d465740fb4125c87/href</a></iframe><p>3. Now that we have our own Emotion and react-emotion instances, we need to tell all our components, etc. to import from these instances instead of &#39;emotion&#39; and &#39;react-emotion&#39;:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/688c185b3bb0f44f83dcc0f32c0b162e/href">https://medium.com/media/688c185b3bb0f44f83dcc0f32c0b162e/href</a></iframe><p>4. Once we deploy to production with these changes 🙏, we should be seeing the Emotion &lt;style data-emotion&gt; tag inside our newly created &lt;div id=&quot;emotion”&gt; tag and below all the CSS Module &lt;style&gt; tags:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05689afa431b10e740db8fdb33c5f0f6/href">https://medium.com/media/05689afa431b10e740db8fdb33c5f0f6/href</a></iframe><p>I hope this helps Emotion and other CSS-in-JS people out there! If you have any questions, I am <a href="https://twitter.com/eubenesa">@EubeneSa</a>!</p><p>I’d like to thank <a href="https://medium.com/u/93de0780c5e6">Kye Hohenberger</a> for his time and encouraging me to write my very first blog post. 🔥</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6a099c58010" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>