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

Having trouble sending data to my server using a POST request with Axios

Below is the React code I've written for form submission: const handleSubmit = (e) => { e.preventDefault(); console.log('item:', item); Axios.post('http://<MY_SERVER>/item/add', {name:item}) .then(resp ...

Utilizing Bootstrap to allow for seamless text wrapping around a text input field

I am trying to implement a "fill-in-the-blank" feature using Bootstrap, where users need to enter a missing word to complete a sentence. Is there a way to align the text input horizontally and have the rest of the sentence wrap around it? This is my curr ...

Show small information box when hovering over custom toggle button

I have developed a unique custom toggle switch feature When I hover my mouse over the switch, it should display a tooltip message as YES if the switch is in the ON position and NO if it's in the OFF position. Is there a way to implement this functio ...

Is there a tidier method for coding this JSX?

Is there a way to optimize these function calls for both onGoClick and onNoGoClicked within the SomeForm component? Or is it fine to keep them as they are? <SomeForm onGoClick={() => { cleanupHere(props) }} o ...

Retrieve the appended element's object

I am currently facing an issue with accessing elements that are automatically added by a library in my code. In my HTML, I have the following line: <div class="bonds" id="original" style="display:block;"></div> The library appends some elemen ...

The disappearance of the overlay background due to modal reload in NextJS dynamic routing

I am working on a simple NextJS app where clicking on a page opens a modal with updated URL but without triggering a new navigation. The content inside the modal is displayed, while the actual page location is reflected in the URL and refresh takes the use ...

Navigating through _middleware on Next.js to inspect cookies

I am facing an issue with using _middleware in Next.js. I am trying to retrieve the JWT token and verify it within that _middleware. Here is my code snippet: import {NextResponse} from "next/server"; import {verify} from "jsonwebtoken"; ...

Is there a way to create a fixed container aligned to the right and have the parent container handle scrolling?

My setup is as follows: Full width, 100px height header The header is always visible at the top. Full width, remaining height details The content of details can scroll vertically and horizontally. A fixed 200px width, full height container is right- ...

In the event that a different filter is modified using useEffect, the page should be reset back

I am utilizing react functional components and encountering an issue with calling data from an API with available filters and pagination. Whenever I change a filter type, the pagination needs to reset back to the first page. const pageChange = (page) => ...

How can I implement a scroll bar in Angular?

I am facing an issue with my dialog box where the expansion panel on the left side of the column is causing Item 3 to go missing or appear underneath the left column when I expand the last header. I am looking for a solution to add a scroll bar so that it ...

How can I transfer a selected value from a unique dropdown component to react-hook-form?

I am utilizing react-hook-form for form validation in this Gatsby project. However, my dropdown component is not a <select> tag but a customized component created with divs and an unordered list. This design choice was made to meet our specific custo ...

It seems like the Next.js middleware.ts file is running twice, which may also be causing the app to render twice

After investigating the middleware, we discovered that it is executing functions twice, including the application itself. To troubleshoot this issue, I removed the "favicon" from a matcher in the resources where middleware is used because there were talks ...

React Native app experiences a start-up crash caused by SoLoader problem

I'm encountering a problem with my Android app (iOS is working fine). Every time I build it, the application closes before launching. I've tried various solutions found on Github and here, but haven't been able to resolve it yet. The instal ...

What is the recommended method for removing CSS classes in the Sencha ExtJS framework during a component event? (Those pesky red lines)

Occasionally, an aggravating red line will appear unpredictably when adjusting the size of this component using its split bar located at the top edge of the component. I managed to find a way to permanently eliminate the red line by removing its CSS class ...

Blurry font rendering occurs when an element is scaled using CSS

I want to add a scale animation to a bootstrap button, but the text appears blurry. I've tried all the solutions mentioned here. How can I resolve this issue? Below is the code snippet (text is slightly less blurry in the snippet compared to my pr ...

The lower div is overlapping the upper div in a smaller viewport

I have integrated some dashboard widgets in iframes and I want to ensure they are responsive. My goal is for each widget to occupy full width when the screen size is reduced, but appear side by side when the browser window is large (md+): iframe { b ...

What are the steps to utilizing an npm package that simply encapsulates my JavaScript code?

Our current npm package is designed for clients working on ES6-based projects, such as React. The main index file of the package looks like this: export function ourFunction() { } Clients import this function using the following syntax: import { ourFunc ...

Issue: Next.js project encountered error #321 during deployment on Vercel platform

Encountered Minified React error #321. Visit the provided link for the detailed message or utilize the non-minified dev environment to view full errors and additional warnings. at S (/vercel/path0/node_modules/react/cjs/react.production.min.js:18:327) ...

Using Jquery to toggle a class on click, and dynamically change based on the screen size

I am trying to figure out how to toggle a CSS class on an element by clicking on a div using jQuery. I know how to do it, but I also want the toggle to only happen when the screen size is less than 800px. I'm not very familiar with JavaScript, so I co ...

In React Native, utilize a placeholder image when the item's image is undefined

Currently, I am using FlatList to display multiple Images on the screen. My requirement is to show a placeholder Image when item.img is null (the items are pulled from react-redux). Challenges: I am looking to implement a placeholder image using &apos ...