How to customize a React datepicker by adding a dot underneath the current date with CSS

I am looking to enhance the appearance of today's date in a datepicker by adding a small circle or filled dot below the number. For example, if today is the 1st of March, I want a dot to appear just below the number 1 on the datepicker.

Initially, I tried to achieve this effect using CSS styling, like so:

  transform: translateX(-50%);
  border-radius: 100%;
  position: absolute;
  background: blue;
  bottom: 2px;
  height: 2px;
  content: '';
  width: 2px;
  left: 50%;

However, when I added this code where indicated in my existing codebase, it caused distortion and movement of the date numbers within the datepicker. Or, the blue circles appeared on top of the numbers, with the numbers themselves ending up at the bottom of their respective cells instead of their usual positions.

.DayPicker-Week {
        border-bottom: none;
        cursor: default;

        .DayPicker-Day {
            text-styles('normal');
            border-right: none;
            cursor: default;
            height: 32px;
            padding: spacing-NEW(0.5);
            width: 32px;

            &--disabled {
                color: red
            }

            .DayPicker-Day-NEW{
                display: table-cell;
                height: inherit;
                vertical-align: middle;
                width: inherit;
            }


            &--today:not(.DayPicker-Day--disabled):not(.DayPicker-Day--selected):not(.DayPicker-Day--outside) .DayPicker-Day-NEW {
                // IF TODAYS DATE
                // ADD A DOT BELOW TODAYS DAY NUMBER
            }
        }
}

Answer №1

        &:before{
            transform: translateY(-50%);
            border-radius: 50%;
            position: absolute;
            background: rgb(144, 106, 111);
            content: '';
            height: 10px;
            width: 10px;
            right: 50%;

            top: 40%;

        }

This solution worked perfectly for me! Make sure to adjust the parent component's positioning to relative.

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 causes the fading effect on my navigation bar when the slideshow is in use?

I recently created a navigation bar at the top of my webpage, placed above a picture slideshow. However, I noticed that as the slideshow transitions between images, the background color of the navigation bar fades to transparent. How can I prevent this and ...

Creating a Form Layout with Bootstrap - Organizing Text Boxes and Text Areas

https://i.sstatic.net/oqRwR.jpg In the image above, I need to adjust the position of the textbox to align it with the TextArea. Is there a Bootstrap class that can help me achieve this? My current version of Bootstrap is 3.3.6. HTML &l ...

Border Effect Resembling Windows Tiles

When you hover your mouse over a tile in Windows, a cool effect happens: Hovering outside the tile, but within the container area: https://i.sstatic.net/yZk9f.png Hovering inside a tile: https://i.sstatic.net/LoSmk.png Hovering outside a tile at its m ...

What is the best way to create a shape using CSS?

In my chat application, I have a functionality where replies on a chat are initially hidden and represented by a count in a red box. When the user clicks on the red button, the replies from other users are revealed along with an input box for writing a r ...

Is it possible to place a div and a heading side by side within the same line?

Is there a way to align a div and header on the same line? Currently, the red div is displaying below the text. Thank you for your help! .underlined { border-bottom: 1px dotted #000; text-decoration:none; } .block { height:15px; background-color: #ff505 ...

The gap between columns in Bootstrap grids

Currently, I am dynamically fetching "boxes" and adding them to the HTML document using ngFor. The number of boxes is unknown in advance. Here is the code I am currently using: <div *ngIf="items && items.length" class="row"&g ...

Changing the text color using jQuery is proving to be difficult for me

I've been trying to apply a styling condition using an if statement in my jQuery code based on the result from an API, but for some reason, I'm not seeing the color change. I have given an ID to try and change the color through CSS. $.getJSON(API ...

Dynamic Material UI TextField underline width using JSX in React

I recently encountered an issue while trying to add padding to my TextField component. I applied the padding to the root 'style' property, but it caused the underline to overflow beyond the designated area to the right by the same amount as the p ...

Utilizing the power of CSS' calc() function in ReactJS using react-motion's <Motion/>

I'm currently attempting to utilize calc() within a template string for the following scenario: <Motion defaultStyle={{ y: 0, opacity: 1 }} style={{ y: spring(this.state.navBarOpen ? 0 : `- calc(3.25em + 0.5vw)`), opacity: sp ...

Ways to locate CSS file path within a web browser

Currently, I am focusing on the theme development aspect of Magento2. After compiling the .less file, I noticed that two css files are generated: styles-l.css styles-m.css Despite trying to inspect the element and view the applied CSS in the browser, i ...

Full-Width Bootstrap Sticky Containerized

I am trying to create a sticky sidebar that fills the full width of the container in Bootstrap 4. I have written the code below, and while the sticky functionality works perfectly, the sidebar does not span the full width of the container. Can someone pl ...

Setting a constant width for text characters across all devices using CSS and HTML

I am looking to display text in my textarea with the same width in pixels across all devices. Essentially, I want to set the character width in pixels so that it appears consistently on any device (Desktop/Mobile). <html> <head> <styl ...

Vanish and reappear: Javascript block that disappears when clicked and shows up somewhere else

My goal is to make three squares randomly disappear when clicked on the page. However, I am facing an issue where some of them, usually the 2nd or 3rd one, reappear elsewhere on the page after being clicked. I have created a jsfiddle to demonstrate this: ...

Chrome introduces surprise spacing to text input fields styled uniquely

This particular code snippet is functioning correctly on Firefox, but unfortunately not on Chrome. The height of the input should match the styling of the select, but there seems to be a discrepancy in Chrome. Any ideas on how to rectify this? Upon closer ...

Issues with ordering directives in Bootstrap 4 are preventing proper functionality on various mobile platforms and devices

When I resize the browser window to mobile width, the order column directive in the code snippet above works fine. However, when I test it on a mobile emulator or an actual mobile device, the order columns do not function properly. This issue seems to be r ...

Display the text above overlapping div elements

I need a design where one div overlaps another, but the text inside the overlapping div must still be visible. <div class='box1'> <div class='sendAbove'> This message should remain visible in this div </div> ...

Using Clojure Hiccup for crafting stylish information in a unique manner

I want to create CSS style using hiccup by specifying the "top" and "left" variables to position an element. Currently, my code looks like this: (html [:div {:style (str "top" top ";left" left)} "some text"]) The code above is not very clean. It ...

Pictures in Windows 7 have shifted to the left

After a recent migration to the Windows 7 operating system at my company, I encountered an issue. While using the same Visual Studio 2010 master file that was working fine on my Windows XP machine, I noticed that all the images below were now shifted to t ...

No JavaScript needed: Create custom overflow/scroll indicators using CSS only

Is there a way to align the content of a box to the left when the box doesn't overflow? I have a scroll indicator created with CSS only, which works well but has this alignment issue. Any suggestions or improvements on the code are welcome :) html ...

Is it possible to create a single code that can be used for various buttons that perform the same function?

Whenever I click the right button, the left button appears and when I reach the last page, the right button disappears. However, this behavior is affecting both sections. Is there a way to write separate code for each section? I managed to make it work by ...