2

The problem is I can't find an appropriate way with CSS styling to make the react-day-picker wide enought to fill out all a mobile display.

I've tried to customize the css file provided by react-day-picker and a lot of styles were applied but all of them weren't successfull.


    .DayPicker {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        font-size: 2.5rem;
        margin: 0;
        margin-top: 2rem;
    }

    .DayPicker-wrapper {
        position: relative;
        flex-direction: row;
        user-select: none;
        width: 100%;
    }

    .DayPicker-Months {
        display: flex;
        flex-wrap: wrap;
        flex-direction: column;
    }

    .DayPicker-Month {
        display: table;
        margin: 0;
        margin-top: auto;
        border-spacing: 0;
        border-collapse: collapse;
        user-select: none;
    }

    .DayPicker-NavBar {
        position: relative;
    }

    .DayPicker-NavButton {
        position: absolute;
        top: 1.4rem;
        margin-top: 2px;
        width: 1.25em;
        height: 1.25em;
        background-position: center;
        background-size: 60%;
        background-repeat: no-repeat;
        color: #8B9898;
        cursor: pointer;
        outline: none;
    }

    .DayPicker-NavButton:hover {
        opacity: 0.8;
    }

    .DayPicker-NavButton--prev {
        left: 10px;
    }

    .DayPicker-NavButton--next {
        right: 10px;
    }

    .DayPicker-NavButton--interactionDisabled {
        display: none;
    }

    .DayPicker-Caption {
        display: table-caption;
        margin-bottom: 0;
        border: 1px solid #e9e9e9;
        padding: 0.5em 0.5em;
        background-color: #f1f1f1;
        text-align: center;
    }

    .DayPicker-Weekdays {
        display: table-header-group;
        margin-top: 1em;
    }

    .DayPicker-WeekdaysRow {
        display: none;
    }

    .DayPicker-Weekday {
        display: table-cell;
        padding: 0.5em;
        color: #8B9898;
        text-align: center;
        font-size: 0.875em;
    }


    .DayPicker-Body {
        display: table-row-group;
    }

    .DayPicker-Week {
    }

    .DayPicker-Day {
        display: table-cell;
        padding: 0.8em;
        border: 1px solid #d0d4d9;
        vertical-align: middle;
        text-align: center;
        cursor: pointer;
        width: 8.9vw;
    }

I want to make the calendar wide enought to fill all a mobile screen in my web-app (mobile version).

1 Answer 1

1

I don't know how but I did it. Here is the solution:

.DayPicker {
    flex-direction: row;
    font-size: 2.5rem;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

.DayPicker-wrapper {
    position: relative;
    flex-direction: row;
    user-select: none;
    width: 100%;
    margin: 0;
    padding: 0;
}

.DayPicker-Months {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

.DayPicker-Month {
    display: table;
    margin: 0;
    padding: 0;
    margin-top: auto;
    border-spacing: 0;
    border-collapse: collapse;
    user-select: none;
}

.DayPicker-NavBar {
    position: relative;
    margin: 0;
    padding: 0;
}

.DayPicker-NavButton {
    position: absolute;
    top: 1.4rem;
    margin-top: 2px;
    width: 1.25em;
    height: 1.25em;
    background-position: center;
    background-size: 60%;
    background-repeat: no-repeat;
    color: #8B9898;
    cursor: pointer;
    outline: none;
}

.DayPicker-NavButton:hover {
    opacity: 0.8;
}

.DayPicker-NavButton--prev {
    left: 10px;
    background-image: url('../../images/navLeft.png');
}

.DayPicker-NavButton--next {
    right: 10px;
    background-image: url('../../images/navRight.png');}

.DayPicker-NavButton--interactionDisabled {
    display: none;
}

.DayPicker-Caption {
    display: table-caption;
    border: 1px solid #e9e9e9;
    padding: 0.5em 0.5em;
    background-color: #f1f1f1;
    text-align: center;
    margin: 0;
}

.DayPicker-Caption > div {
    font-family: "Open Sans", monospace;
    font-weight: 600;
    margin: 0;
    padding: 0;
}

.DayPicker-WeekdaysRow {
    display: none;
    margin: 0;
    padding: 0;
}

/*.DayPicker-Body {
    display: table-row-group;
}*/

.DayPicker-Week {
    display: table-row;
    margin: 0;
    padding: 0;
}

.DayPicker-Day {
    display: table-cell;
    padding: 0.8em;
    border: 1px solid #d0d4d9;
    vertical-align: middle;
    text-align: center;
    cursor: pointer;
    width: 6rem;
    margin: 0;
}


.DayPicker-TodayButton {
    background-color: transparent;
    background-image: none;
    box-shadow: none;
    color: #4A90E2;
    font-size: 0.875em;
    cursor: pointer;
}
1
  • If anyone else is curious about this, this solution works because of the .DayPicker and .DayPicker-Months classes. Copying only those two would work fine. May 7, 2019 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.