2021-04-02 07:32:20 +03:00
|
|
|
|
---
|
|
|
|
|
title: Layout
|
|
|
|
|
path: components/layout
|
|
|
|
|
status: Experimental
|
|
|
|
|
source: 'https://github.com/primer/css/tree/main/src/layout/layout.scss'
|
|
|
|
|
bundle: layout
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
Build responsive-friendly page layouts with 2 columns.
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
Use with .container-xx classes to limit the overall layout structure size.
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
## Elements:
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
- `Layout-main`
|
|
|
|
|
- `Layout-sidebar`
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
## Default
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
```html live
|
|
|
|
|
<div class="Layout">
|
|
|
|
|
<div class="Layout-main border">
|
|
|
|
|
.Layout-main
|
|
|
|
|
</div>
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-sidebar border">
|
|
|
|
|
.Layout-sidebar
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
```
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
- `Layout-center-container-md`
|
|
|
|
|
- `Layout-center-container-lg`
|
|
|
|
|
- `Layout-center-container-xl`
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
Use `Layout-center-container-xx` to wrap `container-xx` elements inside
|
|
|
|
|
`Layout-main` so the content remains centered on the screen regardless
|
|
|
|
|
of the sidebar position.
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
## Modifiers:
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
### Sidebar position on desktop/large screens
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
- `Layout--right-sidebar` (default)
|
|
|
|
|
- `Layout--left-sidebar`
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
### Sidebar position on mobile/small screens
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
- `Layout--main-priority` (default)
|
|
|
|
|
- `Layout--sidebar-priority`
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
### Sidebar sizing
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
- Default: [md: 256px, lg: 296px, xl: 320px]
|
|
|
|
|
- `Layout--sidebar-narrow` [md: 240px, lg: 256px, xl: 296px]
|
|
|
|
|
- `Layout--sidebar-wide` [md: 296px, lg: 320px, xl: 344px]
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
```html live
|
|
|
|
|
<div class="Layout Layout--sidebar-narrow">
|
|
|
|
|
<div class="Layout-main border">
|
|
|
|
|
Layout--sidebar-narrow
|
2021-04-02 07:32:20 +03:00
|
|
|
|
</div>
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-sidebar border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
sidebar
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout Layout--sidebar-wide">
|
|
|
|
|
<div class="Layout-main border">
|
|
|
|
|
Layout--sidebar-wide
|
2021-04-02 07:32:20 +03:00
|
|
|
|
</div>
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-sidebar border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
sidebar
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-04-02 08:06:36 +03:00
|
|
|
|
```
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
### Column gutter
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
- Default: [md: 16px, lg: 24px, xl: 32px]
|
|
|
|
|
- `Layout--gutter-condensed` [md: 16px, lg: 16px, xl: 24px]
|
|
|
|
|
- `Layout--gutter-spacious` [md: 24px, lg: 32px, xl: 40px]
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
```html live
|
|
|
|
|
<div class="Layout Layout--gutter-condensed">
|
|
|
|
|
<div class="Layout-main border">
|
|
|
|
|
Layout--gutter-condensed
|
2021-04-02 07:32:20 +03:00
|
|
|
|
</div>
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-sidebar border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
sidebar
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout Layout--gutter-spacious">
|
|
|
|
|
<div class="Layout-main border">
|
|
|
|
|
Layout--gutter-spacious
|
2021-04-02 07:32:20 +03:00
|
|
|
|
</div>
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-sidebar border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
sidebar
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="Layout container-xl">
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-main border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
main
|
|
|
|
|
</div>
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-sidebar border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
sidebar
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="Layout Layout--left-sidebar">
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-main border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
main
|
|
|
|
|
</div>
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-sidebar border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
sidebar
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-04-02 08:06:36 +03:00
|
|
|
|
```
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
### Centered content
|
2021-04-02 07:32:20 +03:00
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
```html live
|
2021-04-02 07:32:20 +03:00
|
|
|
|
<div class="Layout Layout--left-sidebar">
|
|
|
|
|
<div class="Layout-main">
|
|
|
|
|
<div class="Layout-center-container-md">
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="container-md border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
main
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-sidebar border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
sidebar
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="Layout Layout--left-sidebar">
|
|
|
|
|
<div class="Layout-main">
|
|
|
|
|
<div class="Layout-center-container-lg">
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="container-lg border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
main
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2021-04-02 08:06:36 +03:00
|
|
|
|
<div class="Layout-sidebar border">
|
2021-04-02 07:32:20 +03:00
|
|
|
|
sidebar
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-04-02 08:06:36 +03:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Accessibility and keyboard navigation
|
|
|
|
|
|
|
|
|
|
Keyboard navigation follows the markup order. Decide carefully how the
|
|
|
|
|
focus order should be be by deciding whether `Layout-main` or `Layout-sidebar`
|
|
|
|
|
comes first in code. The code order won’t affect the visual position.
|