<?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 Juan Encalada on Medium]]></title>
        <description><![CDATA[Stories by Juan Encalada on Medium]]></description>
        <link>https://medium.com/@juanencalada?source=rss-71c912af30af------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9b8vnbScgPfKAMM-7Sxkog@2x.jpeg</url>
            <title>Stories by Juan Encalada on Medium</title>
            <link>https://medium.com/@juanencalada?source=rss-71c912af30af------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 10:29:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@juanencalada/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[Creating Adaptive Aspect Ratio Cards for IBM’s Carbon Design System]]></title>
            <link>https://medium.com/@juanencalada/creating-adaptive-aspect-ratio-cards-for-ibms-carbon-design-system-8891f5173981?source=rss-71c912af30af------2</link>
            <guid isPermaLink="false">https://medium.com/p/8891f5173981</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[figma]]></category>
            <dc:creator><![CDATA[Juan Encalada]]></dc:creator>
            <pubDate>Sat, 12 Oct 2024 16:06:21 GMT</pubDate>
            <atom:updated>2024-10-16T13:55:23.604Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="IBM’s aspect ratio grid" src="https://cdn-images-1.medium.com/max/1024/1*4XG3t9hSwtFd3OUU1_5xKA.png" /></figure><p>The <strong>IBM Carbon Design System</strong>, built on the principles of the <strong>IBM Design Language</strong>, is driven by precision and scalability. At the core of this system is the <strong>2x Grid</strong>, which dictates the structure and rhythm of all visual elements. One of the most intriguing components within this system is the <strong>aspect ratio card</strong> — cards that maintain a consistent aspect ratio while flexibly adapting to their content. These cards are vital in ensuring design integrity and visual rhythm across varying layouts, devices, and screen sizes.</p><figure><img alt="Two aspect ratio cards displayed on a grid, demonstrating how the cards maintain their proportions and layout as they scale to different sizes, while preserving content integrity and spacing" src="https://cdn-images-1.medium.com/max/1024/1*PT_nc8C-DmfpVeU9VwLtNQ.png" /><figcaption>Aspect ratio cards maintaining proportions while scaling to different sizes</figcaption></figure><p>I’ve always been fascinated by how aspect ratio cards keep their shape while expanding with the content inside them. This ability to dynamically grow based on content needs is essential for readability and usability. I first set out to solve this in Figma, and later decided to try out the concept in code <strong>for my own learning</strong>.</p><h3>The Goal: A Scalable Solution in Figma</h3><p>The primary objective was to create a scalable aspect ratio card solution in Figma that would grow in height based on its content, but still maintain its defined aspect ratio. I began by listing some requirements to ensure there would be no surprises as I worked toward a solution that might ultimately lead me down a dead-end path. I also defined some stretch goals for what I hoped to achieve in Figma. The first stretch goal—matching card heights in a grid I knew would be a tall order. The second stretch goal—wasn’t really a requirement of the aspect ratio card I was building at the time, but I knew it would be an easy addition for other use cases.</p><p><strong>Primary goals</strong></p><ol><li>Aspect ratio card maintains aspect ratio card when scaled</li><li>Adapt vertically in height if the contents inside the card grow</li><li>Maintain a safe distance between the card contents and decorative elements at the bottom of the card</li><li>Cards grow to match the height of the largest card in the row</li></ol><p><strong>Stretch goals</strong></p><ol><li>Cards grow to match the height of the largest card in the grid</li><li>Aspect ratio can be easily changed to other supported aspect ratios</li></ol><h3><strong>The Problem: Maintaining Aspect Ratios Without Truncation or Overflow</strong></h3><p>Aspect ratio cards are crucial for creating fluid layouts while maintaining visual consistency. The challenge is ensuring the cards are responsive enough to adapt to growing content without causing overflow.</p><p>In code, maintaining aspect ratios while balancing dynamic content is much simpler with technologies like <strong>CSS Grid, Flexbox, and JavaScript.</strong> However, it is still not without its challenges, especially when dealing with cross-browser inconsistencies — looking at you, Safari! In fact, this card behavior already exists in Carbon’s code base and has for some time—it’s the design kits that have never been able to reflect the appropriate responsive behavior.</p><p>In Figma, this problem is particularly tricky because Figma doesn’t natively support aspect ratios, which presents a fundamental challenge to implementing aspect ratio cards. I knew I needed to get creative, but thankfully, I was already highly familiar with the <a href="https://wojtek.im/journal/targeting-safari-with-css-media-query"><strong>aspect ratio component from Vitalii</strong></a> available in the Figma Community. Vitalii’s aspect ratio component quickly became my starting point.</p><p>My first attempt was to <strong>absolute position</strong> the content on top of the aspect ratio component. While this approach maintained the ratio, it didn’t allow the card to grow as the content inside expanded— an essential feature for creating fluid, scalable, and accessible aspect ratio cards.</p><h3><strong>The Figma Approach: Using Negative Space Between</strong></h3><p>After realizing the limitations of my first approach, I experimented with various methods and stumbled upon an underutilized technique in Figma — <strong>negative space between</strong>. By strategically adding negative space between, I discovered that the contents inside the container would overlap, aligning to the top as their limit, allowing the card to expand in height as necessary based on the tallest element inside. This element would of course be the height of the content, or the height of the aspect ratio, based on the aspect ratio’s width.</p><h4>Negative space be-what?</h4><p>That’s right. Negative space between. This challenge led me down a deep path of exploring the ins and outs of Figma’s Auto layout space between property, specifically around what happens as you play with negative values. Here’s a breakdown:</p><ol><li>When you have 2 elements within an Auto layout, the 2nd element cannot overlap the previous element to the point where it’s starting origin surpasses the starting origin of the first element. The first element’s starting origin serves as any subsequent element’s starting limit.</li><li>Similarly, if the second element is smaller than the first element, the second element can only overlap the first element by 100% of its height, with the first element’s ending origin serving as the second element’s limit.</li><li>If the second element grows in height, when it is equal in height to the first element, it perfectly overlaps the element. As the second element grows beyond the size of the first element, it once again cannot overlap past the first element’s starting origin.</li><li>If more than 2 elements, overlap of any element can not exceed the height of the smallest element.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZfL6MzXsPkHaAQYli6-Vg.png" /><figcaption>GIF of various space between values</figcaption></figure><p>This solution was perfect. It preserved the aspect ratio and enabled the content to influence the card’s height without breaking the layout. The flexibility it offered made it versatile enough for a variety of use cases, and I was quite proud of the final outcome.</p><p>Check out the Figma file <a href="https://www.figma.com/community/file/1426939053555812543/aspect-ratio-cards-ibm-carbon-design-system">here</a>.</p><h3><strong>The Code Approach: A Learning Experience</strong></h3><p>Since solving this challenge in Figma, I’ve had the urge to challenge myself and bring this concept to life in code. This behavior already exists in Carbon, but I wanted to do it without looking at any of their code to test my own hypothesis. As someone with a passion for both design and front-end development, I wanted to see how my assumptions played out in a live environment. I built the cards using CSS Grid and Flexbox, and worked out a few kinks to ensure the aspect ratios stayed intact as the content grew. I specifically needed to include an <strong>@supports for Safari.</strong> This CSS is essential for Safari, but breaks the working cards in Chrom and Firefox. Targeting Safari was critical. Thanks for the help <strong>targeting Safari exclusively, </strong><a href="https://wojtek.im/journal/targeting-safari-with-css-media-query"><strong>Wojtek Witkowski</strong></a>.</p><pre>@supports (hanging-punctuation: first) and (font: -apple-system-body) and<br>  (-webkit-appearance: none) {<br>  .card {<br>    min-height: fit-content;<br>    height: calc(100% - 2rem);<br>  }<br>}</pre><h4>Getting the Cards to Be the Same Height Throughout the Grid</h4><p>The HTML and CSS approach alone is great, but doesn’t only equalizes the height of the cards per row. This may be enough for some systems, but for Carbon, it’s essential that the height of all cards in the grid be equalized. I added some JavaScript to ensure the cards in the grid row maintained a consistent height.</p><p>Check out the code <a href="https://codepen.io/juanencalada/pen/PoMbadL">here</a>.</p><h3><strong>Final Thoughts: Bridging Design and Development</strong></h3><p>This project was a great opportunity to blend my skills as both a designer and developer. I love finding creative ways to solve design challenges in Figma and then translating those solutions into code to test their real-world viability. If you’re a designer or developer facing similar challenges, I hope this post provides some inspiration and practical insight.</p><p>Check out the <a href="https://codepen.io/juanencalada/pen/PoMbadL">CodePen here</a> and the <a href="https://www.figma.com/community/file/1426939053555812543/aspect-ratio-cards-ibm-carbon-design-system">Figma file here</a>.</p><p>Happy designing and coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8891f5173981" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>