npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@asphalt-react/layout

v2.12.2

Published

Layout

Downloads

133

Readme

Layout

npm npm version

The Layout component provides a flexible and composable way to structure your application's pages using semantic sections and responsive layouts. It includes helpers for common page areas (Header, Aside, Main, Footer) and a powerful layout system for arranging content.

Usage

import { Page, Layout } from '@asphalt-react/layout'
import { Appbar } from '@asphalt-react/appbar'
import { Logo } from '@asphalt-react/logo'

<Page>
  <Page.Header>
    <Appbar head={<Logo />} />
  </Page.Header>
  <Page.Main>
    <Layout>
      content
    </Layout>
  <Page.Main>
</Page>

Components

Page & Section

A wrapper for page content, providing consistent styling and structure. This component will arrange the UI based on the layout regions declared in Page Section.

A semantic wrapper for page areas. Use Page.Header, Page.Aside, Page.Main, and Page.Footer for common layout regions. Add sections inside the Page component to automatically arrange them. Set semantic to true to render components as HTML semantic elements.

Below is an example usage with Sidebar or Appbar. If using both components, ensure that navigation is included in only one—either the sidebar or the appbar.

import { Page, Layout } from '@asphalt-react/layout'
import { Sidebar } from '@asphalt-react/sidebar'
import { Logo } from '@asphalt-react/logo'

<Page>
  <Page.Header>
    <Appbar head={<Logo />} />
  </Page.Header>
  <Page.Main>
    <Layout>
      content
    </Layout>
  <Page.Main>
</Page>

Layout & Slot

A responsive layout container that supports both grid and flexbox, with options for gaps, alignment, templates, and breakpoints. This component provides the following layout types:

  • Fluid — Follows the intrinsic width of its children.
  • Fill — Distributes available space equally among children.
  • Spread — Adds equal spacing between child elements.
  • Template — Arranges children according to a template format.

You can nest a Layout component inside another Layout. For best results, place the Layout inside Page.Main, as it relies on container queries that depend on the Main component.

The Slot component is designed for use within Layout. It lets you specify a container area when used with <Layout template>. It also controls the order of items responsively using the order prop. The order prop can be a single number or an object specifying the order for small (s), medium (m), and large (l) breakpoints.

<Layout>
  <Layout.Slot order={{s: -1, m: 1}}></Layout.Slot>
  <Layout.Slot order={-1}></Layout.Slot>
</Layout>

Fluid

This is the default behavior of Layout. It arranges child elements horizontally or vertically, following the intrinsic width or height of their content. By default, items will wrap to a new line when there is not enough space.

<Layout vertical>
  <div style={{width: "200px"}}>content...</div>
  <div>content...</div>
</Layout>

Spread

Spread distributes child elements with equal spacing between them.

<Layout spread>
  <Button>Login</Button>
  <Button>Forgot Password</Button>
</Layout>

Fill

The fill layout ensures that all child elements expand to fill the available space equally. This is especially useful for repetitive items, such as cards or tiles, that should have uniform sizing regardless of their content. On smaller screens, items will stack vertically and take full width. You can override this behaviour by specifying the number of items per row for each breakpoint (e.g., s={2}, m={4}).

// fill the space equally
<Layout fill>
  <div></div>
  <div></div>
  <div></div>
</Layout>

// 2 columns on small screen, 6 columns in medium screen
<Layout fill s={2} m={6}>
  <div></div>
  <div></div>
  <div></div>
  ...
</Layout>

Template

The template layout enables developers to define complex, grid-based arrangements using named areas. Add a line break to indicate new rows. Each child can be assigned to a specific area by setting the area prop on the Slot component. If the s (small) breakpoint is not specified, items will automatically stack vertically and take up 100% width on mobile screens.

const template = 
`analytis analytics summary
category consumer summary`;
const templateResponsive = {
  s: `summary summary
  category customers
  analytics analytics`,
  m: `analytics analytics summary
  customers category summary`,
}

<Layout template={template}>
  <Layout.Slot area="analytics"></Layout.Slot>
  <Layout.Slot area="category"></Layout.Slot>
  <Layout.Slot area="consumer"></Layout.Slot>
  <Layout.Slot area="summary"></Layout.Slot>
</Layout>

Layout

Props

children

React node(s) to render inside the layout container.

| type | required | default | | ---- | -------- | ------- | | node | false | N/A |

gap

The gap size between layout items. Accepts 's', 'm', or 'l'. The default is 'm'.

| type | required | default | | ---- | -------- | ------- | | enum | false | "m" |

align

Align of items along cross-axis: 'start', 'end', 'center', or 'stretch'. Equivalent to CSS align-items.

| type | required | default | | ---- | -------- | ------- | | enum | false | N/A |

placement

Placement of items along the main axis: 'start', 'end', or 'center'. Equivalent to CSS justify-content.

| type | required | default | | ---- | -------- | ------- | | enum | false | N/A |

spread

Adds equal spacing between items.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

vertical

Applies vertical layout. Only works on default Layout and Spread.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

wrap

Enables wrapping of items. Default is true. Only works on default Layout and Spread.

| type | required | default | | ---- | -------- | ------- | | bool | false | true |

reverseOrder

Reverses the order of children items. Only works on default Layout and Spread.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

fill

Fill available space equally.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |

s

Number of columns for small screens (used with fill).

| type | required | default | | ------ | -------- | ------- | | number | false | N/A |

m

Number of columns for medium screens (used with fill).

| type | required | default | | ------ | -------- | ------- | | number | false | N/A |

l

Number of columns for large screens (used with fill).

| type | required | default | | ------ | -------- | ------- | | number | false | N/A |

template

Sets layout template areas, as a string or an object with s/m/l keys. Use a line break to indicate new rows. For example: slot1 slot2 \n slot1 slot2 or { s: slot1 \n slot2, m: slot1 slot2 \n slot1 slot2 }

| type | required | default | | ------ | -------- | ------- | | custom | false | "" |

responsiveLayout

Enables responsive Layout which auto adjusts layout based on screen size.

| type | required | default | | ---- | -------- | ------- | | bool | false | true |

Page

Props

children

Components or elements to be rendered inside the Page.

| type | required | default | | ---- | -------- | ------- | | node | true | N/A |

asideEnd

Aligns Aside component to the end of the container.

| type | required | default | | ---- | -------- | ------- | | bool | false | false |