<?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 Mehdi AL OUAFI on Medium]]></title>
        <description><![CDATA[Stories by Mehdi AL OUAFI on Medium]]></description>
        <link>https://medium.com/@alouafi.mehdi?source=rss-7dff53bd84bd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Uy8LEXxtCFD-xiZth-5uRA.jpeg</url>
            <title>Stories by Mehdi AL OUAFI on Medium</title>
            <link>https://medium.com/@alouafi.mehdi?source=rss-7dff53bd84bd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:15:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alouafi.mehdi/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[Structuring Your React Applications with “Layout Primitives”: Today, let’s focus on the unbeatable…]]></title>
            <link>https://medium.com/@alouafi.mehdi/structuring-your-react-applications-with-layout-primitives-today-lets-focus-on-the-unbeatable-65d80cb9e547?source=rss-7dff53bd84bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/65d80cb9e547</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[layout]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Mehdi AL OUAFI]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 19:27:01 GMT</pubDate>
            <atom:updated>2024-12-02T19:27:01.435Z</atom:updated>
            <content:encoded><![CDATA[<h3>Structuring Your React Applications with “Layout Primitives”: Today, let’s focus on the unbeatable &lt;Stack /&gt; 🚀</h3><p>When I start a new React project, or even when I join a new codebase, one of the first things I like to do is analyze whether the application uses layout primitives.<br>If they’re not in place, I make it a point to introduce concepts like <strong>Stack</strong>, <strong>Box</strong>, or <strong>Grid</strong>, which significantly simplify layout management.</p><p>Why Are Layout Primitives Essential?<br>In design systems, each component is designed in isolation without necessarily considering its context. This creates a challenge:<br>A standalone component might be used in different environments, each requiring unique spacing. Without primitives, this often leads to repetitive styles (e.g., display: flex, margin, gap, etc.) in every parent component or layout.</p><p>Enter the Elegant and Unstoppable &lt;Stack /&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ET07YaftYeuvJ-8a" /><figcaption>Photo by <a href="https://unsplash.com/@holly_buildalifeyoulove?utm_source=medium&amp;utm_medium=referral">Holly Stratton</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A Stack is an abstraction that simplifies arranging child elements by automatically managing spacing. It typically comes in two forms:<br>1️⃣ HStack (Horizontal Stack) for horizontal alignment.<br>2️⃣ VStack (Vertical Stack) for vertical alignment.</p><p>Using properties like gap, you can easily control the spacing between children without repeating code.</p><p>Stack Component Example :<br>Whether you’re using styled-components or TailwindCSS, encapsulating these behaviors in an abstraction like Stack makes your code more intuitive and reusable:</p><pre>&lt;HStack gap=&quot;10px&quot;&gt;<br>  &lt;Icon /&gt;<br>  &lt;VStack gap=&quot;5px&quot;&gt;<br>    &lt;Text&gt;First Name&lt;/Text&gt;<br>    &lt;Text&gt;Last Name&lt;/Text&gt;<br>  &lt;/VStack&gt;<br>&lt;/HStack&gt;</pre><p>Advantages:<br>✅ Reduced Repetition: No more rewriting rules like display: flex or flex-direction: column every time.<br>✅ Improved Readability: The code clearly expresses intent through component names.<br>✅ Consistency: A single source of truth for spacing and structure.</p><p>Regardless of the library or methodology (CSS-in-JS, TailwindCSS, Sass), adopting primitives like Stack enhances your project’s maintainability and scalability.<br>This approach not only simplifies developers’ work but also ensures a consistent user experience.</p><p>👉 I recommend checking out this book that dives into layout primitives. -&gt; <a href="https://every-layout.dev/layouts/">https://every-layout.dev/layouts/</a><br>👉 And you? What are your favorite layout primitives? 💬 Share in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65d80cb9e547" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>