<?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[Abdul Malik's blog]]></title><description><![CDATA[A software developer based in Indonesia, who specializes in Frontend Web Development]]></description><link>https://blog.up2dul.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 11:43:27 GMT</lastBuildDate><atom:link href="https://blog.up2dul.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Trying Biome as the next code linter and formatter]]></title><description><![CDATA[Intro
As a software developer, our primary task is to write code, and it is not just about writing it so that the program runs well. We also need to ensure that the code we write is clean, which means we must pay attention to things such as giving va...]]></description><link>https://blog.up2dul.dev/trying-biome-as-the-next-code-linter-and-formatter</link><guid isPermaLink="true">https://blog.up2dul.dev/trying-biome-as-the-next-code-linter-and-formatter</guid><category><![CDATA[biome]]></category><category><![CDATA[Linter]]></category><category><![CDATA[eslint]]></category><category><![CDATA[Prettier]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Abdul Malik]]></dc:creator><pubDate>Thu, 28 Mar 2024 02:16:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1720264156155/f83a7097-9cbf-4f8b-8c08-6b4c0dcc4719.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-intro">Intro</h1>
<p>As a software developer, our primary task is to write code, and it is not just about writing it so that the program runs well. We also need to ensure that the code we write is clean, which means we must pay attention to things such as giving variable names, removing unused code, and maintaining consistency. While a developer can manually keep the code clean, it can be difficult when there is a lot of code to write, and when we working with a team.</p>
<p><img src="https://miro.medium.com/v2/resize:fit:800/0*jnjuUq6sSpXElmRp.jpeg" alt class="image--center mx-auto" /></p>
<blockquote>
<p>Note: the topic we will talk about in here is not really cover/represent about "clean code", there are a lot another things about clean code outside.</p>
</blockquote>
<p>This is where tools like code linters and formatters come in handy. As developers who use JavaScript especially, we must already know about ESLint and Prettier. Both of these are popular tools that useful in keeping our codebase clean and consistent. With <strong>ESLint</strong> we can trace syntax errors, logic errors, get code suggestions, etc, based on the ESLint rules that we already config. While <strong>Prettier</strong> is used for formatting our code which includes the semicolon usable, tab indentation, quotes usable, trailing comma, etc, it is based on our Prettier configuration as well. In the project, we can use one of them or even combine both of them.</p>
<h1 id="heading-about-biome">About Biome</h1>
<p>In August 2023, there was another code linter/formatter tool released, it's named Biome, so it's what we will talk about.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1711563997935/1d8ffb10-b389-4770-ab7e-cfd4bf3c61a6.png" alt="Biome home page" class="image--center mx-auto" /></p>
<blockquote>
<p>Fun fact: the first logo of Biome was looks like same with <a target="_blank" href="https://remix.run">Remix</a> logo XD.</p>
</blockquote>
<h2 id="heading-what-is-this">What is this?</h2>
<blockquote>
<p><strong>Biome is a</strong><a target="_blank" href="https://github.com/biomejs/biome/tree/main/benchmark#formatting"><strong>fast formatter</strong>for <em>JavaScript</em></a>, <em>TypeScript</em>, <em>JSX</em>, and <em>JSON</em> that scores <a target="_blank" href="https://console.algora.io/challenges/prettier"><strong>97% compatibility with <em>Prettier</em></strong></a>, <a target="_blank" href="https://console.algora.io/challenges/prettier"><strong>saving CI and developer time</strong>.</a></p>
<p><strong>Biome is a</strong><a target="_blank" href="https://github.com/biomejs/biome/tree/main/benchmark#linting"><strong>performant linter</strong></a> for <em>JavaScript</em>, <em>TypeScript</em>, and <em>JSX</em> that features <a target="_blank" href="https://biomejs.dev/linter/rules/"><strong>more than 200 rules</strong></a> from ESLint, typescript-eslint, and <a target="_blank" href="https://github.com/biomejs/biome/discussions/3">other sources</a>.</p>
</blockquote>
<p>That's two main points that I quote from the <a target="_blank" href="https://biomejs.dev">official site</a>. So basically Biome is a JavaScript/TypeScript linter and formatter same as ESLint and Prettier, yeah so Biome alone does a thing that ESLint and Prettier do, and it is built on <strong>Rust</strong>.</p>
<h2 id="heading-reasons-to-use-it">Reasons to use it</h2>
<p>Before trying to use it, let's get to know why we should try it, and maybe make it an ESLint and Prettier alternative for our development.</p>
<h3 id="heading-better-performance">Better performance</h3>
<p>Biome has a better performance on linting and formatting code, yup, as I mentioned below, Biome is built on 🦀 Rust. And then.., I don't know how to describe this anymore tbh.</p>
<h3 id="heading-some-pre-configured-rules">Some pre-configured rules</h3>
<p>If you have used ESLint and Prettier before, you know there are a lot of plugins to do simple things such as TypeScript, React plugins, or import sorter from Trivago. So Biome came in already with some useful top-level config options such as some I mentioned before, which are TypeScript, React, and import sorter.</p>
<h3 id="heading-idetext-editor-integrations">IDE/Text editor integrations</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1711565398087/3a4c5c15-e039-4142-bbc2-faac6bc36beb.png" alt="Biome extension on Visual Studio Code" class="image--center mx-auto" /></p>
<p>Biome already has an official integration/plugin with Visual Studio Code and IntelliJ IDEA, and a plugin that is maintained by communities for some other editors such as Neovim, Emacs, Helix, and Sublime Text. Get to know more about this <a target="_blank" href="https://biomejs.dev/guides/integrate-in-editor/">here</a>.</p>
<h1 id="heading-getting-started">Getting started</h1>
<p>"Talk is cheap, show me the <s>code</s> demo", let's try to use it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1711587816655/0054df29-22a5-41e2-a10b-f33ad6d7a223.png" alt class="image--center mx-auto" /></p>
<p>Here I will use the basic React Vite app for the implementation.</p>
<h2 id="heading-install-biome">Install Biome</h2>
<p>So, first of all, install the Biome itself as the development dependencies, here I will use <a target="_blank" href="https://pnpm.io">PNPM</a> as the package manager.</p>
<pre><code class="lang-bash">pnpm add --save-dev --save-exact @biomejs/biome

