Styles from .scss file doesn't apply. #1950
-
My code: StyledDatePicker.js import React from 'react'
import {DayPicker} from 'react-day-picker';
import styles from 'react-day-picker/dist/style.module.css';
import newStyles from'./DatePicker.scss';
const StyledDatePicker = (props) => {
const classNames = {...styles, ...newStyles};
console.log('classNames', classNames);
return (
<DayPicker
{...props}
classNames={classNames}
/>
);
}
export default StyledDatePicker; DatePicker.scss @import "react-day-picker/dist/style";
.rdp-day_today:not(.rdp-day_outside) {
color: red;
}
.rdp {
--rdp-cell-size: 120px; /* Size of the day cells. */
--rdp-caption-font-size: 12px; /* Font size for the caption labels. */
--rdp-accent-color: #1ac334; /* Accent color for the background of selected days. */
--rdp-background-color: #1e5f04; /* Background color for the hovered/focused elements. */
--rdp-accent-color-dark: #22cc24; /* Accent color for the background of selected days (to use in dark-mode). */
--rdp-background-color-dark: #180270; /* Background color for the hovered/focused elements (to use in dark-mode). */
--rdp-outline: 2px solid var(--rdp-accent-color); /* Outline border for focused elements */
--rdp-outline-selected: 3px solid var(--rdp-accent-color); /* Outline border for focused _and_ selected elements */
--rdp-selected-color: #fff; /* Color of selected day text */
}
.head { color: blue !important } No one of my new styles isn't working. But default styles of react-day-picker are working good. I noticed that if I change .head { color: ... } in my scss to red for example, it will be applied on the page without reload. If I reload the page, my styles will disappear again. What am I doing wrong? I've already tried all styled-components methods, all css modules, etc. We used Webpack, React, styled-components, MUI, etc. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @is-paranoia! Is there a way to replicate your issue by forking this code-sandbox? https://codesandbox.io/s/react-day-picker-8-vl4ry?file=/src/App.tsx If your styles are not imported, check if your CSS needs a |
Beta Was this translation helpful? Give feedback.
I apologize that I could not provide CodeSandbox. The fact is that the .scss import works fine in it.
I haven’t fully figured it out, but I’ll still leave the solution in our project. Apparently it's all about our frontend configuration
In our project we managed to do this:
We add the default library styles to the DatePicker.scss file. That is, just Crtl+C from lib & Ctrl+V.