Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make a styled circle component using tailwindcss?

I am working on image upload component in my react app and I design the image uploader component.

Here is the code and the result respectively.

<div className="px-8 py-6 mt-2 text-left bg-white shadow-lg">
        <form action="">
          <div class="flex  items-center justify-center bg-grey-lighter">
            <label class=" flex flex-col items-center px-4 py-6 bg-white text-blue rounded-lg shadow-lg tracking-wide uppercase border border-blue cursor-pointer hover:bg-blue hover:text-white">
              <AddAPhotoIcon />
              <span class="mt-2 text-base leading-normal">Upload Photo</span>
              <input type="file" class="hidden" />
            </label>
          </div>
        </form>
      </div>

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But I want change it exactly as the following component.

enter image description here

>Solution :

Make sure you have the same width and height for the element you want circular, in combination with rounded-full.

I adapted your example and used h-40 and w-40 to control height and width. With rounded-full, the result is a circular component.

<div class="flex items-center justify-center">
  <form action="">
    <label class="text-blue border-blue hover:bg-blue flex h-40 w-40 cursor-pointer flex-col items-center justify-center rounded-full border bg-white uppercase tracking-wide shadow-lg hover:text-white">
      <AddAPhotoIcon />
      <span class="mt-2 text-base leading-normal">Upload Photo</span>
      <input type="file" class="hidden" />
    </label>
  </form>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading