Tailwind CSS can not configure correctly placeholder

Gegob

I'm replacing all the CSS to use just tailwind CSS. I was looking on his page that they have an inputs with a transition but I need to add an icon on the inner left side. I was changing the colors and the position of the placeholder because otherwise the icon and the text were colliding. But if I change the position of the placeholder when it is focused the top line goes too much at the right side. I was looking every before/after of the code but I didn't get the expected results.

<div class="relative mb-6 flex items-center">
    <input class="peer h-full px-3 py-2 pl-8 rounded-[7px] border border-blue-gray-200
        border-t-transparent bg-transparent text-sm font-normal
        text-blue-gray-700 outline outline-0 transition-all placeholder-shown:border
        placeholder-shown:border-blue-gray-200 placeholder-shown:border-t-blue-gray-200
        focus:border-2 focus:border-blue-500 focus:border-t-transparent focus:outline-0 disabled:border-0 disabled:bg-blue-gray-50"
           placeholder=" " />
    <label class="before:content[''] after:content[' '] pointer-events-none absolute
        left-0 -top-1.5 flex h-full w-full select-none text-[11px] font-normal leading-tight
        text-blue-gray-400 transition-all before:pointer-events-none before:mt-[6.5px]
        before:mr-1 before:box-border before:block before:h-1.5 before:w-2.5 before:rounded-tl-md
        before:border-t before:border-l before:border-blue-gray-200 before:transition-all
        after:pointer-events-none after:mt-[6.5px] after:ml-1 after:box-border after:block
        after:h-1.5 after:w-2.5 after:flex-grow after:rounded-tr-md after:border-t after:border-r
        after:border-blue-gray-200 after:transition-all peer-placeholder-shown:text-sm
        peer-placeholder-shown:leading-[3.75] peer-placeholder-shown:text-blue-gray-500
        eer-placeholder-shown:before:border-transparent peer-placeholder-shown:after:border-transparent
        peer-focus:text-[11px] peer-focus:leading-tight peer-focus:text-blue-500 peer-focus:before:border-t-2
        peer-focus:before:border-l-2 peer-focus:before:border-blue-500 peer-focus:after:border-t-2
        peer-focus:after:border-r-2 peer-focus:after:border-blue-500 peer-disabled:text-transparent
        peer-disabled:before:border-transparent peer-disabled:after:border-transparent
        peer-disabled:peer-placeholder-shown:text-blue-gray-500">
        Input With Icon
    </label>
    <i class="fas fa-heart absolute left-4 mb-0 mt-auto"></i>
</div>

Focus input correct

Correctly focus expected.

Expected placeholder

Correctly expected placeholder.

If I move directly the placeholder

So I need to know which part of the code I need to configure to just move the placeholder but the focus I wanted to be the same as the original.

Placeholder not correctly placed

Actual placeholder.

Tailwind Input

Wongjn

Increase the width of the <label>'s before pseudo element when the placeholder of the <input> is shown:

<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<div class="relative mb-6 flex items-center">
    <input class="peer h-full px-3 py-2 pl-8 rounded-[7px] border border-blue-gray-200
        border-t-transparent bg-transparent text-sm font-normal
        text-blue-gray-700 outline outline-0 transition-all placeholder-shown:border
        placeholder-shown:border-blue-gray-200 placeholder-shown:border-t-blue-gray-200
        focus:border-2 focus:border-blue-500 focus:border-t-transparent focus:outline-0 disabled:border-0 disabled:bg-blue-gray-50"
           placeholder=" " />
    <label class="before:content[''] after:content[' '] pointer-events-none absolute
        left-0 -top-1.5 flex h-full w-full select-none text-[11px] font-normal leading-tight
        text-blue-gray-400 transition-all before:pointer-events-none before:mt-[6.5px]
        before:mr-1 before:box-border before:block before:h-1.5 before:w-2.5 before:rounded-tl-md
        before:border-t before:border-l before:border-blue-gray-200 before:transition-all
        after:pointer-events-none after:mt-[6.5px] after:ml-1 after:box-border after:block
        after:h-1.5 after:w-2.5 after:flex-grow after:rounded-tr-md after:border-t after:border-r
        after:border-blue-gray-200 after:transition-all peer-placeholder-shown:text-sm
        peer-placeholder-shown:leading-[3.75] peer-placeholder-shown:text-blue-gray-500
        eer-placeholder-shown:before:border-transparent peer-placeholder-shown:after:border-transparent
        peer-focus:text-[11px] peer-focus:leading-tight peer-focus:text-blue-500 peer-focus:before:border-t-2
        peer-focus:before:border-l-2 peer-focus:before:border-blue-500 peer-focus:after:border-t-2
        peer-focus:after:border-r-2 peer-focus:after:border-blue-500 peer-disabled:text-transparent
        peer-disabled:before:border-transparent peer-disabled:after:border-transparent
        peer-disabled:peer-placeholder-shown:text-blue-gray-500
        peer-placeholder-shown:before:w-8 peer-focus:before:w-2.5
      ">
        Input With Icon
    </label>
    <i class="fas fa-heart absolute left-4 mb-0 mt-auto"></i>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to make only placeholder italics in tailwind css?

Tailwind CSS Dynamic State Updates But Not Rendered Correctly

Css can´t find tailwind

How to configure Rollup and PostCSS to bundle LESS and CSS (Tailwind)

How to use Tailwind CSS in React to configure Create React App?

Can I style the SurveyJs forms with tailwind css?

How can we deal with layers in Tailwind CSS

How can I configure my joinfaces correctly?

how can i customize container width in tailwind-css?

Why can't I pass variable as a className to tailwind-css?

How can image view through the hollow text in tailwind css

Tailwind CSS can't align icon and text to center on button

How can I change the underline color in tailwind css

How can I align image horizontally in tailwind-css

Tailwind CSS - Can't center search bar inside a div

Can't make space in between hamburger - Tailwind CSS

Can't center absolute position (Tailwind.css)

can I use top and calc within Tailwind CSS 3.0

How can I center an image inside a table using Tailwind CSS?

Can use both Tailwind css and Bootstrap 4 at the same time?

How can I space out elements in a navbar with Tailwind CSS?

How can I stabilize floating labels in React using Tailwind CSS?

Vue.js 3 and Tailwind CSS: Dynamic width not rendering correctly in RatingBar component

Tailwind, animate input placeholder to become a label?

Use Sveltekit and Tailwind CSS

Transition duration with tailwind css

Aligning Content in Tailwind CSS

Circle with text in Tailwind css

Breadcrumb and ellipsis with Tailwind CSS