I can't figure out why my CSS transition isn't functioning properly in React 18

I've attempted multiple times to implement a transition on eventBody, but it still isn't functioning correctly.

Here's the snippet of code:

export function Event({ event }: EventProps) {
  const [showDropDown, setShowDropDown] = useState(false)

  return (
      <div className={styles.eventBody} hidden={!showDropDown}>
        <div className={styles.line}></div>
        <AttendeeList upcoming={true} attenders={attenders}></AttendeeList>
     </div>
  )
}

CSS:

.eventBody {
  transition: all 0.4s ease-out;
}

.eventBody[hidden='true'] {
  display: none;
}

I tried triggering setShowDropDown after 100ms delay upon every click on the header div, and also experimented with using height in the transition instead of all, but unfortunately, both methods were unsuccessful.

Answer №1

The css selector you provided is incorrect. It's important to note that display is not considered an animatable property.

.eventBody {
  transition: all 0.4s ease-out;
  height: 300px;
  position: relative;
  overflow: hidden;
}

.eventBody[hidden] {
  height: 0;
}

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

What is the process for including CSS in the .ashx.cs code-behind file in ASP.NET?

How can I insert a css class in the .ashx file while the .aspx UI page displays it as a string? What is the method to include css in the code behind of the .ashx page? I would like the text "Cook" to be displayed in red. Problem: https://i.sstatic.net ...

Why isn't the z-index functioning properly in Vue.js styling?

I am currently developing a simple component that displays four steps, indicating the current step and allowing users to navigate through them. I want to create a design where these numbers are enclosed within circles that are evenly distributed in a line ...

Issues with Firefox's flexbox functionality are preventing it from working

Hey there, I've created a bubble menu with a button using code. It functions perfectly on Chrome but seems to have some issues on Mozilla Firefox. You can check it out and give it a try. $(".roundedBallOuter").click(function(e) { $(this).toggleCl ...

Every time I try to install @mui/icons-material, I keep encountering the same error message

npm ERROR! Unable to access the 'pickAlgorithm' property of null npm ERROR! For more details, check the complete log at: C:\Users\User\AppData\Local\npm-cache_logs\2021-11-02T04_49_26_513Z-debug.log ...

The module was not found due to an error stating: "Unable to locate 'DavidDaDon.png'"

Feeling a bit lost with my code here. I have the PNG files in my src folder, used require and relative paths to access them, but something seems off. What's causing the issue? I'm working on a birthday reminder countdown featuring my closest frie ...

Displaying the active item in a list of items using material-ui Drawer

In order to highlight the selected item in my drawer, I have the following code snippet: <Link to ="/#" style={{textDecoration:'none'}}> <ListItem button selected={selectedIndex === 0} onClick={(event) => handleListItemC ...

How to utilize datepicker in react-redux to compare dates

Incorporating the DateInput component into my Redux form has been quite a challenge: const MyDatePicker = ({ input, meta: { touched, error } }) => ( <div> <DatePicker {...input} dateFormat="DD-MM-YYYY" selected={input.value ? ...

What seems to be the issue at hand? Could I be making a mistake? Are there alternative methods to approach this situation?

I've encountered an error with my code, which is displayed in the attached picture. Can anyone help me identify the issue? The goal of my code is to show a message if the passcode length entered in the TextInput is less than 10 characters. Once the le ...

NextJS with GraphQL resulted in an increase in the number of hooks rendered compared to the previous render

Trying to streamline my project by adding the navbar to _app.js instead of every component. The issue arises after logging in, with an error message Rendered more hooks than during the previous render. specifically pointing at useQuery(GETCARTDATA) Would ...

Eliminate the standard border line from a div element

While working on creating shapes in React using CSS, I encountered an irritating issue with a ring design that I'm attempting to create. I can't seem to get rid of the default border around the circle shape I've created. I've tried usin ...

Utilizing Bootstrap framework to create a user-friendly navigation bar with dropdown functionality for a seamlessly organized and visually appealing full

Looking to utilize bootstrap for creating a top navigation layout and encountering an issue with the default left alignment. How can I make it span the full width at the top? Current https://jsfiddle.net/v2notb5n/ <nav class="navbar"> < ...

Unlimited header height with automatic vertical overflow for content on the rest of the page

My page has a header with content that can wrap, so it doesn't have a fixed height. I want the rest of the page to be filled by the content container and activate vertical scroll when there is too much content in the container. I've tried various ...

Due to a glitch in the firebase cloud function, the payment is not going through

I have developed a react-redux application with Firestore as the database and now I want to integrate Firebase Cloud Functions to handle Stripe payments. Here is how it's set up: Below is the action method for checkout, which processes token and amo ...

Color each row in PrimeVue DataTable based on the value of a specific column item

Recently, I came across a PrimeVue DataTable with a specific structure: <DataTable value="info"> <Column header="Name" field="name" /> <Column header="Desc." field="desc" /> <Colu ...

Having trouble aligning material-ui GridList in the center

I am currently working with a GridList in order to display Cards. The styling for these components is set up as shown below: card.js const useStyles = makeStyles({ card: { maxWidth: 240, margin: 10 }, media: { heigh ...

Tips for aligning objects within a bootstrap column so that they all have the same starting point on the X axis

To recreate the issue I am facing, I created a basic HTML structure with 2 bootstrap columns. My aim is to have multiple <p> elements in the second column, stacked one below the other. However, the problem arises when these <p> tags contain tex ...

I prefer to disable the toggle feature if the target remains unchanged

My goal is to create a step-by-step ordering system using the data-id="x" attribute to determine which content should be visible when selected. I want to make sure that if two elements have the same data-id, clicking on one will deselect the other. Any su ...

Bootstrap version 5 has a feature where the dropdown menu extends beyond the right side of the screen

I'm facing an issue with the default bootstrap 5 navbar. When I attempt to add a dropdown on the right side, the list of dropdown items extends beyond the screen on the right. You can see the problem here. I've tried the solutions suggested in s ...

Can you provide guidance on how to prioritize container div style over CSS class?

Here's the HTML code snippet I'm working with: <html> <head> <style> .text-box { color: red; } </style> </head> <body> <p class=&qu ...

The Enigmatic Gap Amidst Flex Elements

I have a situation where two divs are placed within a flex container. However, the second div is incorrectly aligning to the right side of the page rather than next to the first div. Despite the default values for flex-flow being row and justify-content b ...