<?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"><channel><title><![CDATA[Irvv17's Blog]]></title><description><![CDATA[Irvv17's Blog]]></description><link>https://irvv17.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Nov 2026 04:56:29 GMT</lastBuildDate><atom:link href="https://irvv17.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[The Gold Mine of UI Frameworks: BaseWeb]]></title><description><![CDATA[There's a lot of UI frameworks for every JS framework out there, they offer different things but today I'm going to present you with the Baseweb]]></description><link>https://irvv17.hashnode.dev/the-gold-mine-of-ui-frameworks-baseweb</link><guid isPermaLink="true">https://irvv17.hashnode.dev/the-gold-mine-of-ui-frameworks-baseweb</guid><category><![CDATA[React]]></category><category><![CDATA[UI]]></category><category><![CDATA[CSS3]]></category><category><![CDATA[CSS Frameworks]]></category><category><![CDATA[Next.js]]></category><dc:creator><![CDATA[Irving]]></dc:creator><pubDate>Thu, 01 Apr 2021 20:49:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1617292249486/0QLAc60Ka.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="some-context">Some Context:</h3>
<p>I start this "<em>new</em>" JS frameworks journey with the Vue.js framework, after this I try Nuxt.js (it's the Next.js of Vue.js), and I love it, then I've tried some UI frameworks with it (<strong>BootstrapVue</strong>, <strong>Vuetify</strong>, <strong>Antd</strong>) they're all fantastic.</p>
<p>But I always got low-performance issues, and when I test different websites with different <strong>UI frameworks</strong>, with Lighthouse or PageSpeed Insights, the results are terrible 60, 70 maybe an 80 with a lot of effort. And then I accept it..., and to be honest I have 2 o 3 websites on production with very low performance 😢.</p>
<p><img src="https://i.imgur.com/a2oJn5Y.png" alt="Low-Performance Screenshot" /></p>
<p>After this, I learn React.js, after using it for a while I enjoy the <strong>tailwindcss/react</strong> way. But honestly re-inventing components that almost every UI-Kit or UI-Framework has out of the box, it's not a great thing (<em>at least not for me</em>).</p>
<blockquote>
<p>When you want to build complex interfaces, and you are working alone it's better to have a suite of components, and it's better if you can customize it, that's the reason that I love <strong>tailwindcss</strong>, 'cause it's very customizable, but it's a little hard to handle for me.</p>
</blockquote>
<p>After all, this and like with Vue.js I try different UI-Kits with React like <strong>Antd-REACT</strong>, <strong>ReactStrap</strong>, <strong>Semantic UI</strong>, and again <strong>THE SAME LOW-PERFORMANCE ISSUES</strong>, and I was like...maybe</p>
<p><img src="https://media.giphy.com/media/h7vNrcyrglScZOItBE/giphy.gif" alt="This is who I am" /></p>
<blockquote>
<p><em>I'm a low-performance websites guy. 😭 ... I'm not that good with performance ... maybe this is not my thing</em></p>
</blockquote>
<p>And just for causality, I found <strong>BaseWeb UI Framework</strong> ...
First, it's from <strong>Uber</strong> folks, and (at least for me) means <em>Quality</em>, has a lot of components, it's very flexible, it's very customizable, very performant and for more reasons, I feel I've found...</p>
<h3 id="a-gold-mine">A GOLD MINE 🥇.</h3>
<p>I try it..., and honestly, it was a little <strong>confusing</strong> at the beginning 'cause' they're using a "<em>particular</em>" CSS toolkit to manage the CSS of their components which is <strong>Styletron</strong> and If you read about <em>Styletron</em>, they're focusing on <strong>Performance</strong>, the particular thing among others <strong>UI-Frameworks/Toolkits</strong> (<em>Styletron specifically</em>) generates styles only when is needed.</p>
<blockquote>
<ul>
<li>This concept is also known as the <strong>critical rendering path</strong>.</li>
<li>Styletron has a CSS in JS architecture</li>
<li>Styletron is component-oriented styling</li>
</ul>
</blockquote>
<p>So, let's try Baseweb :)</p>
<h3 id="setting-up-styletron">Setting-Up Styletron ⛏️</h3>
<p>We're going to use Next.js because it has a lot of utilities for production out of the box, and we want to test the performance of the application in a production scenario (for example this website need's to be SEO friendly).</p>
<ol>
<li><p>First you need to know that Styletron works with <strong>any</strong> JS framework or even Vanilla Javascript, but <strong>BaseWeb</strong> it's only for <strong>React.js</strong> you can check <a target="_blank" href="https://www.styletron.org/react">how to setup Styletron with react</a> but we're going to check <a target="_blank" href="https://www.styletron.org/getting-started#with-nextjs">how to setup Styletron with next.js</a> and then we're going to integrate Baseweb UI.</p>
<ul>
<li>And you may like, Wait, what? <img src="https://i.imgur.com/jKbHZYL.gif" alt="wait-what?" /></li>
<li>Why we are setting up Styletron?, This post is about BaseWeb UI. ¿? ... well</li>
<li>That's because like I mentioned before, BaseWeb uses another CSS toolkit to manage the style of our components, and it's better if you understand how it works.</li>
<li>(<em>BaseWeb has a <a target="_blank" href="https://baseweb.design/getting-started/setup/">getting started</a> section but in this case, we are going to set it up from scratch to understand <strong>how it works</strong> in depth</em>)</li>
</ul>
</li>
<li><p>With this clear now Create the next app with Styletron example app provided by Styletron Team <strong>just run:</strong></p>
<ul>
<li><code>yarn create next-app --example with-styletron nextjs-basewebui-app &amp;&amp; cd nextjs-basewebui-app &amp;&amp; yarn</code></li>
</ul>
</li>
<li><p>Then run <code>yarn</code> or <code>npm</code> in <code>dev mode</code>, This package sets some configurations into <strong>_app.js</strong>, <strong>_document.js</strong>, and adds a simple example in the app/index.js page of how Styletron works.</p>
<ul>
<li>Finally, <strong>styletron.js</strong> is the file that StyletronProvider uses to inject <strong>styletron-engine-atomic</strong> and <strong>styletron-react</strong> in our app
<img src="https://i.imgur.com/MhZ2g9T.png" alt="Initial structura + view" /></li>
<li>Inspect <strong>pages/index.js</strong> and you got something like this:</li>
</ul>
</li>
</ol>
<p><code>import { styled, useStyletron } from 'styletron-react';</code></p>
<ul>
<li>Both are packages that use CSS-in-JS architecture, and you can use <em>useStyletron</em> as a hook and set styles into JSX like the example.</li>
</ul>
<p><code>const [css] = useStyletron();</code></p>
<p><code>&lt;p className={css({ fontSize: '32px' })}&gt;Styled by hook&lt;/p&gt;</code></p>
<h3 id="refactor-and-add-typescript">Refactor and Add Typescript 🔧</h3>
<blockquote>
<p>We are going to change the base structure of the project for a convention, and we are going to move to <strong> Typescript </strong> which is easy in this case, but you can work with plain <strong> JS </strong> if you prefer, We're going to move all the next.js workflow into <strong>(src/)</strong>  directory, and we will add <em>typescript</em>.</p>
</blockquote>
<p>You can follow the <strong>steps</strong>, <strong>copy</strong>, <strong>fork</strong>, or <strong>clone</strong> the necessary files in the <a target="_blank" href="https://github.com/irvv17/Nextjs-Baseweb-Boilerplate/tree/9c92727a89a2a789d55873a5c057949b123b4106">repository at this point</a>.</p>
<p>After moving the workflow into the <strong>src/</strong> directory we are going to add:</p>
<ul>
<li>Typescript</li>
<li>Jest</li>
<li>ESlint</li>
<li>Prettier</li>
</ul>
<p>Feel free to check the <a target="_blank" href="https://github.com/irvv17/Nextjs-Baseweb-Boilerplate/blob/9c92727a89a2a789d55873a5c057949b123b4106/package.json">package.JSON</a> if you don't how to set all these packages</p>
<ul>
<li>Then configure <strong>ESLINT</strong> with <strong>npx eslint --init</strong> command.</li>
<li>After this we will add prettier, this is much easier just run <strong>yarn add --dev --exact prettier</strong> and create a <strong>.prettier</strong> file.</li>
</ul>
<p>However, both files are here: <a target="_blank" href="https://github.com/irvv17/Nextjs-Baseweb-Boilerplate/blob/ec0fbe9a0d033aedd0a806ff03653cb9fc71d4e6/.prettierrc">.prettier</a>, <a target="_blank" href="https://github.com/irvv17/Nextjs-Baseweb-Boilerplate/blob/ec0fbe9a0d033aedd0a806ff03653cb9fc71d4e6/.eslintrc.json">.eslintrc.json</a></p>
<blockquote>
<p><strong>Now</strong> we have a regular next app with <strong>Styletron</strong>, but the main source is into <strong>src/</strong> folder, and we added <strong>TS</strong> and <strong>ESlint</strong> with prettier, This is the structure of the project at this point:</p>
</blockquote>
<p><img src="https://i.imgur.com/8K7vVz5.png" alt="structure with TS" /></p>
<p>The changes into <strong>src/</strong> files are just about typescript, you can check it <a target="_blank" href="https://github.com/irvv17/Nextjs-Baseweb-Boilerplate/tree/50a53a6428433160df3ea4afb97609e65610bab2">here</a>...
After these changes, if we run <strong>yarn dev</strong> we will get the same view that we've sawed before, 'cause we just change <strong>JS</strong> for <strong>TS</strong>.</p>
<p><img src="https://i.imgur.com/eNS65ur.png" alt="TS structure plus view" /></p>
<p>Now let's add Baseweb to our project, this will be easy, 'cause we have the <strong><em>heart</em></strong>❤ of Baseweb in our app (which of course is <strong>Styletron</strong>).</p>
<h3 id="setting-baseweb-ui-framework">Setting Baseweb UI framework 🛠️</h3>
<ol>
<li>First, we need to add Baseweb dependencies, this is pretty easy just run <code>yarn add baseui</code> now were going to set the <em>baseui</em> package in the whole application, this is pretty simple, 'cause we ran the Styletron boilerplate first, so we already have that configuration into _<strong>app.tsx</strong> file.</li>
<li>Now open that file and add <strong>BaseProvider</strong> (you can check it in the official documentation too) but basically, <strong>Styletron</strong> and <strong>Baseui</strong> have <strong><em>separated</em></strong> providers, so we are going to wrap <strong>StyletronProvider</strong> into <strong>BaseProvider</strong>, and Baseui will use the StyletronProvider.<ul>
<li>That's the reason that we start with just <strong>Styletron</strong>, now you can understand how baseui uses the CSS-in-JS.</li>
</ul>
</li>
<li>We need to import <strong>BaseProvider</strong>, and a <strong>theme</strong> (were going to talk about themes later), after import the file we need to wrap <strong>StyletronProvider</strong> into <strong>BaseProvider</strong><ul>
<li>(you can check the <a target="_blank" href="https://github.com/uber/baseweb#usage">official documentation</a> and it's the same thing, but our Styletron provider value is separated)
<img src="https://i.imgur.com/uj2pbfu.png" alt="_app.tsx with the baseui and styletron provider" /></li>
<li>If you run in dev mode, the result is the same 'cause you are not using any baseui component yet.<a target="_blank" href="https://github.com/irvv17/Nextjs-Baseweb-Boilerplate/blob/9c06b3d781f19a8d5e0982a4d4279332639f11fc/src/pages/_app.tsx"> you can copy this file here</a></li>
</ul>
</li>
</ol>
<h3 id="using-our-first-basewebui-component">Using our first Basewebui component</h3>
<ol>
<li>Now we can import any component of the baseui package in our pages or other components, let's add a Navbar in our <strong>index</strong> page.</li>
<li>I'm going to create a <strong>NavBar</strong> component and save it into the components directory</li>
<li>Copy the example of a navbar component in the <a target="_blank" href="https://baseweb.design/components/app-nav-bar/#examples">official documentation</a> into our <strong>NavBar.tsx</strong> file (<a target="_blank" href="https://github.com/irvv17/Nextjs-Baseweb-Boilerplate/blob/79f197771f232c5d3fcd63e7ebed51a02f61a30c/src/components/NavBar.tsx">You can copy this file here</a>)</li>
<li><img src="https://i.imgur.com/AKkFVe5.png" alt="NavBar Component" /></li>
<li>Import the NavBar component into the Index page (<a target="_blank" href="https://github.com/irvv17/Nextjs-Baseweb-Boilerplate/blob/79f197771f232c5d3fcd63e7ebed51a02f61a30c/src/pages/index.tsx">You can copy this file here</a>)<ul>
<li><img src="https://i.imgur.com/w9RsIlz.png" alt="Index with NavBar Component" /></li>
</ul>
</li>
<li>start with <code>yarn run dev</code>, and Voilà! a beautiful mobile-first Navbar appear 🤯<ul>
<li><img src="https://i.imgur.com/fcdQZtj.png" alt="Index with NavBar Component" /></li>
</ul>
</li>
<li>The most interesting of all this is the <strong><em>performance</em></strong> if you run a <strong>lighthouse</strong>  or <strong>page speed</strong> test you will reach a <strong>100  score</strong>.<ul>
<li><img src="https://media.giphy.com/media/Cd9XcHdZEIcaA/giphy.gif" alt="Reach 100% Score lighthouse with Next.js and Baseweb ui" /></li>
</ul>
</li>
</ol>
<p>Of course, you will think that is just a menu, and it's different from a real big application but honestly, <strong>I've never reached a 100 score</strong> when using a collection/kit/framework of components as I mentioned (Antd, Bootstrap, etc) before.</p>
<p>Especially when you set it <code>globally</code>, 'cause now you can consume ANY component of Baseweb, but it will generate just the critical CSS, and like I mentioned before they're emphasized <strong>performance</strong></p>
<blockquote>
<p>Of Course, Basewebui has its  <em>bad things</em></p>
<h3 id="pros">PROS:</h3>
<ul>
<li><strong>Highly</strong>: performant</li>
<li><strong>Very</strong>: customizable (Almost every aspect of the components) you can use Styletron for this or <a target="_blank" href="https://baseweb.design/guides/understanding-overrides">Baseui overrides</a></li>
<li><a target="_blank" href="https://baseweb.design/guides/theming/"><strong>Themeable</strong></a> This is very useful when you don't want generic styles.</li>
<li><strong>Private</strong>: (you can expect quality and maintenance of the project from UBER) but of course you can still contribute.</li>
</ul>
</blockquote>
<h3 id="cons">CONS:</h3>
<ul>
<li><strong>CSS-in-JS</strong>: Some people don't like to use CSS-in-JS, so if this is your case Baseweb is not for you.</li>
<li><strong>Confusing</strong>: At the beginning (How Styletron works specifically)</li>
<li><strong>Knowledge</strong>: (it would be difficult and confusing if you don't know how to set a good CSS-in-JS architecture)</li>
<li><strong>Framework</strong>: it's a framework everything is pre-created.</li>
</ul>
<h2 id="conclusions">Conclusions</h2>
<p>There's a lot of <strong>UI Kits</strong>, <strong>CSS Frameworks</strong> out there for every Javascript framework and of course, everyone has their particularities and shines in different ways, of course As you may know this framework (like other frameworks or even technologies)  is not perfect in all situations, you need to check what is better for each situation.</p>
<p>I highly recommended to you if you like to use a <strong>collection or kit of components</strong> pre-made that you can "install" once, use in the whole application, and you need a <strong>great performance</strong> in it. Of course, has pros, cons but like I mentioned before it's great when you want great performance without problems.</p>
<p>Of Course, don't forget that this is a <strong>framework</strong> so is better that you know the basis of CSS and of course Javascript, 'cause knowledge is like a plant if you have solid roots, make fruits it will be really easy.</p>
<blockquote>
<p>Thank you for taking your time to read this. I appreciate any comments/feedback or questions you may have.</p>
<p><a target="_blank" href="https://github.com/irvv17/Nextjs-Baseweb-Boilerplate">You can check the final code in GitHub, feel free to fork or clone it</a></p>
<p><a target="_blank" href="https://nextjs-baseweb-boilerplate-irvv17.vercel.app/">Live preview,  deployed in ▲Vercel</a> (Try a lighthouse test)</p>
</blockquote>
]]></content:encoded></item></channel></rss>