cssgridgenerator
App UI

CSS Grid Calendar Layout Generator

A seven-column month grid with a weekday header and events that span days.

Open in
1080px

Drag across the grid to draw an area. Arrow keys nudge, Shift + arrows resize.

space to pan · ⌘scroll to zoom
11fr21fr31fr41fr51fr61fr71fr8
1auto2auto3minmax(120px, auto)4minmax(120px, auto)5
toolbar1 / 1 / 2 / 8
mon2 / 1 / 3 / 2
tue2 / 2 / 3 / 3
wed2 / 3 / 3 / 4
thu2 / 4 / 3 / 5
fri2 / 5 / 3 / 6
sat2 / 6 / 3 / 7
sun2 / 7 / 3 / 8
w1-13 / 1 / 4 / 2
w1-23 / 2 / 4 / 3
w1-33 / 3 / 4 / 4
w1-43 / 4 / 4 / 5
w1-53 / 5 / 4 / 6
w1-63 / 6 / 4 / 7
w1-73 / 7 / 4 / 8
w2-14 / 1 / 5 / 2
w2-24 / 2 / 5 / 3
w2-34 / 3 / 5 / 4
w2-44 / 4 / 5 / 5
w2-54 / 5 / 5 / 6
w2-64 / 6 / 5 / 7
w2-74 / 7 / 5 / 8

Named areas. The CSS is a picture of the layout, and only the properties that actually change get repeated inside each media query.

.calendar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
  grid-template-rows: auto auto minmax(60px, auto) minmax(60px, auto);
  gap: 2px;
  grid-template-areas:
    "toolbar toolbar toolbar toolbar toolbar toolbar toolbar"
    "mon     tue     wed     thu     fri     sat     sun"
    "w1-1    w1-2    w1-3    w1-4    w1-5    w1-6    w1-7"
    "w2-1    w2-2    w2-3    w2-4    w2-5    w2-6    w2-7";
}

.calendar > .toolbar { grid-area: toolbar; }
.calendar > .mon { grid-area: mon; }
.calendar > .tue { grid-area: tue; }
.calendar > .wed { grid-area: wed; }
.calendar > .thu { grid-area: thu; }
.calendar > .fri { grid-area: fri; }
.calendar > .sat { grid-area: sat; }
.calendar > .sun { grid-area: sun; }
.calendar > .w1-1 { grid-area: w1-1; }
.calendar > .w1-2 { grid-area: w1-2; }
.calendar > .w1-3 { grid-area: w1-3; }
.calendar > .w1-4 { grid-area: w1-4; }
.calendar > .w1-5 { grid-area: w1-5; }
.calendar > .w1-6 { grid-area: w1-6; }
.calendar > .w1-7 { grid-area: w1-7; }
.calendar > .w2-1 { grid-area: w2-1; }
.calendar > .w2-2 { grid-area: w2-2; }
.calendar > .w2-3 { grid-area: w2-3; }
.calendar > .w2-4 { grid-area: w2-4; }
.calendar > .w2-5 { grid-area: w2-5; }
.calendar > .w2-6 { grid-area: w2-6; }
.calendar > .w2-7 { grid-area: w2-7; }

@media (min-width: 900px) {
  .calendar {
    grid-template-rows: auto auto minmax(120px, auto) minmax(120px, auto);
    gap: 4px;
  }
}

How this layout works

Seven equal columns, one row per week: repeat(7, minmax(0, 1fr)). The minmax(0, …) is what stops a long event title from making Wednesday wider than Thursday.

Multi-day events are the reason to use Grid here rather than a table. An event from Tuesday to Thursday is grid-column: 3 / 6 — one element spanning three cells — which a table of day cells cannot express without colspan gymnastics.

Give the day cells a minmax(90px, auto) row so an empty week still looks like a week, and a busy one can grow. Fixed row heights force you to hide events behind a "+3 more" link earlier than you need to.

Every property used here is listed in the CSS Grid cheat sheet, with the reason to reach for it.

Frequently asked questions

How do I build a month calendar with CSS Grid?
Seven columns of minmax(0, 1fr) and one row per week. The minmax(0, …) matters: without it a long event title makes one weekday wider than the rest.
How do I show an event that spans several days?
Place one element across the cells: Tuesday to Thursday is grid-column: 3 / 6. This is the thing a table of day cells cannot do, and the main reason to build a calendar with Grid.
How do I center a grid in CSS?
Use justify-content: center on the grid container to centre the whole grid inside it, and margin-inline: auto with a max-width to centre the container in the page. These are different jobs: the first moves the tracks within the container, the second moves the container itself.
How do I center items inside a CSS grid?
Set place-items: center on the container. That is shorthand for align-items plus justify-items, and it centres every item inside its own cell on both axes. For a single item, use place-self: center on that item instead.
How do I make a CSS grid responsive?
Use grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) and it reflows at every width with no media queries at all. Add breakpoints only when the exact column count matters, or when the layout has to change shape rather than just wrap.
When should I use CSS Grid instead of Flexbox?
Use Grid when things must line up in two directions at once, and Flexbox when content flows along one axis. A page skeleton or dashboard is Grid; a navbar or row of buttons is Flexbox. They nest: Grid for the page, Flexbox inside the cells.

How to use it

  1. Open the pattern

    The calendar month view loads into the editor already responsive, with every breakpoint set up.

  2. Change the tracks

    Edit the column and row sizes in the Tracks panel. Anything valid in a track list works.

  3. Redraw at another width

    Move the ruler past a breakpoint marker and rearrange. Only the placement changes.

  4. Copy the code

    Take CSS, HTML, Tailwind or a shadcn component. The media queries are already written.

More in App UI

Elsewhere in the library

Browse all 46 layout patterns →