<span class="hljs-comment"># if using NPM</span>
npm i --save-dev --save-exact @biomejs/biome
<span class="hljs-comment"># if using Yarn</span>
yarn add --dev --exact @biomejs/biome
</code></pre>
<blockquote>
<p><code>--exact</code> will resolve the version of the package and add it to your <code>package.json</code> with an exact version number instead of a version range.</p>
</blockquote>
<h2 id="heading-init-configuration-file">Init configuration file</h2>
<p>Now create a Biome configuration file by running the init command.</p>
<pre><code class="lang-bash">pnpm biome init

<span class="hljs-comment"># if using NPM</span>
npx @biomejs/biome init
<span class="hljs-comment"># if using Yarn</span>
yarn biome init
</code></pre>
<p>After running that command, now we will have <code>biome.json</code> a file in our root project directory. The file will contain this code:</p>
<pre><code class="lang-bash">{
    <span class="hljs-string">"<span class="hljs-variable">$schema</span>"</span>: <span class="hljs-string">"https://biomejs.dev/schemas/1.6.3/schema.json"</span>,
    <span class="hljs-string">"organizeImports"</span>: {
        <span class="hljs-string">"enabled"</span>: <span class="hljs-literal">true</span>
    },
    <span class="hljs-string">"linter"</span>: {
        <span class="hljs-string">"enabled"</span>: <span class="hljs-literal">true</span>,
        <span class="hljs-string">"rules"</span>: {
            <span class="hljs-string">"recommended"</span>: <span class="hljs-literal">true</span>
        }
    }
}
</code></pre>
<h2 id="heading-usage">Usage</h2>
<p>After initiating the configuration file, now we can use it. There are three main commands.</p>
<ol>
<li>Format files.</li>
</ol>
<pre><code class="lang-bash">pnpm biome format &lt;files&gt; --write

<span class="hljs-comment"># if using NPM</span>
npx @biomejs/biome format &lt;files&gt; --write
<span class="hljs-comment"># if using Yarn</span>
yarn biome format &lt;files&gt; --write
</code></pre>
<ol start="2">
<li>Lint files.</li>
</ol>
<pre><code class="lang-bash">pnpm biome lint &lt;files&gt;

