<?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>Forem: ORGENIC Team</title>
    <description>The latest articles on Forem by ORGENIC Team (@orgenicteam).</description>
    <link>https://forem.com/orgenicteam</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%2F165291%2F83b57e9e-1a30-459f-8251-1d53ef0dcb19.png</url>
      <title>Forem: ORGENIC Team</title>
      <link>https://forem.com/orgenicteam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/orgenicteam"/>
    <language>en</language>
    <item>
      <title>Styling ORGENIC UI Components</title>
      <dc:creator>ORGENIC Team</dc:creator>
      <pubDate>Mon, 27 May 2019 12:04:01 +0000</pubDate>
      <link>https://forem.com/orgenicteam/styling-orgenic-ui-components-5g91</link>
      <guid>https://forem.com/orgenicteam/styling-orgenic-ui-components-5g91</guid>
      <description>&lt;h1&gt;
  
  
  Styling ORGENIC UI Components
&lt;/h1&gt;

&lt;p&gt;ORGENIC UI is a growing set of web components with focus on UX and design. Though ORGENIC UI comes with an integrated theming system it is often useful to modify the current theme quick and effective for individual purposes instead of creating a complete theme from scratch. This tutorial shows how to change the given styles of the ORGENIC UI tab component.&lt;/p&gt;

&lt;h1&gt;
  
  
  Insert the Component
&lt;/h1&gt;

&lt;p&gt;Just add this code to use a tab control within an ORGENIC UI project:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;og-tab-container&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;og-tab&lt;/span&gt; &lt;span class="na"&gt;label=&lt;/span&gt;&lt;span class="s"&gt;"Tab Title"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!--CONTENT OF THE TAB --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/og-tab&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/og-tab-container&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Listing 1: adding the tab control to the template&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/orgenic-team/embed/rgMzMB?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Style the Component
&lt;/h1&gt;

&lt;p&gt;Since all ORGENIC UI components are native &lt;em&gt;WebComponents&lt;/em&gt; with &lt;em&gt;ShadowDOM&lt;/em&gt;, it is not possible to overwrite them with basic CSS features. For example, it is impossible to set the background-color of the current selected tab like this:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.og-tabs__list-item--selected&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&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;Listing 2: This won’t work&lt;/p&gt;

&lt;h2&gt;
  
  
  Custom properties to the rescue
&lt;/h2&gt;

&lt;p&gt;Themability is one of the underlying features of ORGENIC UI. To provide the capability of modifying styles within the ShadowDOM by an external stylesheet, ORGENIC UI uses CSS &lt;strong&gt;Custom Properties&lt;/strong&gt; aka CSS variables. Therefor every component has its own set of CSS variables the user can use to create an individual design.&lt;/p&gt;

&lt;p&gt;All UI components and their Custom Properties are documented at &lt;a href="http://docs.orgenic.org"&gt;http://docs.orgenic.org&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Modify the Design
&lt;/h2&gt;

&lt;p&gt;This example will show how to apply a new background color for the tabs. The documentation provides the CSS variables needed:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;--og-tabs__tab-Background&lt;/span&gt;
&lt;span class="nt"&gt;--og-tabs__tab-Background--hover&lt;/span&gt;
&lt;span class="nt"&gt;--og-tabs__tab-Background--active&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Just create a new CSS file (custom-theme.css) where the new values are applied to the CSS variables and include it as last stylesheet into the HTML:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;og-tab-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;--og-tabs__tab-Background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                 &lt;span class="m"&gt;#39b6e4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--og-tabs__tab-Background--active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;         &lt;span class="m"&gt;#1ca2d2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--og-tabs__tab-Background--hover&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;          &lt;span class="m"&gt;#1ca2d2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                     &lt;span class="m"&gt;#FFFFFF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;              
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;og-tab&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="m"&gt;#333333&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;Listing 3: Overwriting the default theme&lt;/p&gt;

&lt;p&gt;The text color of the tabs title and the content are set to &lt;code&gt;inherit&lt;/code&gt;. That means - despite of the ShadowDOM - it is enough to set the parents CSS property &lt;code&gt;color&lt;/code&gt; to change it without any special Custom Property.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/jfuhrmann/embed/QROGjN?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  TL;DR
&lt;/h1&gt;

&lt;p&gt;With the power of pre-defined CSS variables, it is very easy to modify the design of ORGENIC UI components without creating a complete theme. The encapsulation that comes with the ShadowDOM makes the components immune against side effects from foreign CSS, but also open to its own specific Custom Properties.&lt;/p&gt;

&lt;h1&gt;
  
  
  Please visit us at:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://orgenic.org/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=stylingcomponents"&gt;https://orgenic.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/orgenic/orgenic-ui"&gt;https://github.com/orgenic/orgenic-ui&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/orgenicUI"&gt;https://twitter.com/orgenicUI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>orgenicui</category>
      <category>webcomponents</category>
      <category>ux</category>
      <category>design</category>
    </item>
  </channel>
</rss>
