What are some ways to decrease the dimensions of my dateTimePicker?

I'm looking to decrease the dimensions of my datetime picker box. Here's an image of my current dateTimePicker: https://i.stack.imgur.com/MeJlq.png

Below is the component I'm using:

import React, { useState } from 'react';
import momentLocaliser from 'react-widgets-moment';
import DateTime from 'react-datetime';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import 'react-datetime/css/react-datetime.css';

const moment = require('moment');

moment.locale('es');
momentLocaliser(moment);

const DateTimePickerInput = ({
    label,
    format,
    input,
    width,
    placeholder,
    selected,
    tooltip,
    tooltipPlacement,
    disabled,
    defaultValue,
    value,
    onChange,
    inputProps,
    meta: { valid, touched, error },
    showTime,
    style,
    ...props
}) => {
    const classes = classNames('form-group', {
        'has-error': (touched && !valid),
        'has-success': (touched && !valid)
    })
    return (
        <div className={classes}>
            <label htmlFor={input.name}>{label}</label> <br />
            <DateTime
                name={input.name}
                locale='es'
                dateFormat="DD-MM-YYYY"
                timeFormat="HH:mm:ss"
                onChange={param => {
                    input.onChange(param)
                }}
                inputProps={{placeholder: !input.value ? 'Please, select a date': moment(input.value).format('DD-MM-YYYY HH:mm:ss')}}
                style={{}}

                {( !valid && touched) &&
                    <p className='help-block'>{error}</p>
                }
            </div>
       );
 };

  

Here is the stylesheet that I am importing from my DateTimePicker widget:

/*!
     https://github.com/YouCanBookMe/react-datetime
 */

.rdt {
    position: relative;
}

.rdtPicker {
    display: none;
    position: absolute;
    width: 250px;
    padding: 4px;
    margin-top: 1px;
    z-index: 99999 !important;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
    border: 1px solid #f9f9f9;
}

.rdtOpen .rdtPicker {
    display: block;
}
...

The width of the date time picker box is larger than expected. How can I adjust the width of the box to make it smaller?

Answer №1

To modify the CSS properties of react-datetime, consider the following adjustments:

.rdtPicker {
  width: 400px; //Adjust to your desired width
}

.rdtPicker tr {
  height: 50px; //Specify the row height for overall height modification
}

You can view a functional demonstration on this CodePen link.

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

Adjust the size of the image within a designated container to decrease its proportions when there is an excess of text present

I am working on a project where I need to resize an image based on the available space within its container. When there is text in the description, the image should adjust its size accordingly without pushing the text upwards. I am using React for this pro ...

I'm having trouble getting the footer to stay at the bottom of my website

Struggling with positioning my footer at the bottom of my website, I've tried various solutions posted by others but they don't seem to work for me. I've experimented with different methods like using 'Bottom: 0;' or placing my fo ...

"Having trouble with the React Material UI CardMedia video component? It seems to

Is there a way to have the video autoplay and repeat on this website? I can see the thumbnail, but no buttons to start or stop it. Click here for more information <CardMedia component="video" image='/video.mp4' title='title&apo ...

Error caused by touch in JSX email field

There is a minor bug that doesn't impact the functionality, but it's present and bothersome. Within my react.js application, I have a signup form. Below is a simplified version: import { useState } from "react" import {signupApi} from ...

Enhance your user interface by adding a tooltip above a button

I am currently working on creating a button that can copy content from a variable into the clipboard using TypeScript and Material-UI. Here is what I have tried: const [copySuccess, setCopySuccess] = useState(''); const copyToClipBoard = async ( ...

Define the width of jqgrid

I have been utilizing SmartAdmin jqgrid to showcase data in tabular format. The number of columns in the datatable changes dynamically each time. I am converting the DataTable to a JSON object and assigning it to the jqgrid. However, it appears that jqgrid ...

How can I personalize the color of a Material UI button?

Having trouble changing button colors in Material UI (v1). Is there a way to adjust the theme to mimic Bootstrap, allowing me to simply use "btn-danger" for red, "btn-success" for green...? I attempted using a custom className, but it's not function ...

Subcomponent in React is not rendering as expected

I have a primary React component with a subcomponent named AttributeInput. To prevent redundancy in my code, I moved some of the logic from the main component to a method within AttributeInput. My attempt at referencing this code looks like this: {this.s ...

Contrasting Firefox Experience on Mac and Windows

I'm experiencing some issues with a website that is displaying differently in Firefox on Windows compared to Mac. I did some research online to see if there are any known differences in CSS rendering between the two versions of Firefox, but it doesn&a ...

Updating the page dynamically in React/Redux by making API calls based on user submissions

My current task involves calling an API with Redux, triggering the call based on a form submission. If the query is empty, it should return all lists; otherwise, it should only return lists that match the query. // List.tsx import React, { useEffect, useS ...

Adjust the alignment of two headers with varying sizes

Can someone provide guidance on aligning two headers of different sizes (e.g. h3 and h5) based on their bottom edges, making them appear like a cohesive group in a sentence format? The current code snippet I am working with is as follows: ...

Combining Moralis and Vite for seamless integration with React

Struggling to integrate Moralis into my React Vite application by following the guidance provided in the Moralis documentation. However, after completing the installation process, I keep encountering an error Here is a snippet from my main.jsx file: impor ...

Encountering an Uncaught TypeError due to failure to read the property 'bool' of an undefined value

Encountering a runtime error in my code that I can't seem to pinpoint. Everything was functioning correctly before this error surfaced after updating npm. Here's the error message: Uncaught TypeError: Cannot read property 'bool' of und ...

"The authentication cookie fields are not defined when trying to get the authentication in the Express framework

After setting up my React client on port 3000 and Express on port 5000, I encountered an issue. When logging in, the cookie fields are set without any problems. However, when trying to retrieve the isauth value, it shows as undefined. //login log message ...

Is utilizing React's useEffect hook along with creating your own asynchronous function to fetch data the best approach

After attempting to craft a function for retrieving data from the server, I successfully made it work. However, I am uncertain if this is the correct approach. I utilized a function component to fetch data, incorporating useState, useEffect, and Async/Awa ...

The reason the CSS direct descendant selector does not affect Angular components

We are working with a basic main.html. <app> <sidebar></sidebar> <main-content> <router-outlet></router-outlet> </main-content> </app> After loading a component through routing (changing the ...

The final thumbnail fails to appear in the visible display (react-responsive-carousel)

I am currently facing an issue with displaying a series of images using react-responsive-carousel. When the images exceed a certain size causing the thumbnail section to become scrollable, the last thumbnail is always out of view. Although I have impleme ...

Rearranging the @use directive in Sass

Here are some style snippets: tokens.scss .text-center { text-align:center; } .bold { font-weight: bold; } @mixin text-style-1 { font-size: 1.2rem; font-weight: bold; } component/card.scss @use "../token.scss" as tokens; .card { @i ...

Creating Certificates for Finished Courses within the Certificate Course Management Platform (CCMP) constructed on the PERN technology stack

This question holds significant importance for me as I am gearing up for a project presentation at my university scheduled for April 16th. My current project involves the development of a Certificate Course Management System (CCMS) using the PERN stack (P ...

Guide on using react-highlight-words to emphasize various keywords using different color schemes

I am currently working on implementing a search feature for my React project. At the moment, I am only required to enter a single keyword and search for it within the text. Once found, I need to extract and display the sentences containing this keyword sep ...