<span class="hljs-comment"># if using NPM</span>
npx @biomejs/biome lint &lt;files&gt;
<span class="hljs-comment"># if using Yarn</span>
yarn biome lint &lt;files&gt;
</code></pre>
<ol start="3">
<li>Run both format and lint.</li>
</ol>
<pre><code class="lang-bash">pnpm biome check --apply &lt;files&gt;

<span class="hljs-comment"># if using NPM</span>
npx @biomejs/biome check --apply &lt;files&gt;
<span class="hljs-comment"># if using Yarn</span>
yarn biome check --apply &lt;files&gt;
</code></pre>
<p>To make it easier, let's just add those commands into <code>"scripts"</code> in the <code>package.json</code>. So the <code>package.json</code> file would look like this:</p>
<pre><code class="lang-json">{
  <span class="hljs-comment">// ...</span>
  <span class="hljs-attr">"scripts"</span>: {
    <span class="hljs-comment">// ...</span>
    <span class="hljs-attr">"format"</span>: <span class="hljs-string">"biome format --write ./src"</span>,
    <span class="hljs-attr">"lint"</span>: <span class="hljs-string">"biome lint ./src"</span>,
    <span class="hljs-attr">"check"</span>: <span class="hljs-string">"biome check --apply ./src"</span>
  },
  <span class="hljs-comment">// ...</span>
}
</code></pre>
<p>So now we just run these commands easily. Go <a target="_blank" href="https://biomejs.dev/reference/configuration/">here</a> for the advanced configurations.</p>
<h1 id="heading-development-status">Development status</h1>
<p>The latest minor release of Biome came on 8 March 2024, which is version <a target="_blank" href="https://github.com/biomejs/biome/releases/tag/cli%2Fv1.6.0">1.6.0</a>. It has some changes, such as "Partial support for Astro, Svelte, and Vue files" and some new rules. So it's good news for developers who casually use Astro, Svelte, and Vue.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Now should we use Biome and fully replace ESLint and Prettier?</p>
<ol>
<li><p>It depends, currently, I use it for my project only, if you are going to use it on your work project, maybe you can discuss it with your team.</p>
</li>
<li><p>If there is an ESLint or Prettier plugin rule that always you use and is not available yet on Biome, then you can just use ESLint with Prettier.</p>
</li>
</ol>
<p>And maybe there are other reasons to think about it.</p>
<p>So that's it, thank you ✨.</p>
<h1 id="heading-references">References</h1>
<ul>
<li><p><a target="_blank" href="https://biomejs.dev/">https://biomejs.dev</a></p>
</li>
<li><p><a target="_blank" href="https://youtu.be/KI7mbm-BxqA?si=h16A0ZJYntzfGzZJ">https://youtu.be/KI7mbm-BxqA?si=h16A0ZJYntzfGzZJ</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[A Guide to Contributing to an Open Source Projects]]></title><description><![CDATA[What is Open Source?
From Wikipedia, this is what we get about Open Source:

