What is the best way to create a circular upload button design on a website using either bootstrap, React, or materialUI?

Here is the desired appearance:

Click here for the image, with a circle indicating where the photo should be uploaded

<div class="container ">
    <div class="row mx-auto">
        <div class="col ">
            <span class="border border-success rounded-circle">
                <button class="btnUpload">
                    <i class="fa fa-upload"></i> Upload
                </button>
            </span>
        </div>
    </div>
</div>

Answer №1

When working with React, it is recommended to use "className" instead of "class". In the case of wanting to add borders to an inline element like a span, consider turning it into a block element by setting its display property to block or using a div element instead. To center a button both vertically and horizontally inside the element, you can utilize flexbox as shown below:

<div
  className="border border-success rounded-circle"
  style={{ width: 100, height: 100, margin: 50 }}
>
  <div className="h-100 d-flex justify-content-center align-items-center">
    <button className="btnUpload">
      <i class="fa fa-upload"></i> Upload
    </button>
  </div>
</div>

Check out this live example on CodeSandbox.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Conceal the bootstrap hamburger icon if there are no navigation items present

I am working on dynamically populating nav-items within a navbar bootstrap component. There are instances where no nav-items are present, and during those times, I would like to hide the hamburger icon in device viewports. I have identified that the class ...

When the button is clicked, a modal will pop up

Looking for help in incorporating JavaScript to create a responsive modal that pops up with lyrics when a button is pressed in a table. Any assistance would be greatly appreciated. Note: Only the code for the table has been provided. Let me know if you&ap ...

Page not found: URL containing a space character could not be displayed

Previously, URLs containing spaces were functioning properly but started causing issues with React Router version 6. Has anyone else experienced this problem and if so, how did you resolve it? The URL is generated dynamically based on data from a JSON fil ...

Retrieve the final result from the onChange function

// In this scenario, we are working with three variables obtained from the text const varArray = ['montant', 'test','date'] // We aim to store the variable name and user input value in an array const [variableValues, setVaria ...

Encountered an issue while executing the next build process

Every time I run npm next build, it throws an error message. Despite my efforts to search for a solution online and installing the "extract-text-webpack-plugin," the issue persists. The error being thrown is as follows: > next build (node:8136) Depre ...

A guide on integrating the MUI Timepicker with the newest 6 version using Formik

I am currently experimenting with the MUI React Timepicker component and facing an issue during integration with Formik for validation. The problem lies in the inability to bind values properly in the initialValues of the form. const [initialValues, setI ...

The nonexistence of the ID is paradoxical, even though it is present

I've been working on a school project that involves a dropdown box with the id "idSelect." However, I'm encountering an issue where it says that idSelect is not defined when I try to assign the value of the dropdown box to a variable. Even after ...

Changing the class of a div with Selenium using Python

I need to update the layout of a webpage from grid list to simple list, but the challenge is that there is no dropdown or button. Instead, I need to add an active class to the div element. How can I accomplish this using Selenium in Python? <a href=&q ...

Centering an unordered list and ensuring the image is responsive across different screen sizes are both top priorities for this design

Currently, I am working on an HTML project through freecode academy and encountering some obstacles. My goal is to center align the unordered list and make sure that the image responds well to various screen sizes. Please feel free to leave comments with ...

I'm puzzled, can anyone provide clarification on the concept of xml?

Recently, Sheshank S. provided me with a solution to my question, but I failed to grasp its meaning. Can someone please explain it to me? Despite looking through various tutorials on websites and videos, none of them have been able to clarify what this cod ...

What is the best way to adjust the border radius of a TextField component in Material-UI React?

I've been attempting to customize the border radius of a TextField in MUI without any success. The current borderRadius is set to 4px, and I'm trying to change it to 0px. Here is the code I've been using: <TextField id="time&q ...

Why is the div still displaying with the same id and class even after postback in a partial view using MVC?

Encountering a issue where the partial view is repeating after post back, despite the functionality working correctly. Here is the code snippet from the View: @using (Ajax.BeginForm("MarkDefiniteDischargePatient", "PDDD",new { }, new Aja ...

Is there a different method to position an element in the center of the webpage?

Typically, the code margin:auto is used for centering, but I have a different code below. HTML : <article> <header></header> </article> CSS: article{ max-width: 500px; margin: auto; /* centered - nice */ } header{ width: ...

An HTML table featuring rows of input boxes that collapse when the default value is not filled in

My table is populated with dynamic rows of input boxes, some of which may have a default value while others return an empty string ''. This causes the table to collapse on those inputs. <tr *ngFor="let d of displayData"> < ...

Tips for utilizing ion view within an ionic 2 application

In my original use of Ionic 1, I placed the footer after the <ion-content> and before . However, in the new Ionic 2, I can't seem to find any reference to <ion-view>. My specific need is to have two buttons at the bottom of the screen fol ...

How to Style Your ASP.NET Website: Utilizing a Stylesheet with Visual Studio 2010

I am having trouble adding a stylesheet to the master page of my asp.net web form. I want to create an inline navigation menu at the top of the page, but I can't seem to get it working. I have created the stylesheet in the same way I would for an HTML ...

Showing changes in state in real-time using ReactJS: A quick guide

Hello, I am currently facing an issue while trying to add a comment and display it immediately on the DOM. Whenever I type any word in the form box, it does not appear in the box. Additionally, pressing the enter key does not trigger a POST request. Could ...

Embedding a countdown timer in basic HTML code

Attempting to embed the following into an HTML website: The issue I am facing is that when I run it, the timer does not appear. However, when I run it in fsFiddle, I do see the countdown timer. What could be causing this problem? <!DOCTYPE html> & ...

Obtaining a string union value dynamically during execution

Question 1: Exploring a component library, material-ui, which offers interfaces and types for customizing the css class values of each component. For the Select component, they define a type as a combination of string literals type SelectClassKey = " ...

Guide on properly specifying mapDispatchToProps in a component's props interface

In my project, I have a connected component utilizing mapStateToProps and mapDispatchToProps along with the connect HOC from react-redux. My goal is to create concise and future-proof type definitions for this component. When it comes to defining types fo ...