x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<div class="sidebar-layout">
<header id="header">
<div class="hide@md" data-controller="dialog">
<button class="btn btn--icon" data-action="dialog#showModal">
<img aria-hidden="true" src="/assets/menu-5b8caef9.svg" width="20" height="20" />
<span class="sr-only">Open menu</span>
</button>
<dialog class="sheet sheet--left" data-dialog-target="menu" data-action="click->dialog#closeOnClickOutside">
<button class="btn btn--plain sheet__close" data-action="click->dialog#close">
<img aria-hidden="true" src="/assets/x-2fabf707.svg" width="16" height="16" />
<span class="sr-only">Close</span>
</button>
<div class="sheet__content">
<h1>Mobile menu</h1>
</div>
</dialog>
</div>
<h1>Header</h1>
</header>
<aside id="sidebar">
<div class="p-2">Sidebar</div>
</aside>
<main id="main">
<div>Line 1</div>
<div>Line 2</div>
<div>Line 3</div>
<div>Line 4</div>
<div>Line 5</div>
<div>Line 6</div>
<div>Line 7</div>
<div>Line 8</div>
<div>Line 9</div>
<div>Line 10</div>
</main>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<div class="sidebar-layout">
<header id="header">
<%= render "mobile_menu" %>
<h1>Header</h1>
</header>
<aside id="sidebar">
<div class="p-2">Sidebar</div>
</aside>
<main id="main">
<div>Line 1</div>
<div>Line 2</div>
<div>Line 3</div>
<div>Line 4</div>
<div>Line 5</div>
<div>Line 6</div>
<div>Line 7</div>
<div>Line 8</div>
<div>Line 9</div>
<div>Line 10</div>
</main>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
.sidebar-layout {
display: grid;
grid-template-areas: "header header" "sidebar main";
grid-template-columns: var(--sidebar-width, 0) 1fr;
grid-template-rows: auto 1fr;
block-size: 100dvh;
@media (width >= 48rem) {
--sidebar-border-width: var(--border);
--sidebar-padding: var(--size-2);
--sidebar-width: 220px;
}
@media (width >= 64rem) {
--sidebar-border-width: var(--border);
--sidebar-padding: var(--size-4);
--sidebar-width: 280px;
}
}
.header-layout {
display: grid;
grid-template-areas: "header" "main";
grid-template-rows: auto 1fr;
block-size: 100dvh;
}
.centered-layout {
display: grid;
place-items: center;
block-size: 100dvh;
}
.container {
inline-size: 100%;
margin-inline: auto;
max-inline-size: var(--container-width, 64rem);
}
#header {
align-items: center;
border-block-end-width: var(--border);
block-size: var(--size-16);
display: flex;
gap: var(--size-4);
grid-area: header;
padding-inline: var(--size-4);
@media (width >= 64rem) {
padding-inline: var(--size-6);
}
}
#sidebar {
border-inline-end-width: var(--sidebar-border-width, 0);
display: flex;
flex-direction: column;
grid-area: sidebar;
gap: var(--size-2);
overflow-x: hidden;
padding: var(--sidebar-padding, 0);
}
#main {
display: flex;
flex-direction: column;
gap: var(--size-4);
grid-area: main;
overflow: auto;
padding: var(--size-4);
@media (width >= 64rem) {
gap: var(--size-6); padding: var(--size-6);
}
}
Java Script is not required or multiple files are needed, check the notes.