Open-source software (OSS) is computer software that is released under a license in which the copyright holder grants users the rights to use, study, change, and distribute ...]]></description><link>https://blog.up2dul.dev/a-guide-to-contributing-to-an-open-source-projects</link><guid isPermaLink="true">https://blog.up2dul.dev/a-guide-to-contributing-to-an-open-source-projects</guid><category><![CDATA[Open Source]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[contribution to open source]]></category><category><![CDATA[Pull Requests]]></category><dc:creator><![CDATA[Abdul Malik]]></dc:creator><pubDate>Sun, 23 Jul 2023 16:23:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1720263898762/d65d039b-5ccc-45e6-ba5d-089c004e2c61.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-open-source">What is Open Source?</h2>
<p>From Wikipedia, this is what we get about Open Source:</p>
<blockquote>
<p><strong>Open-source software</strong> (<strong>OSS</strong>) is <a target="_blank" href="https://en.wikipedia.org/wiki/Software">computer software</a> that is released under a <a target="_blank" href="https://en.wikipedia.org/wiki/Open-source_license">license</a> in which the <a target="_blank" href="https://en.wikipedia.org/wiki/Copyright">copyright</a> holder grants users the rights to use, study, change, and <a target="_blank" href="https://en.wikipedia.org/wiki/Software_distribution">distribute the software</a> and its <a target="_blank" href="https://en.wikipedia.org/wiki/Source_code">source code</a> to anyone and for any purpose.</p>
</blockquote>
<p>In simpler terms, it means that the software's underlying code is made accessible to the public, and anyone is allowed to view, modify, and share it.</p>
<h2 id="heading-why-contribute-to-open-source">Why contribute to Open Source?</h2>
<p>By contributing to the project, we can help the community who made it and so many peoples who used the project, and your contribution history can be a valuable addition to their portfolio. We can even contribute some simple things such as typos, grammatical errors, or docs addition, so not every contribution should be a code change.</p>
<h2 id="heading-pre-requisite">Pre-requisite</h2>
<p>You only need to know about the basic of <a target="_blank" href="https://git-scm.com/">git</a> such as cloning, push, and pull. And already have a GitHub or another git platform account.</p>
<h2 id="heading-finding-the-project-to-contribute">Finding the project to contribute</h2>
<p>Selecting a project that aligns with your interests and expertise is essential. Look for projects that you use or find interesting. To explore different projects, you can browse them on popular platforms like GitHub, GitLab, and Bitbucket.</p>
<h3 id="heading-example">Example</h3>
<p>Recently I am on learning and exploring Jotai state management at <a target="_blank" href="https://tutorial.jotai.org">tutorial.jotai.org</a> (<em>an Official interactive Jotai tutorials website</em>) and found something wrong with the sentences, so here I will use this as an example to contribute because it was open source too.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690104010777/ec40f301-517a-4106-b8da-b5d2878c0340.png" alt class="image--center mx-auto" /></p>
<p>I captured this from <a target="_blank" href="https://tutorial.jotai.org/quick-start/theme-setting">tutorial.jotai.org/quick-start/theme-setting</a> which is one of the pages on the website, something's wrong, right? Yeah, there are some grammatical errors, especially the "for you app" sentence, this is what I want to fix, so let's just get started.</p>
<blockquote>
<p>FYI: <a target="_blank" href="https://jotai.org">Jotai</a> is one of the popular state management libraries for React app.</p>
</blockquote>
<h2 id="heading-get-in-touch-with-the-project-source">Get in touch with the project source</h2>
<p>So, after finding the project that would we contribute to, let's open the source of the project. For this case, it is <a target="_blank" href="https://github.com/jotaijs/jotai-tutorial">github.com/jotaijs/jotai-tutorial</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690104628024/a0d1203c-0940-4d78-82b0-f37de215517b.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p>It is a Next.js project, if you don't know about Next.js it doesn't matter, because it is only for example.</p>
</blockquote>
<h3 id="heading-know-what-to-change">Know what to change</h3>
<p>Make sure we know what we will change through the project codebase. In my case, it is in <a target="_blank" href="https://github.com/jotaijs/jotai-tutorial/blob/main/app/quick-start/theme-setting/markdown.ts">~/app/quick-start/theme-setting/markdown.ts</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690106939520/c94da8a6-112b-4819-926c-4883df8b66e3.png" alt class="image--center mx-auto" /></p>
<p>Yup, that is the code that shows the grammatical errors.</p>
<h3 id="heading-contribution-guidelines">Contribution guidelines</h3>
<p>Getting to know about project contribution guidelines is one of the important parts. We should read and understand the contribution guidelines of the open source project we want to contribute to which is usually listed in the file <code>CONTRIBUTING.md</code>. Here is an example:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690113125710/b6bc89ac-9409-423c-8575-05af38a79fcf.png" alt class="image--center mx-auto" /></p>
<p>The file usually contains "<strong>How to contribute"</strong>, "<strong>Code of Conduct", "Branching and Versioning"</strong>, and "<strong>Coding Standards and Style Guidelines".</strong></p>
<h2 id="heading-start-to-make-a-changes">Start to make a changes</h2>
<blockquote>
<p>I will use GitHub because the project that I am exemplifying is on GitHub. So if the project you are going to contribute is on another platform like GitLab or Bitbucket, that's fine.</p>
</blockquote>
<h3 id="heading-fork-the-repository">Fork the repository</h3>
<p>On the project repository page, click the "<strong>Fork"</strong> button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690115541859/abe7ff23-19ba-46fd-a4be-d101582c45ce.png" alt class="image--center mx-auto" /></p>
<p>In this step, we can create a new name or description of the repository. But I will change nothing, so in this step, I will immediately click the "<strong>Create fork</strong>" button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690115408452/4cab23c6-c5e0-44c7-8dad-825caa0f8fbf.png" alt class="image--center mx-auto" /></p>
<p>So here is my repository that forked from <a target="_blank" href="https://github.com/jotaijs/jotai-tutorial">github.com/jotaijs/jotai-tutorial</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690115876876/40e88cf6-b36b-4188-9e67-3f540a4848a9.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-clone-the-forked-repository">Clone the forked repository</h3>
<p>Now on the forked repository clone the git repository to local. Copy the git URL.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690120879926/b1abfb94-1ff1-48d4-b967-3ef8f263ed5a.png" alt class="image--center mx-auto" /></p>
<p>Open the local directory for the project to the terminal, run <code>git clone &lt;GIT_URL&gt; &lt;PROJECT_FOLDER_NAME&gt;</code>, in here I pass the folder name to "jotai-tutorial".</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690121720577/ea32dd0e-9755-4fa6-a20f-00b02fd50d44.png" alt class="image--center mx-auto" /></p>
<p>And then open the project using code editor, I will use <a target="_blank" href="https://code.visualstudio.com">Visual Studio Code</a>.</p>
<h3 id="heading-make-a-changes">Make a changes</h3>
<p>Because we already know what would we change, so just make the changes now using code editor.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690123788621/827d6541-a05a-431b-ad49-7f2cb668bdb6.png" alt="Before and after changes" class="image--center mx-auto" /></p>
<p>Those are the changes I have been working on. Left (before) and right (after).</p>
<h3 id="heading-push-the-changes">Push the changes</h3>
<p>After we make the changes now create a new branch. Why did we create a new branch instead of using the main (<code>main</code>) branch? it's keeping the <code>main</code> branch clean. So in this case, I will create a new branch named <code>fix/theme-switcher-grammar</code> by running this command:</p>
<pre><code class="lang-bash">git checkout -b fix/theme-switcher-grammar
</code></pre>
<p>By running the command, we also automatically moved to the new branch. Then now I will commit the changes. Then add the changes to the staging and commit.</p>
<pre><code class="lang-bash">git add .
git commit -m <span class="hljs-string">"fix: grammatical errors in theme switcher page instructions"</span>
</code></pre>
<p>And now push the new branch with changes to the fork on GitHub.</p>
<pre><code class="lang-bash">git push origin fix/theme-switcher-grammar
</code></pre>
<blockquote>
<p>For the branch name and commit message, make sure we provide clear naming/message and related to what we change.</p>
</blockquote>
<h3 id="heading-back-to-the-github">Back to the GitHub</h3>
<p>Then if we back to the forked repository, there is will appear a notification like this with the button "<strong>Compare &amp; pull request</strong>", and now let's click the button because we want to make a pull request.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690125394066/460a8865-426a-4d8c-99b9-f0ee5bf071e0.png" alt class="image--center mx-auto" /></p>
<p>Then we will get directed to the pull request page, we can fill the pull request title and description well. Make sure we fill in the title according to the context of the changes we make. In my case, I fill the title "Fix grammatical errors in theme switcher page instructions", and would be better if we provide the screenshots for the changes we make. If it's done, then we click the "<strong>Create pull request</strong>" button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690128383671/f2418da6-2a6b-447b-84b1-be1a906489db.png" alt class="image--center mx-auto" /></p>
<p>And done.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1690128462215/28c8df3e-8401-4402-a18a-efab4b8b5aed.png" alt class="image--center mx-auto" /></p>
<p>Now we need to wait for the review from the project maintainer, if it is approved it will be merged by them, otherwise, if there are still errors or something wrong then usually they will comment and tell us to improve the changes we made.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Contributing to open source projects is one of the ways that allows we to make a positive impact on the software community. By choosing the right project, engaging with the community, and submitting meaningful contributions, we can become an active part of the open source movement and advance our coding skills to new heights.</p>
]]></content:encoded></item><item><title><![CDATA[Introduction into Chakra UI]]></title><description><![CDATA[Want to read in Bahasa Indonesia version? here you go: https://medium.com/@up2dul/chakra-ui-0-perkenalan-b493f059ebe1

What is Chakra UI?
From the official website, this is what we get about Chakra UI:

Chakra UI is a simple, modular and accessible c...]]></description><link>https://blog.up2dul.dev/introduction-into-chakra-ui</link><guid isPermaLink="true">https://blog.up2dul.dev/introduction-into-chakra-ui</guid><category><![CDATA[React]]></category><category><![CDATA[Chakra-ui]]></category><category><![CDATA[ui components]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[react components ]]></category><dc:creator><![CDATA[Abdul Malik]]></dc:creator><pubDate>Wed, 03 May 2023 12:50:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1720263848108/b8cd098a-e669-4965-8fa7-4908c24705af.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Want to read in <strong>Bahasa Indonesia</strong> version? here you go: <a target="_blank" href="https://medium.com/@up2dul/chakra-ui-0-perkenalan-b493f059ebe1">https://medium.com/@up2dul/chakra-ui-0-perkenalan-b493f059ebe1</a></p>
</blockquote>
<h2 id="heading-what-is-chakra-ui">What is Chakra UI?</h2>
<p>From the official website, this is what we get about Chakra UI:</p>
<blockquote>
<p>Chakra UI is a simple, modular and accessible component library that gives you the building blocks you need to build your React applications.</p>
</blockquote>
<p>So Chakra UI is one of the most popular React UI Component libraries. Chakra UI provides some built-in components that are ready to use, so this is a solution for those who don't want to create React components manually from scratch.</p>
<p>There are some other React UI components such as <a target="_blank" href="https://mui.com/">Material UI</a>, <a target="_blank" href="https://mantine.dev">Mantine</a>, and <a target="_blank" href="https://ant.design/">Ant Design</a>, but in this article, we will only learn about Chakra UI and not compare them.</p>
<h2 id="heading-why-use-chakra-ui-for-react-project">Why use Chakra UI for React project?</h2>
<h3 id="heading-built-in-accessibility">Built-in accessibility</h3>
<p>Chakra UI provides components that are designed with accessibility in mind and provides built-in support for common accessibility features such as screen reader compatibility and keyboard navigation. This makes it easier for developers to create accessible interfaces without having to implement these features from scratch. Get to know more about website accessibility: <a target="_blank" href="https://chakra-ui.com/blog/the-beginners-guide-to-building-an-accessible-web">https://chakra-ui.com/blog/the-beginners-guide-to-building-an-accessible-web</a>.</p>
<h3 id="heading-custom-hooks">Custom hooks</h3>
<p>When developing a website using React, we are always faced with a situation where we need custom hooks, and the great thing is, Chakra UI also provides utility custom hooks that are so useful, such as <code>useBoolean</code>, <code>useClickOutside</code>, and <code>useClipboard</code>. We don't need to install anything more, so just import the hooks that we want from <code>'@chakra-ui/react'</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683023357691/c860c04e-dae1-41c4-a524-76e7488f7e1e.png" alt="Chakra UI custom hooks" class="image--center mx-auto" /></p>
<h3 id="heading-active-community">Active community</h3>
<p>Chakra UI has an active and supportive community of developers who contribute to the development and provide support. This makes it easier to get help and find solutions to common problems.</p>
<h2 id="heading-start-using-chakra-ui-on-the-project">Start using Chakra UI on the project</h2>
<blockquote>
<p>I don't provide the step for generating React project from scratch in this part, so if want to follow make sure you already have a React project using <a target="_blank" href="https://create-react-app.dev/">CRA</a>, <a target="_blank" href="https://vitejs.dev/">Vite</a>, <a target="_blank" href="https://nextjs.org">Next.js</a>, or anything else.</p>
</blockquote>
<p>So in the project directory, open the terminal and install Chakra UI along with some additional libraries. We can use <a target="_blank" href="https://www.npmjs.com/">npm</a>, <a target="_blank" href="https://yarnpkg.com/">yarn</a>, or <a target="_blank" href="https://pnpm.io/">pnpm</a> to install it.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># npm</span>
npm i @chakra-ui/react @emotion/react @emotion/styled framer-motion

