Generating tags dynamically with a function

Is there a way to showcase dynamic tags with proper line breaks in CSS? The responsive container needs to break gracefully:

CSS:

.tags {
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    background-color: white;
    padding-left: 0.5em;
    padding-right: 0.5em;
    padding-top: 0.25em;
    padding-bottom: 0.25em;
    margin: 0.5em;
}

This is the desired display:

mapTags = tagArray => {
  return tagArray.map((item, i) => <span key={i} className={styles.tags}>
  {item}</span>);
};

Can you lend me a hand with this issue?

Additionally, what's the solution for dealing with tags that have spaces like "This is a tag"? How can I maintain my borders effectively?

Answer №1

<span> is recognized as an inline element. Consider utilizing <div> instead. If it becomes essential to utilize span, experiment with implementing the display: block property. However, this method should not be considered ideal, even if it produces the desired outcome.

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

When the page is refreshed, the react-stomp-hooks useStompClient hook is reset to undefined

Incorporating the react-stomp-hooks library, I have implemented a websocket stomp connection to my backend within a function component where I define const stompClient = useStompClient(). Upon initial rendering of the page, everything functions as expected ...

Dividing points in half at the top and bottom edges in a chart using chartjs

https://i.sstatic.net/AfosF.png Upon observation of the provided image, it can be seen that the points are halved when they reach the top or bottom edges, specifically when the data points are 1 or 5 in this context. Various attempts were made to address ...

Update the delivery status of an Uber Eats order using the Uber Eats API

Hey there, I hope everyone is doing well. I need to update the delivery status of orders on Uber Eats through my app. I am in partnership with Uber Eats and using the Update Delivery Status API for this purpose. The API requires the scope eats.store.order ...

Creating an array based on specific conditions being satisfied (Using Javascript)

I am struggling with a coding problem involving adding users to groups. The goal is to add each user to a group array, with a maximum of 3 users per group. If a group reaches 3 users, it should be moved to another array that collects all the groups. I then ...

Switching the vertical alignment of grid items in Material UI when the page is collapsed

When the page is collapsed, the Left grid item element moves to the top of the page and the Right grid element is positioned below it. I would like to reverse this behavior so that the Right element appears on top and the Left element below when the page ...

Vue should only activate the element that has been clicked on

I'm currently working on my first Vue project and encountering an issue with triggering a child component within a table cell. Whenever I double click a cell, the `updated` event is being triggered in all child components associated with the table cel ...

What is the correct way to denote a CSS class in SASS syntax?

Can you show me how to code this in SASS? .solo:hover > .solo-pane, .solo-pane.active, .solo-pane.lighten { opacity: 0.5; } I'm having trouble separating the classes using commas. ...

How to detect a right-click on empty time slots in Fullcalendar agenda views

I am working with a calendar feature on my web application using Adam Shaw's fullcalendar 2.1.1 JS library. I have successfully set up right-click responses for events and days by binding the "mousedown" event in the dayRender and eventRender callback ...

Is it possible that attaching the click event directly to the ID is effective while attaching it to the childnode is not working

Can anyone help me with a problem I'm having? When I try to target a specific element by accessing its child nodes, the click event doesn't work. However, if I use getElementById and then attach the click event through that method, it works. Idea ...

What could be causing the issue of opacity and list reordering not functioning properly in react-dnd and react-virtualization?

I'm currently setting up a react-dnd sortable list within a react-virtualized List. I've been referencing an example from react-dnd which can be found here. Most of it is working as expected, but I'm encountering an issue where the items I ...

The functionality of the MVC jQuery grid is currently malfunctioning

Recently, I attempted to integrate a jQuery grid plugin from gijgo.com into my MVC application. Following the instructions provided on c-sharpcorner and/or codeproject meticulously, however, upon running the application, I encountered a troubling JavaScrip ...

The server gets blocked by numerous AJAX GET requests happening at the same time until the data gets returned

In my Rails application, I am using the gridList library to display charts. The chart data is fetched asynchronously from a controller method in JSON format via AJAX. Upon initial page load, each gridlist item displays a loading icon while simultaneously m ...

Capturing deprecated Material UI alerts

At our company, we have a central shared material UI theme that different teams incorporate into their codebases. Although we make an effort to keep up with the latest versions, sometimes the central repository lags behind when there are significant chang ...

When attempting to showcase an MUI icon that was imported, I encounter the following issues: Invalid hook call and the <ForwardRef(SvgIcon)> component

Encountering issues while trying to display an imported MUI icon leads to the following errors: Error: https://i.stack.imgur.com/USdEx.png Sample Code: import React from 'react' import ThreeDRotation from '@mui/icons-material/ThreeDRotati ...

Error encountered while creating SvelteKit: The module 'intl-messageformat' that was requested is in CommonJS format

Encountering an error during production build. Here's the output of npm run build executed on Node v16.20.1 npm run build > <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c7a6c6a317a757278796e5c2c322c322d">[email&# ...

Is it true that the react setState function does not function properly with stream data?

I'm currently utilizing PouchDB to synchronize my remote database with my local database. The following code is integrated within the componentDidMount lifecycle method: const that = this var localDB = new PouchDB('localdb') var remoteDB = ...

Customize the width of a DataTable cell in VuetifyJS

I am currently utilizing the VuetifyJS Data Table and I'm looking for a way to reduce the spacing between the entries in each header cell. Adding a width to each header did not achieve the desired result, as it seems there is a minimum predefined widt ...

Sending dynamic information to bootstrap's modal using props in VueJS

I'm currently working on a personal project and encountering an issue with the bootstrap modal. My project involves a list of projects, each one contained within a card element. The problem arises when I attempt to display details for each project by ...

Footer remains fixed and scrolls into the body when the window is resized

Having trouble with the footer's responsiveness when resizing the desktop window. It looks fine in developer tools, but in different browsers, the footer placement gets messed up and scrolls over the rest of the content. Any insights on what might be ...

Sending an ajax request to submit the results of jQuery.each loop

$(".submitinfo").each(function() { // Using ID as POST name and value as POST value }); // Sending the data using ajax request $.ajax({ url: 'submit.php', traditional: true, data: { 'submit':'true', 'age&a ...