React-day-picker: Styled Components does not work with DayPickerInput

Created on 25 Oct 2018  路  5Comments  路  Source: gpbl/react-day-picker

Most helpful comment

I can do it with a wrapper, not sure if it's proper way.
https://codesandbox.io/s/7zoy5293v0

All 5 comments

I can do it with a wrapper, not sure if it's proper way.
https://codesandbox.io/s/7zoy5293v0

I did pretty much the same way but with scss. how I did not think this way.
馃憤

To avoid having wrapper, you can pass the right className to classNames prop of DayPickerInput. Check styling-normal-react-components section in styled-components docs.

Updated codesandbox: https://codesandbox.io/s/p3427n1m8j

Update fork because the wrapper does not work with refs, so i add forwardRef:

https://codesandbox.io/s/9lkmj6mlvp?fontsize=14

Hey, you can create a wrapper and replace the existing css, like this:

const WrapperStyled = styled.div`
  &&& {
    .DayPicker,
    .DayPicker-wrapper {
      :focus {
        outline: none;
      }
    }

    .DayPicker-Weekday {
      color: #6adc91;
      font-size: 18px;
      font-family: 'Montserrat-SemiBold';
    }
}
`

const Calendar = () => { return ( <WrapperStyled> <DayPicker {...props} numberOfMonths={2} selectedDays={selectedDays} navbarElement={<Navbar />} captionElement={<Caption />} onDayClick={handleDayClick} /> </WrapperStyled> ) }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kradical picture kradical  路  3Comments

mcapodici picture mcapodici  路  3Comments

laidinidis picture laidinidis  路  6Comments

wenzoto picture wenzoto  路  6Comments

davidjbradshaw picture davidjbradshaw  路  3Comments