How to Implement Dotted Line Styling for Row Data in ReactJS with CSS?

I'm working on a condensed design with Reactjs

Monday......................08:00 AM - 21:00 PM

I have a lot of dots in the display above. How can I make it shorter without using so many dots? Entering numerous dots like this is not ideal for the website.

Do you have any suggestions or ideas to help me out?

Answer №1

To achieve this effect in CSS, you can utilize dotted borders. Below is an example where the Flex layout is used. Adjust the positioning of the dots as needed, as specified in the CSS code comments.

const App = () => {
  return (
    <React.Fragment>
      <div className="dotted-data-container">
        <div className="dotted-data-key">Monday</div>
        <div className="dotted-data-separator"></div>
        <div className="dotted-data-value">08:00 AM - 21:00 PM</div>
      </div>
      <div className="dotted-data-container">
        <div className="dotted-data-key">Saturday</div>
        <div className="dotted-data-separator"></div>
        <div className="dotted-data-value">08:00 AM - 21:00 PM</div>
      </div>
    </React.Fragment>
  );
}

ReactDOM.render(<App/>, document.getElementById("root"));
.dotted-data-container {
    display: flex;
}

.dotted-data-separator {
    flex: 1;
    border-bottom: 2px dotted; /* adjust style accordingly */
    position: relative;
    top: -2px; /* reposition if necessary */
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.0/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.0/umd/react-dom.production.min.js"></script>
<div id="root"></div>

Answer №2

Here is the solution.

[...Array(dotCount)].map(()=> "•").join("")

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

React, redux, and redux observable are all essential tools for developing web applications. They

I am currently working on determining the type of a promise's resolve function. Here is a snippet of the code, or you can find it on GitHub: https://github.com/Electra-project/Electra-Desktop/blob/master/src/app/header/epics.ts export function getSt ...

Adjust the size of the startIcon / endIcon in Material-UI

I'm currently working on a Material-UI theme and I need to use our own custom set of SVG icons. However, I'm facing an issue where the icons become too small when placed in a button using startIcon or endIcon. Is there a way to enlarge the icon s ...

Ways to split images and text in list items using CSS

Can the text be formatted in a specific location on the page, separate from the image and heading? This is the HTML code I am currently using: <div class="tab-pane container fade" id="environmental"> <div class="row"> <div class="c ...

What is the best way to extract the value from a Material UI Slider for utilization?

I am looking to capture the value of the slider's onDragStop event and store it as a const so that I can use it in various parts of my code. However, I am unsure about how to properly declare my const sliderValue and update it. Any guidance on where a ...

Top Margin: Supported by Chrome and Safari

After troubleshooting why the margin-top is not working on Safari, but works fine on Chrome, I discovered a discrepancy. Chrome Upon hovering over an item in the image, the cursor changes as expected. This feature operates smoothly in Chrome. https://i. ...

Creating a custom CSS clip to apply a rounded path on an image

I have been experimenting with applying a "clip path" to an image using a rounded path. While I am aware that SVG clip paths are an option, I found them to be less responsive. As an alternative, I attempted to place the SVG graphic under the image within a ...

What is the reason for PeerJs altering a MediaStream before transmitting it to another person?

I am currently developing a video chat application using Next.js 14, Express, socket.io, and peerjs One issue I am encountering is that when I send a stream, the user receives a modified version of it. This occurs specifically when I enter a room with my ...

Updating the class of a div based on a checkbox being checked or unchecked

I am attempting to apply the "isChecked" class to the parent div when a checkbox is checked, using the ngClass directive. Here is the HTML: <div ng-class="{isChecked: (isChecked_1 == 'true')}"> <input type="checkbox" id="check_ ...

Oops! Unable to extract the 'devices' property from the unspecified value because it is not defined

I wrote a function in my page.txs file to fetch a JSON response and incorporate it into a Next 13 app page. const getDevices = async () => { try { const res = await fetch('/api/getdevice',{ cache: 'no-store' }) ...

Executing a mutation upon mounting using React Apollo 2.1's Mutation component: A Step-by-Step Guide

Currently transitioning from Relay to React Apollo 2.1, and I've encountered a questionable situation. Situation: Certain components should only be displayed if the user is authenticated with an API key. To handle this, there's an Authenticator ...

Switch image formats to webp using react js

Utilizing the react-dropzone package, I aim to incorporate images into my application. To achieve this, I must send the images to a firebase server after managing image conversions. Whilst browsing through YouTube tutorials, I came across a guide demonstr ...

The class is failing to be applied to the parent div that holds an id starting with the letter x

I have been attempting to assign a class to the parent container when the child element has the 'hidden' class. If not, then a different class should be added. function tagMissions() { if ($('span[id^="mission_participant_new"]').h ...

What sets srcset apart from media queries?

Can you explain the contrast between srcset and media query? In your opinion, which is more optimal and what scenarios are ideal for each? Appreciate it! ...

What is the best way to override @include within a CSS class?

Our team's application utilizes Bootstrap SASS for styling, but we have made certain customizations to the framework. The Bootstrap files are included in our project through a build process, making direct modifications impossible. When it comes to dr ...

Tips for personalizing your Magento 2 theme

As someone new to Magento 2 and front-end development with a basic knowledge of HTML and CSS, I am eager to customize the blank theme in Magento 2 to gain a deeper understanding of how things work. However, despite reading through the documentation, I am u ...

Upon installation of Next.js, an error in the globals.css file quickly emerged, yet remarkably, it did not disrupt the code in

Here is the link to the repository: here. Once I created the next.js environment using the command "npx create-next-app@latest ./" and ran "npm run dev", I encountered the following error message:- ../../../#React Projects/My projects/causs/styles/global. ...

Attempting to highlight a specific list item by using the CSS current class to emphasize its active state

I've been experimenting with different solutions I found in previous questions, but unfortunately, none of them have worked for me. I suspect the issue lies in the fact that the element is deeply nested within CSS classes, and my lack of experience is ...

Error: The variable "Set" cannot be found in the react.js code, specifically in Safari browser

An issue has been identified in Safari where a ReferenceError is thrown: "Can't find variable: Set" when using react.js. This error occurs only in Safari, while all other browsers work perfectly fine. The error message points to the main.js file which ...

What happens when you try to access the property 'blur' of something that is undefined?

Example of using ref in Material-UI TextField: <TextField label="Select " value={this.state.type} inputRef={this.selectCar} type="text" /> The selectCar function is set in the constructor as follows: this.selectCar = React.createRef(); When t ...

I am looking to implement custom styles to a navigation bar element upon clicking it

When I attempted to use useState(false), it ended up applying the styles to all the other elements in the navbar. import React, { useState } from 'react'; import { AiOutlineMenu } from 'react-icons/ai'; import { Navbar, NavContainer, Na ...