<?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>DEV Community: Muhammad Omer Baig</title>
    <description>The latest articles on DEV Community by Muhammad Omer Baig (@iomerbaig).</description>
    <link>https://dev.to/iomerbaig</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%2F1704751%2F572c4ae1-7530-4eac-9985-c1d8cdf5f5fd.png</url>
      <title>DEV Community: Muhammad Omer Baig</title>
      <link>https://dev.to/iomerbaig</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iomerbaig"/>
    <language>en</language>
    <item>
      <title>React + Tailwind Design Issue: Dynamic Arrow Alignment Outside Buttons</title>
      <dc:creator>Muhammad Omer Baig</dc:creator>
      <pubDate>Sat, 29 Jun 2024 19:40:32 +0000</pubDate>
      <link>https://dev.to/iomerbaig/react-tailwind-design-issue-dynamic-arrow-alignment-outside-buttons-3nhm</link>
      <guid>https://dev.to/iomerbaig/react-tailwind-design-issue-dynamic-arrow-alignment-outside-buttons-3nhm</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe95svmgfu43ff3vtyf9j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe95svmgfu43ff3vtyf9j.png" alt="current design - red box highlights the alignment issue" width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo68075ndl2uma9nswd1p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo68075ndl2uma9nswd1p.png" alt="desired design" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm working on a React project using Tailwind CSS. My buttons feature arrows (&amp;lt;-) positioned outside, aligned towards the center of the button's right border with some space between them. Currently:&lt;/p&gt;

&lt;p&gt;Buttons with shorter text display arrows correctly. Longer text causes arrows to misalign, disrupting the design. Design Flow:&lt;/p&gt;

&lt;p&gt;Arrows (&amp;lt;-) are positioned outside each button. They should align dynamically to the center of the right border of the button, maintaining a consistent visual distance.&lt;/p&gt;

&lt;p&gt;Challenge: How can I adjust arrow alignment dynamically in React with Tailwind CSS, ensuring they stay centered along the right edge of buttons regardless of text length? I need to preserve the space between buttons and arrows as part of the design.&lt;/p&gt;

&lt;p&gt;Here’s the relevant code for button component and arrow alignment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import DiscoveryButton from '../DiscoveryButton/DiscoveryButton';

const RightSection = ({ responses, activeResponse, handleButtonClick }) =&amp;gt; {
  return (
    &amp;lt;div className="grid grid-cols-[80%_20%] relative"&amp;gt;
    {/* Button Grid */}
    &amp;lt;div className="grid grid-cols-1 items-start  space-y-4"&amp;gt;
      {responses.map((response, index) =&amp;gt; (
        &amp;lt;DiscoveryButton
          key={index}
          index={index}
          active={activeResponse === index}
          onClick={handleButtonClick}
        /&amp;gt;
      ))}
    &amp;lt;/div&amp;gt;

    {/* Navigation Arrows */}
    &amp;lt;div className="grid grid-cols-1 mt-2 pl-2  justify-center relative"&amp;gt;
      {responses.map((response, index) =&amp;gt; (
        // VERTICAL LINE HERE
        &amp;lt;div
          key={index}
          className="relative w-full pt-[--pt] bg-[image:linear-gradient(#000,#000),linear-gradient(#000,#000)] bg-[position:0_calc((theme(fontSize.base.1.lineHeight)*.5)-1px+var(--pt)),100%_var(--y,0%)] bg-[length:100%_2px,2px_var(--h,100%)] bg-no-repeat [--pt:theme(padding.4)] first:[--pt:0%] first:[--y:calc(theme(fontSize.base.1.lineHeight)*.5)] last:[--h:calc((theme(fontSize.base.1.lineHeight)*.5)+var(--pt))]"
        &amp;gt;
          {/* Poistioning of Arrow head */}
          &amp;lt;svg
            className="translate-y-[calc((theme(fontSize.base.1.lineHeight)-24px)*.75)]"
            width="16.8"
            height="24"
            viewBox="0 0 16.8 24"
            fill="none"
          &amp;gt;
            {/* ARROW HEAD HERE */}
            &amp;lt;path
              d="M0 12l12 12 1.4-1.4L4.2 12 13.4 3.4 10 0l-12 12z"
              fill="currentColor"
            /&amp;gt;
          &amp;lt;/svg&amp;gt;
          {/* for the line passing through the 3rd arrow */}
          {index === 2 &amp;amp;&amp;amp; (
            &amp;lt;div class="absolute left-full top-[--pt] h-[2px] bg-black w-5 mt-[11px]" /&amp;gt;
          )}
        &amp;lt;/div&amp;gt;
      ))}
    &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default RightSection;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// DiscoveryButton.jsx

import React from 'react';
import { buttonNames } from './buttonNames';

const DiscoveryButton = ({ index, active, onClick }) =&amp;gt; {
  return (
    &amp;lt;button
      onClick={() =&amp;gt; onClick(index)}
      className={`px-4 py-2.5 text-lg  text-right ${active ? 'bg-theme-blue text-white rounded-lg ' : 'bg-transparent text-black'}`}
    &amp;gt;
      {buttonNames[index]}
    &amp;lt;/button&amp;gt;
  );
};

export default DiscoveryButton;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from 'react';
import Heading from '../Heading/Heading';
import LeftSection from './sections/LeftSection';
import CenterSection from './sections/CenterSection';
import RightSection from './sections/RightSection';
import { responses } from './discoveryResponses'; // Adjust path as necessary
import { buttonNames } from './DiscoveryButton/buttonNames';
import { theme } from '../../theme';

const DiscoveryResponse = () =&amp;gt; {
  const [activeResponse, setActiveResponse] = useState(0);

  const handleButtonClick = (index) =&amp;gt; {
    setActiveResponse(index);
  };

  return (
    &amp;lt;section className={`${theme.padding.mobileVertical} ${theme.padding.mobileHorizontal} ${theme.padding.mediumHorizontal}`}&amp;gt;


      &amp;lt;div className="text-center pt-4 pb-8"&amp;gt;
        &amp;lt;Heading
          title="Discovery Response Generator (Discovery Workflow)"
          titleFirst={true}
          boldText="(Discovery Workflow)"
          titleFontSize='text-40px'
        /&amp;gt;
      &amp;lt;/div&amp;gt;

      {/* Parent Grid Container */}
      &amp;lt;div className="grid grid-cols-1 md:grid-cols-[30%_35%_35%] py-10 gap-10"&amp;gt;

        {/* Left Section (Image Display) */}
        &amp;lt;LeftSection imageSrc={responses[activeResponse].image} /&amp;gt;

        {/* Center Section (Text Display) */}
        &amp;lt;CenterSection
          buttonName={buttonNames[activeResponse]}
          responseText={responses[activeResponse].text}
        /&amp;gt;

        {/* Right Section (Button Grid and Navigation Arrows) */}
        &amp;lt;RightSection
          responses={responses}
          activeResponse={activeResponse}
          handleButtonClick={handleButtonClick}
        /&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/section&amp;gt;
  );
};

export default DiscoveryResponse;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
