NextWeb.js

NextWeb.js

  • Docs
  • GitHub

›Styling

Getting Started

  • Getting Started
  • Folder Structure
  • Create a New Page
  • Navigate Between Pages

App

  • Environment Variables
  • Module Alias
  • Routing
  • Context
  • Store
  • Authentication

Page

  • Layout
  • Meta
  • Breadcrumb
  • Stats
  • Restricted Pages

Data Fetching

  • Repositories & Services
  • Server-Side Fetching
  • Client-Side Fetching
  • Error Handling
  • Custom Error

Styling

  • Local Styles
  • Global Styles
  • Grids
  • Style Helpers
  • Fonts
  • Icons

Deployment

  • Deployment

Grids

NextWeb.js comes with simple grid from Rebass.

import { Flex, Box } from '@grid'

function MyComponent() {
  return (
    <Flex>
      <Box width={1/2}>
        Half width
      </Box>
      <Box width={1/2}>
        Half width
      </Box>
    </Flex>
  )
}

As you can see, Rebass Grid allow us to specify how wide our boxes are using the aspect ratio instead of number of columns. That's mean you are no longer sticked to a specific column-based.

Responsive Grids

import { Flex, Box } from '@grid'

function MyComponent() {
  return (
    <Flex>
      <Box width={[1, 2 / 3]}>
        Main
      </Box>
      <Box width={[1, 1 / 3]}>
        Aside
      </Box>
    </Flex>
  )
}

The first item of the array you passed to width prop will be used if the viewport size is smaller than the first breakpoint while each rest item will be used if its breakpoint is matched.

For more information, please visit rebass grid's documentation.

Breakpoints

The good news is you can defines your own breakpoints.

// src/lib/styles/helpers.js

export const breakpoints = {
  md: '48em', // 768px
  lg: '60em', // 960px
  xl: '80em', // 1280px
}

...

Actually, the name of each breakpoint can be anything. But please remember that you will use these names later to refer to each breakpoint. And if you think the default breakpoints are not enough, you can add more.

← Global StylesStyle Helpers →
  • Responsive Grids
  • Breakpoints