<?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 Nelly Hovhannisyan on Medium]]></title>
        <description><![CDATA[Stories by Nelly Hovhannisyan on Medium]]></description>
        <link>https://medium.com/@nel.hovhannisyan?source=rss-6673ccff7a21------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*psYwjvC9zE3TmBpt7naCvA.jpeg</url>
            <title>Stories by Nelly Hovhannisyan on Medium</title>
            <link>https://medium.com/@nel.hovhannisyan?source=rss-6673ccff7a21------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:12:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nel.hovhannisyan/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 setup Theming in React app]]></title>
            <link>https://medium.com/preezma/how-to-setup-theming-in-react-app-53f8568983bf?source=rss-6673ccff7a21------2</link>
            <guid isPermaLink="false">https://medium.com/p/53f8568983bf</guid>
            <category><![CDATA[styled-components]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[themes]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Nelly Hovhannisyan]]></dc:creator>
            <pubDate>Wed, 09 Sep 2020 18:07:29 GMT</pubDate>
            <atom:updated>2020-09-10T09:19:42.602Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, workaholics ! 👋<br>Nowadays it is important to have theming in an application as it results a better user experience. <br>Now let’s setup theming in React application in a very simple way.</p><h3>Requirements</h3><p>In order to setup theming in a React application we need the <a href="https://styled-components.com/"><strong>styled-components</strong></a> to be installed.</p><blockquote><strong>Note</strong>: It is required to create React app first, if you don’t have it already, please follow React Get Started guide ☛ <a href="https://reactjs.org/docs/getting-started.html">https://reactjs.org/docs/getting-started.html</a>.</blockquote><blockquote><strong>Note</strong>: there are different ways to implement theming in a React application but we are going to implement it using styled-components as it is widely used in React applications.</blockquote><h3>What is styled-components?</h3><p><strong>Styled</strong>-<strong>components</strong> is a library for <strong>React</strong> and <strong>React</strong> <strong>Native </strong>which allow us to use technique called CSS-in-JS in our app. It let us write simple CSS in components without worrying about class name conflicts.</p><p>More details can be found in this <a href="https://medium.com/drivetribe-engineering/why-were-slowly-migrating-to-styled-components-2f284d4b5d95"><strong>article</strong></a>.</p><h3>Let’s get started</h3><p><strong>First </strong>we need to install <a href="https://styled-components.com/">styled components</a>:</p><pre>// with npm<br>npm install --save styled-components<br><br>// with yarn<br>yarn add styled-components</pre><p>Now let’s create a file called “Theme.js” in root directory, in which we are going to use <em>“</em><strong><em>ThemeProvider</em></strong>” to provide theme to the child components.<br> In our example we are going to have <strong>light </strong>and <strong>dark </strong>theme variants.</p><p>For each theme variant we need to create theme object with the same <strong>exact </strong>keys. <strong><em>lightTheme </em></strong>is the theme object of the <strong>light variant</strong> and <strong><em>darkTheme </em></strong>is the theme object of the <strong>dark variant</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/829223f981e186fc822bf36127e6f9c7/href">https://medium.com/media/829223f981e186fc822bf36127e6f9c7/href</a></iframe><p>The <strong>ThemeProvider </strong>accepts the <strong>“theme” prop</strong> which get the theme and provides the theme properties to child components. The <strong>Theme component</strong> accepts <strong>“themeMode” </strong>from the parent component which specifies the theme mode to the <strong>ThemeProvider</strong>, if it should be <strong>light </strong>or <strong>dark </strong>mode (in our example).</p><p>We need to import <strong>Theme component </strong>in <strong>App.js</strong> and render child component(s) in it to make theme available in child component(s).</p><p><strong>App.js<br></strong>We need to have a local state for changing the theme mode from child component(s).<br>In this example <strong>“changeThemeMode” </strong>method is responsible for switching between <strong>light </strong>and <strong>dark </strong>theme modes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27833aad8379cccf31b036ec36126634/href">https://medium.com/media/27833aad8379cccf31b036ec36126634/href</a></iframe><p><strong>Content.js<br></strong>In <strong>Content component </strong>we have access to the <strong>theme </strong>that is provided by <strong>ThemeProvider </strong>and we can use it inside <strong>styled-components</strong> (example <strong>NewCard</strong>)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5bc7119ad3ec21a42577159f59e6f6fb/href">https://medium.com/media/5bc7119ad3ec21a42577159f59e6f6fb/href</a></iframe><h3><strong>Demo</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fnw5ht&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fnw5ht&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fnw5ht%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/90ca50c52147d9c7b46fb71352123fd6/href">https://medium.com/media/90ca50c52147d9c7b46fb71352123fd6/href</a></iframe><p><a href="https://github.com/NellyHovhannisyan/Implement-Theming-in-React"><strong>Source code</strong></a> is available in<strong> </strong><a href="https://github.com/NellyHovhannisyan/Implement-Theming-in-React"><strong>github</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53f8568983bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/preezma/how-to-setup-theming-in-react-app-53f8568983bf">How to setup Theming in React app</a> was originally published in <a href="https://medium.com/preezma">Preezma Software Development Company</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>