Grid

A very simple, naive CSS Grid implementation

The Upstart Grid is a minimal implementation of CSS Grid. It allows for an arbitrary number of grid columns, each of which is 1fr in width.

There is no accounting for rows, due to the added complexity that would introduce, plus the 'fact that if you need something more specific, you are probably better of defining your own grid implementation.

The Upstart Grid is made up of two components:

  1. A grid container; and
  2. A grid item - a grid specific content wrapper that provides a grid specific API

Grid Container

The grid container is the <Grid> component. It defines your grid, the number of grid columns, and the size of any gap between your grid components. It is set to a width of 100%, so it will fill all available width wherever you put it.

By default, it has 6 columns, and a grid gap of space[3] from the theme (1.6rem by default).

It expects content in the form of children, and can take any component or HTML element you would like to pass to it, however they will explicitly be constrained to a single column.

Props

Prop nameTypeDefaultDescription
classNamestringnullA custom className you would like to pass to the Component
colsunion6The number of columns in the Grid
gapunion3The the index of the value in the space array to use as the size of the gap between columns and rows
childrenunionRequiredThe children of the Grid

Grid Item

The grid item is the <GridItem> component, and is intended specifically for use with the <Grid> component, and exposes an API that will allow you to specify how many columns wide it should be, as well as which grid line it should start and/or end at.

Span 6
Start 1, End 3
Start 3, Span 4
Start 1, End 4
Auto
End 7, Span 2

Props

Prop nameTypeDefaultDescription
classNamestringnullA custom className you would like to pass to the Component
endunionnullThe grid line the item will end on
spanunionnullHow many grid tracks the item will span
startunionnullThe grid line the item will start on
childrenunionRequiredThe children of the Grid