Reacting to the dynamic removal of spaces

Is there a way to dynamically remove the space between removed chips and older chips in Material-UI when deleting one of them?

                        <div className="row contactsContainer">
                            {contacts.map((contact) => (
                                <div className="col-lg-1 col-md-3 col-sm-4 col-xs-6 my-5">
                                    <Chip
                                    id={contact!.phone}
                                    label="delete"
                                    variant="outlined"
                                    color="primary"
                                    deleteIcon={
                                        <HighlightOffOutlinedIcon id={`del-${contact!.phone}`} />
                                    }
                                    onDelete={handeldelete}
                                    avatar={
                                        <Avatar
                                            alt={`${contact ? contact.phone : ""}`}
                                            src={lady}
                                            className={`li-avatar ${contact ? "" : "d-none"}`}
                                            title={contact?.phone}
                                        />
                                    }
                                    />
                                </div>
                            ))}
                            <div className="col-lg-1 col-md-3 col-sm-4 col-xs-6 my-5 ">
                            {/* <Chip
                                    id="addContact"
                                    label="delete"
                                    avatar={
                                        <Avatar
                                            alt="add contact"
                                            src={add_image}
                                            className={`li-avatar`}
                                            title="Add New Contact"
                                        />
                                    }
                                    /> */}
                                    <div>
                                <a onClick={handleClickOpen}>
                                    <img src={add_image} alt="add_image" className="circle_image" />
                                </a> 
                                </div>
                            </div>
                        </div>

Any suggestions on how to achieve this? Can I accomplish this using Material-UI instead of Bootstrap as shown in this example?

Answer №1

I am confident that the solution will work as expected. Could you kindly provide the code for the function used to eliminate the Chip? My understanding is that removing the item should also remove any associated spaces. Perhaps a more detailed explanation of your issue would help clarify things?

Check out this demonstration using material-ui to see how chips can be removed from an array:

Explore the chip removal 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

Generating a PDF file from an HTML and CSS page can be done without relying on APIs or libraries, by leveraging the

Is there a way to directly convert an HTML page generated using PHP and CSS into a PDF format without the use of libraries? I have come across multiple libraries that can accomplish this task, but I would prefer not to rely on any external libraries and i ...

Easily process payments through PayPal using React

As a newcomer to the world of react web apps, I am in the process of creating a cart payment checkout system. However, all the modules I have tried so far for the PayPal button open in a pop-up window within the same page. What I really want is to be able ...

The inline-block property can become unstable when dealing with a large number

When I create a parent container div with three child divs and set the display property to inline-block, everything looks great on jsfiddle CSS #container { border: 1px solid blue; padding: 2px; display: inline-block; } .child { width: ...

What is the process of playing blob videos (avi, mov) in Angular14?

I've been struggling with this issue for quite some time without knowing how to resolve it. After some research, I came across a similar question: how to play blob video in angular. However, the problem is that the demo provided in the answer does no ...

What if there was a magical jQuery method that could automatically trigger a callback function? What could it possibly be named?

Is there a way to load only images and iframes, similar to the .load() function? I want to automatically add a selector element into the "this" variable for this purpose. $('document').ready(function({ $('a').<Something to trigg ...

What is the most effective method for sending Firestore data to React components?

Having trouble efficiently setting a user's profile and passing that data to other components? Below, I've shared my current approach, but the rendering process is not as smooth. Every time I interact with different parts of the app, the data fro ...

The innerHTML of the p tag remains unaffected when using document.getElementsById("")

HTML {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'lessons/style.css' %}" /> <script> function openNav() { document.getElementById("mySidenav").style.width = "20%"; document.getElementById("main" ...

Find the height of the viewport using jQuery, subtracting (n) pixels

Apologies if the topic seems puzzling, I couldn't find a better way to explain it. I utilized jQuery to adjust the height of a div to match the size of the viewport. var slidevh = function() { var bheight = $(window).height(); $(".container" ...

Ensuring React Canvas dimensions match parent div in Konva Package - a practical guide

Placing a div in A4 format within a fixed div with a height of 500px and dynamic width, allowing scrollability, poses a challenge when inserting a Stage using the Konva library inside the A4 div. The issue arises from the stage only accepting numeric value ...

Maintaining the aspect ratio of images in Bootstrap Carousel: A complete guide

Using the default carousel from Bootstrap template has been working well for me. However, I've encountered an issue where resizing the browser window distorts the image aspect ratio by squishing it horizontally. I've tried various solutions to m ...

Reveal and conceal using CSS animations

I am working on adding animation effects to show and hide HTML elements triggered by a button click. The button toggles a "hide" class to display or hide the element. Check out my code snippet: const toggleButton = document.querySelector('button ...

React input delay handling during onChange event

Upon closer inspection, I've come across an issue that I had not previously noticed. I am unsure if there is a bug within my code or if the onChange function always behaves in this manner, but I am experiencing input delay and am uncertain on how to r ...

Issue with CSS style on header with hyperlink

My CSS style includes a hyperlink for the "Title" to quickly navigate back to the home page. However, when I insert a table, this hyperlink gets disabled. /* JavaScript */ .header { position: absolute; height: 85px; right: 0; top: 0; left: 0; padding: ...

Transform a collection of interfaces consisting of key-value pairs into a unified mapped type

I have a set of interfaces that describe key-value pairs: interface Foo { key: "fooKeyType", value: "fooValueType", } interface Bar { key: "barKeyType", value: "barValueType", } interface Baz { key: "bazKeyType", value: "bazValue ...

Choose either nth-child or nth-of-type within a nested element

Here is the HTML code snippet: <div class="homepage-body"> <a href="#"> <div class="homepage-item"> <div class="homepage-icon"></div> <div class="homepage-text"> Test1 </di ...

Issue with Nginx setup - Unable to establish connection between three distinct servers (Client, API, Database)

What I am attempting to achieve I am currently working on setting up a connection between three individual servers (Client, API, and mySQL) by creating three VMs locally with the following IP addresses. Below is a simple testing React/Node code for each s ...

How to align an unordered list horizontally in HTML without knowing the number of items

I'm currently developing a web page that needs to display an unknown number of items using the ul/li HTML tag. Here are my requirements: The list should utilize as much horizontal space as possible The list must be horizontally centered, even if lin ...

The display:block-inline feature seems to be malfunctioning

Even though I've specified the width of columns as 25%, the boxes are still not aligning in a single line: ...

The issue with the CSS combination of :after and :hover:after across different HTML elements

Encountering an issue while attempting to create a rollover effect using CSS :after and :hover pseudo-elements. Check out the clock and facebook icons on the right side by visiting: See below for the CSS code: .icon { background: url('. ...

The function signature '({ articles }: Props) => JSX.Element' does not match the type 'NextPage<{}, {}>'

Recently, I've decided to delve into the world of React.js and Next.js after being familiar with Vue.js. Encountering a peculiar typescript error has left me scratching my head, but surprisingly, the code actually compiles despite Visual Studio Code w ...