How I can change color of input selected in react-date-range package?

8.2k views Asked by At

I Cant custom with css background color of focusing input selected in this date picker pack

4

There are 4 answers

3
Przeblysk On BEST ANSWER

This is the demo code of react-daterange-picker in codesandbox, you can easily find the corresponding style information Screenshots

0
AlanHusjy On

An example of my component DateRange, change only property rangeColors={['#f33e5b', '#3ecf8e', '#fed14c']}

you need to pass the three values ​​in the array

<DateRange
          editableDateInputs={true}
          onChange={item => setDate([item.selection])}
          moveRangeOnFirstSelection={false}
          ranges={date}
          className={styles.date}
          locale={locales[locale]}
          date={date}
          endDatePlaceholder="Continuo"
          rangeColors={['#f33e5b', '#3ecf8e', '#fed14c']}
        />
      </div>
2
stasdes On

you should copy Styles @wojtekmaj/react-daterange-picker/dist/DateRangePicker.css and react-calendar/dist/Calendar.css to your project.

use the no style option like this:

import { useState } from 'react';
import DateRangePicker from '@wojtekmaj/react-daterange-picker/dist/entry.nostyle';

import './App.css';
import './Calendar.css';
import './DateRangePicker.css';

function App() {
  const [value, onChange] = useState([new Date(), new Date()]);

  return (
    <div>
      <DateRangePicker
        onChange={onChange}
        value={value}
      />
    </div>
  );
}

export default App;

and add to DateRangePicker.css:


.react-daterange-picker__inputGroup__input:focus {
  background: red;
}

enter image description here

0
tyler_flx On

If you only want to change the primary selected range color

And have no luck using their color prop for DateRange

Try this:

rangeColors={["#5569ff"]} //put your color here

Here is an example:

<DateRange
  editableDateInputs={true}
  onChange={item => setDatesSelect([item.selection])}
  moveRangeOnFirstSelection={false}
  ranges={datesSelect}
  rangeColors={["#5569ff"]} //put your color here
/>