React-day-picker: Styles are not loaded

Created on 24 Sep 2017  路  7Comments  路  Source: gpbl/react-day-picker

This seems like a really good alternative to react-datepicker cos it provides custom styling. However, a simple setup following the documentation does not work. The styles do not load. I'm using it with redux-form; the styling is just broken. Anyone else having this issue?

Most helpful comment

So when I added <link rel="stylesheet" href="https://unpkg.com/react-day-picker/lib/style.css"> in the <head> tag, it worked. Not sure what's happening.

All 7 comments

Have you read this first? http://react-day-picker.js.org/docs/styling.html
If there鈥檚 something not clear, I鈥檒l be happy to help!

Yes I read that. The documentation is very clear actually but my implementation does not work.

import React, { Component } from 'react'
import DayPickerInput from 'react-day-picker/DayPickerInput'

import 'react-day-picker/lib/style.css'

class DateTextField extends Component {
  renderField ({ label }) {
    return (
      <div>
        <span>{label}</span>
        <DayPickerInput />
      </div>
    )
  }
  render () {
    const { name, label } = this.props

    return (
      <Field name={name} component={this.renderField} label={label} />
    )
  }
}

export default DateTextField

Any ideas?

So when I added <link rel="stylesheet" href="https://unpkg.com/react-day-picker/lib/style.css"> in the <head> tag, it worked. Not sure what's happening.

@adred I think there's a problem in the way you import CSS from JavaScript:

import 'react-day-picker/lib/style.css'

Are you sure that the CSS is actually imported? E.g. using css-loader and included it in your final CSS file?

i am also facing the same issue

@shivam16parashar any luck, facing same issue

I just met the same problem.
And the solution below is work for me.
or your calendar component name.
import "./Calendar.sass";

or your calendar component style name.
import the style.css form node_modules.
@import "../../../../../node_modules/react-day-picker/lib/style";

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brpontes picture brpontes  路  6Comments

jgatjens picture jgatjens  路  5Comments

samsch picture samsch  路  6Comments

davidjbradshaw picture davidjbradshaw  路  3Comments

mcapodici picture mcapodici  路  3Comments