<span class="hljs-comment"># yarn</span>
yarn add @chakra-ui/react @emotion/react @emotion/styled framer-motion

<span class="hljs-comment"># pnpm</span>
pnpm add @chakra-ui/react @emotion/react @emotion/styled framer-motion
</code></pre>
<p>After that, we can add the Chakra UI component provider to the root of the application project, for example here is a file called <code>App.jsx</code> as an application root in the <code>src</code> folder.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// ~/src/App.jsx</span>
<span class="hljs-keyword">import</span> { ChakraProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">'@chakra-ui/react'</span>;

<span class="hljs-keyword">const</span> App = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ChakraProvider</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">App</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ChakraProvider</span>&gt;</span></span>
  )
}
</code></pre>
<p>If we use Next.js, then will be like this:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// ~/pages/_app.jsx</span>
<span class="hljs-keyword">import</span> { ChakraProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">'@chakra-ui/react'</span>;

<span class="hljs-keyword">const</span> MyApp = <span class="hljs-function">(<span class="hljs-params">{ Component, pageProps }</span>) =&gt;</span> (
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ChakraProvider</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">Component</span> {<span class="hljs-attr">...pageProps</span>} /&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">ChakraProvider</span>&gt;</span></span>
);

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> MyApp;
</code></pre>
<p>So in essence, please adjust it according to the project folder structure used.</p>
<p>And then we can import the component that we want from Chakra UI. This is the example if we use Next.js:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// ~/pages/index.jsx</span>
<span class="hljs-keyword">import</span> Head <span class="hljs-keyword">from</span> <span class="hljs-string">'next/head'</span>;
<span class="hljs-keyword">import</span> {
  Box,
  Button,
  Heading,
  Text,
} <span class="hljs-keyword">from</span> <span class="hljs-string">'@chakra-ui/react'</span>;

<span class="hljs-keyword">const</span> Home = <span class="hljs-function">() =&gt;</span> (
  <span class="xml"><span class="hljs-tag">&lt;&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">Head</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Hello Chakra UI<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">'description'</span> <span class="hljs-attr">content</span>=<span class="hljs-string">'Hello Chakra UI'</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">'icon'</span> <span class="hljs-attr">href</span>=<span class="hljs-string">'/favicon.ico'</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">Head</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">Box</span> <span class="hljs-attr">as</span>=<span class="hljs-string">'section'</span> <span class="hljs-attr">mt</span>=<span class="hljs-string">'40px'</span> <span class="hljs-attr">textAlign</span>=<span class="hljs-string">'center'</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Heading</span> <span class="hljs-attr">fontSize</span>=<span class="hljs-string">'4xl'</span>&gt;</span>Hello world<span class="hljs-tag">&lt;/<span class="hljs-name">Heading</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">mt</span>=<span class="hljs-string">'4px'</span>&gt;</span>
        Welcome to Chakra UI
      <span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Button</span> <span class="hljs-attr">mt</span>=<span class="hljs-string">'20px'</span>&gt;</span>Button from Chakra<span class="hljs-tag">&lt;/<span class="hljs-name">Button</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">Box</span>&gt;</span>
  <span class="hljs-tag">&lt;/&gt;</span></span>
);

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Home;
</code></pre>
<blockquote>
<p>Go to <a target="_blank" href="https://chakra-ui.com/docs/components">https://chakra-ui.com/docs/components</a> to see the component list.</p>
</blockquote>
<p>So the result will be like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683117978118/eeb85714-39ee-4e96-9a73-d42899260f1c.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Finally, we got to know what is Chakra UI, and why to use it, and we have had success installing it to our project. You can explore the other components and or even implement them in your React project. With such good documentation and active community from the developers and the users, so we don't need to worry about using it.</p>
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://chakra-ui.com/">https://chakra-ui.com/</a></p>
</li>
<li><p><a target="_blank" href="https://chakra-ui.com/blog/the-beginners-guide-to-building-an-accessible-web">https://chakra-ui.com/blog/the-beginners-guide-to-building-an-accessible-web</a></p>
</li>
</ul>
]]></content:encoded></item></channel></rss>