Transitioning the CSS transform on a dynamic button title in a React component when the state changes

I have incorporated a unique Button Component in my React project that transforms on hover using a scale value. I am utilizing this button twice.

The first instance contains only dynamic content without an onClick property:

<Button className={`${classes.btn} ${classes["main-btn"]}`}>
              {isLoginMode
                ? "Login"
                : isRegisterMode
                ? "Register"
                : "Reset Password"}
            </Button>

The second instance involves an onClick event to modify some state:

<Button
          properties={{
            onClick: () => {
              setAuthMode(
                isLoginMode ? AuthModes.register : AuthModes.login
              );
            },
          }}
          className={`${classes.btn} ${classes["alt-btn"]`}
        >
          {isLoginMode ? "Register" : "Login"}
        </Button>

While the desktop version works smoothly, there seems to be a delay in updating the text of the second button on Safari mobile. This issue arises due to the transition property, which functioned properly once removed.

Here's the CSS snippet:

Within this component:

.btn {
  width: 100%;
  padding: 0.7rem 0.9rem;
  transition: transform 1s ease;
}

In the Custom Button Component:

.btn {
  outline: none;
  border: none;
  padding: 0.8rem 1.2rem;
  background-color: var(--secondary-color);
  border-radius: var(--radius-low);
  color: white;
  font-weight: bold;
}

.btn:hover {
  transform: scale(1.02);
}

Answer №1

To possibly assist you, please consider this solution: Resolve CSS Transition Issue in Safari

input {
  font-size: 15px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  box-shadow: none;
  outline: none;
  transition-duration:0.4s;
  -webkit-transition-duration:0.4s;
  -ms-transition-duration:0.4s;
  -moz-transition-duration:0.4s;
  visibility:visible !important;
}
input:focus {
  font-size: 30px;
}
<input type="text" placeholder="hello" value="hello" />

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

Utilizing mobile emulators to optimize the viewport for mobile application development

Are mobile emulators like MITE() able to detect viewport settings? <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> Can anyone recommend a mobile emulator that does recognize viewport settin ...

I am constantly receiving a barrage of API requests by utilizing SWR and Axios within my Next.js application

My experience with SWR is a bit confusing as it is my first time using it. I may have made a mistake in my implementation because after setting up the SWR wrapper, I noticed that the API call to the same endpoint was being made repeatedly and endlessly. Th ...

Issue with HTML/CSS: rectangle doesn't scroll as expected

I'm in the process of developing a new website and I want to include a top bar and footer with some unique elements on it. Additionally, I am looking to create a rectangular area where I can input text. After writing the following code snippet, this ...

Creating an image that scales to full width within a Bootstrap column after switching to mobile view

I am having trouble getting the image on the right to expand to full width when the screen size is reduced, transitioning it to mobile view. Is there a Bootstrap class that works similarly to "img-fluid", but displays the image in full width below the text ...

Link with an embedded background image

When I click on the 'law firms' image in my project, instead of displaying a short HTML page with text as intended, it shows a '>' character. I have three circular images on my jsFiddle, and when hovered over, a background shadow ima ...

How to design input elements for adding new rows in Material Table

Looking to expand the width of a drop-down list labeled "Birth Place" within the Materialtable component in ReactJS. https://i.sstatic.net/SM77u.png I am aiming for a design similar to the image attached, but I am unsure where to apply the CSS code &apos ...

Text situated under a stylish Css bar

I want to create a bar chart to display the number of surveys that are completed, not started, and not available. The bars should also show the actual numbers below them, similar to this example https://i.sstatic.net/8miIs.png Currently, I have the fol ...

Caution: Function declared within the loop contains risky references to variable(s) no-loop-func in a forEach loop

Within my React project, there exists a straightforward .js file containing the code snippet below: let oldInfo function getChanges() { const newInfo = {}; let keys = ["name", "age", "sex"]; oldInfo = "one&q ...

What is the best way to ensure that style changes are applied only to content within a modal window

Objective: I am seeking a way to confine the impact of a specific style sheet to a modal without altering the underlying page with minimal adjustments, ideally none. For instance: <html> <head> <link rel="stylesheet" href="/css/theme1 ...

Should the height of a flex item be defined or should it automatically adjust based on its content?

My issue lies within a flex column container containing two elements with the respective classes of .one and .two nested inside: .container { display: flex; flex-direction: column; } .one { height: 50vh; background: blue; } .two { height: 50 ...

Arranging Items in Grid Items with MaterialUI

When using MaterialUI, what is the most effective way to position an image inside a <Grid item>? Instead of putting a div in the grid item and applying flexbox properties, there should be a simpler solution that aligns with the Grid system's pu ...

Align a series of items in HTML to the center side by side

Currently, I am in the process of creating a personalized homepage that features multiple lists of links placed next to each other. However, I'm facing a dilemma on how to center all of them while still maintaining the desired format. If you'd li ...

Enhance the vertical size of IcoFont

This code snippet includes CSS for styling a navbar, as well as HTML and Angular directives for creating navigation elements. If you're looking to center the <li> tags within the <nav> elements and increase the size of their IcoFont icons ...

What is the best way to horizontally align a form input in MatBlazor?

How can I align the form inputs in the center of this image? The GridLayout I am using is defined here: and the form elements are defined here: https://i.sstatic.net/OlC7D.png This is my code attempt but it seems like something is missing: <div class ...

Focus on selecting a div nested within a separate component

I have encountered an issue with an imported component that has multiple nested divs which I am unable to modify. Deep within these divs, I need to apply a bottom margin. While using Chrome DevTools, I managed to add the desired margin to one of the div ...

The text consistently remains positioned to the right of my image

Photo Gallery Title Issue I'm working on a photo gallery project where I want to add titles underneath each image. However, I'm facing a problem where the title is appearing next to the image instead of below it. You can see the issue in this sc ...

Tips for styling React Material-UI list items with fontAwesome icons and Tailwind.css

I would like to align the text of my list items to the left. Additionally, I want all the icons to be the same size as the envelope icon used in Gmail list item. Currently, my code looks like this: https://i.stack.imgur.com/9LNOs.png How can I achieve th ...

The primary objective of utilizing margin

Just embarked on my journey to mastering HTML and CSS. Regarding the 'margin' property: Does its primary function revolve around centering elements horizontally on a webpage? I've crafted a navigation menu for a website, yet I struggle to ...

Activating setState in another component within the same level

As I work on creating a ToDo list, I have an input field in a child component and the array state stored in the parent. To enable re-rendering of the list based on completion status with a click, I am thinking of moving the array to its sibling component, ...

Responsive menu is failing to respond to the click event

I'm facing an issue with my responsive menu on mobile phones. It should display two buttons - one for the navigation bar and the other to toggle the side bar by removing the classes hidden-xs and hidden-sm. However, I am having trouble getting the btn ...