@nanahoshi/mona-ui 0.27.0 → 0.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/docs/api/auto-complete.md +67 -0
  2. package/docs/api/avatar.md +31 -0
  3. package/docs/api/breadcrumb.md +74 -0
  4. package/docs/api/button-group.md +71 -0
  5. package/docs/api/button.md +84 -0
  6. package/docs/api/calendar.md +123 -0
  7. package/docs/api/card.md +97 -0
  8. package/docs/api/chart.md +4380 -0
  9. package/docs/api/check-box.md +70 -0
  10. package/docs/api/chip.md +55 -0
  11. package/docs/api/circular-progress-bar.md +71 -0
  12. package/docs/api/collapsible.md +71 -0
  13. package/docs/api/color-gradient.md +54 -0
  14. package/docs/api/color-palette.md +52 -0
  15. package/docs/api/color-picker.md +89 -0
  16. package/docs/api/combo-box.md +69 -0
  17. package/docs/api/command.md +282 -0
  18. package/docs/api/common.md +599 -0
  19. package/docs/api/contextmenu.md +239 -0
  20. package/docs/api/date-input.md +119 -0
  21. package/docs/api/date-picker.md +67 -0
  22. package/docs/api/datetime-picker.md +72 -0
  23. package/docs/api/dialog.md +291 -0
  24. package/docs/api/dropdown-button.md +248 -0
  25. package/docs/api/dropdown-list.md +72 -0
  26. package/docs/api/dropdowns.md +172 -0
  27. package/docs/api/editor.md +117 -0
  28. package/docs/api/expansion-panel.md +85 -0
  29. package/docs/api/fieldset.md +33 -0
  30. package/docs/api/filter.md +116 -0
  31. package/docs/api/grid.md +1445 -0
  32. package/docs/api/i18n.md +1699 -0
  33. package/docs/api/label.md +58 -0
  34. package/docs/api/list-box.md +301 -0
  35. package/docs/api/list-view.md +294 -0
  36. package/docs/api/list.md +119 -0
  37. package/docs/api/locales.md +134 -0
  38. package/docs/api/menubar.md +275 -0
  39. package/docs/api/multi-select.md +92 -0
  40. package/docs/api/notification.md +164 -0
  41. package/docs/api/numeric-text-box.md +130 -0
  42. package/docs/api/otp-input.md +100 -0
  43. package/docs/api/pager.md +371 -0
  44. package/docs/api/placeholder.md +18 -0
  45. package/docs/api/popover.md +170 -0
  46. package/docs/api/popup-menu.md +328 -0
  47. package/docs/api/popup.md +299 -0
  48. package/docs/api/progress-bar.md +79 -0
  49. package/docs/api/query.md +367 -0
  50. package/docs/api/radio-button.md +113 -0
  51. package/docs/api/rating.md +187 -0
  52. package/docs/api/scroll-view.md +93 -0
  53. package/docs/api/segmented.md +114 -0
  54. package/docs/api/sheet.md +65 -0
  55. package/docs/api/sidebar.md +583 -0
  56. package/docs/api/skeleton.md +26 -0
  57. package/docs/api/slider.md +173 -0
  58. package/docs/api/spinner.md +132 -0
  59. package/docs/api/split-button.md +261 -0
  60. package/docs/api/splitter.md +57 -0
  61. package/docs/api/stepper.md +148 -0
  62. package/docs/api/switch.md +78 -0
  63. package/docs/api/tabs.md +139 -0
  64. package/docs/api/text-area.md +20 -0
  65. package/docs/api/text-box.md +106 -0
  66. package/docs/api/theme.md +627 -0
  67. package/docs/api/time-picker.md +69 -0
  68. package/docs/api/time-selector.md +54 -0
  69. package/docs/api/tooltip.md +112 -0
  70. package/docs/api/tree-view.md +631 -0
  71. package/docs/api/window.md +245 -0
  72. package/docs/auto-complete.md +28 -329
  73. package/docs/avatar.md +4 -24
  74. package/docs/breadcrumb.md +10 -65
  75. package/docs/button-group.md +7 -60
  76. package/docs/button.md +8 -67
  77. package/docs/calendar.md +16 -121
  78. package/docs/card.md +16 -79
  79. package/docs/chart-bar.md +16 -234
  80. package/docs/chart-financial.md +10 -121
  81. package/docs/chart-funnel.md +13 -176
  82. package/docs/chart-heatmap.md +15 -131
  83. package/docs/chart-line-area.md +12 -137
  84. package/docs/chart-pie.md +17 -221
  85. package/docs/chart-radar.md +13 -129
  86. package/docs/chart-radial.md +13 -211
  87. package/docs/chart-scatter.md +6 -74
  88. package/docs/chart-treemap.md +14 -196
  89. package/docs/chart.md +154 -1892
  90. package/docs/checkbox.md +5 -61
  91. package/docs/chip.md +7 -42
  92. package/docs/circular-progress-bar.md +9 -61
  93. package/docs/collapsible.md +5 -87
  94. package/docs/color-gradient.md +8 -81
  95. package/docs/color-palette.md +7 -69
  96. package/docs/color-picker.md +9 -105
  97. package/docs/combo-box.md +28 -331
  98. package/docs/command.md +25 -236
  99. package/docs/contextmenu.md +15 -140
  100. package/docs/date-picker.md +7 -110
  101. package/docs/datetime-picker.md +7 -129
  102. package/docs/decimal-textbox.md +6 -69
  103. package/docs/dialog.md +23 -263
  104. package/docs/dropdown-button.md +15 -146
  105. package/docs/dropdown-list.md +29 -332
  106. package/docs/editor.md +8 -164
  107. package/docs/expansion-panel.md +7 -69
  108. package/docs/fieldset.md +5 -24
  109. package/docs/grid-columns.md +12 -92
  110. package/docs/grid-editing.md +29 -291
  111. package/docs/grid-grouping.md +11 -50
  112. package/docs/grid-rows.md +10 -74
  113. package/docs/grid-selection.md +7 -36
  114. package/docs/grid-server.md +8 -293
  115. package/docs/grid-sorting-filtering.md +10 -333
  116. package/docs/grid-state-export.md +17 -228
  117. package/docs/grid.md +23 -216
  118. package/docs/input.md +7 -19
  119. package/docs/label.md +8 -39
  120. package/docs/list-box.md +21 -253
  121. package/docs/list-view.md +25 -232
  122. package/docs/menubar.md +21 -167
  123. package/docs/multi-select.md +31 -350
  124. package/docs/notification.md +17 -116
  125. package/docs/numeric-textbox.md +9 -78
  126. package/docs/otp-input.md +9 -95
  127. package/docs/pager.md +19 -239
  128. package/docs/placeholder.md +5 -18
  129. package/docs/popover.md +13 -123
  130. package/docs/popup-menu.md +22 -243
  131. package/docs/popup.md +24 -248
  132. package/docs/progress-bar.md +10 -75
  133. package/docs/radio-button.md +8 -96
  134. package/docs/range-slider.md +9 -82
  135. package/docs/rating.md +15 -163
  136. package/docs/scroll-view.md +9 -86
  137. package/docs/segmented.md +8 -90
  138. package/docs/sheet.md +10 -74
  139. package/docs/sidebar-menus.md +413 -0
  140. package/docs/sidebar-state.md +401 -0
  141. package/docs/sidebar.md +32 -876
  142. package/docs/skeleton.md +5 -26
  143. package/docs/slider.md +9 -97
  144. package/docs/spinner.md +15 -95
  145. package/docs/split-button.md +21 -166
  146. package/docs/splitter.md +9 -56
  147. package/docs/stepper.md +13 -127
  148. package/docs/switch.md +8 -58
  149. package/docs/tabs.md +13 -111
  150. package/docs/textarea.md +4 -13
  151. package/docs/textbox.md +10 -77
  152. package/docs/time-picker.md +7 -112
  153. package/docs/tooltip-directive.md +12 -96
  154. package/docs/tooltip.md +12 -96
  155. package/docs/tree-view.md +42 -495
  156. package/docs/window.md +19 -230
  157. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +1 -0
  158. package/fesm2022/nanahoshi-mona-ui-common.mjs +3 -0
  159. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +13 -1
  160. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +5 -0
  161. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +9 -0
  162. package/llms.txt +76 -0
  163. package/package.json +1 -1
  164. package/types/nanahoshi-mona-ui-collapsible.d.ts +2 -0
  165. package/types/nanahoshi-mona-ui-common.d.ts +6 -0
  166. package/types/nanahoshi-mona-ui-date-input.d.ts +18 -1
  167. package/types/nanahoshi-mona-ui-dropdowns.d.ts +6 -0
  168. package/types/nanahoshi-mona-ui-i18n.d.ts +12 -0
@@ -0,0 +1,401 @@
1
+ # Sidebar State & Behavior
2
+
3
+ > Collapsing, controlled and remembered state, the drawer on small screens, and reading a sidebar from code.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/sidebar`
6
+
7
+ **Selectors:** `mona-sidebar`, `mona-sidebar-layout`, `[monaSidebarTrigger]`
8
+
9
+ How a [sidebar](sidebar.md) opens and closes: what collapsing does, binding its state with `[(expanded)]`, remembering it across reloads with `persistKey`, reading and driving it from code with `injectSidebar()`, and the modal drawer it becomes on small screens.
10
+
11
+ ## Overview
12
+
13
+ | What | How | Event |
14
+ | :--- | :--- | :--- |
15
+ | What collapsing does | `collapsible` on `mona-sidebar` | — |
16
+ | Open or closed | `[(expanded)]` on `mona-sidebar`, or a `monaSidebarTrigger` | `expandedChange` |
17
+ | Remembered across reloads | `persistKey` on `mona-sidebar`; `provideSidebarStorage()` | — |
18
+ | Read or driven from code | `injectSidebar()` | — |
19
+ | When it becomes a drawer | `mobileBreakpoint` on `mona-sidebar-layout` | — |
20
+ | How far the drawer's modality reaches | `modalScope` on `mona-sidebar-layout` | — |
21
+
22
+ Each sidebar keeps its own state. A layout with two sidebars has two of everything on this page.
23
+
24
+ ## Import & Quick Start
25
+
26
+ ```typescript
27
+ import { SidebarComponent, SidebarLayoutComponent, SidebarTriggerDirective } from "@nanahoshi/mona-ui/sidebar";
28
+ ```
29
+
30
+ ```html
31
+ <mona-sidebar-layout [mobileBreakpoint]="1024">
32
+ <mona-sidebar collapsible="icon" persistKey="nav" [(expanded)]="navOpen">…</mona-sidebar>
33
+ <main monaSidebarInset>
34
+ <button monaSidebarTrigger aria-label="Toggle sidebar">…</button>
35
+ </main>
36
+ </mona-sidebar-layout>
37
+ ```
38
+
39
+ ## Examples
40
+
41
+ ### Remembered and read from code
42
+
43
+ The sidebar keeps whether it was left open under `persistKey`, so reloading the page brings it back that way. The toolbar in the inset reads it with `injectSidebar()`.
44
+
45
+ `remembered-example.component.ts`
46
+
47
+ ```typescript
48
+ import { Component, signal } from "@angular/core";
49
+ import { LucideDynamicIcon, LucideHouse, LucideSettings, LucideUsers } from "@lucide/angular";
50
+ import {
51
+ SidebarComponent,
52
+ SidebarContentDirective,
53
+ SidebarInsetDirective,
54
+ SidebarLayoutComponent,
55
+ SidebarMenuButtonDirective,
56
+ SidebarMenuDirective,
57
+ SidebarMenuItemDirective,
58
+ SidebarRailDirective
59
+ } from "@nanahoshi/mona-ui/sidebar";
60
+ import { SidebarStatusComponent } from "./sidebar-status.component";
61
+
62
+ @Component({
63
+ selector: "app-sidebar-state-remembered-example",
64
+ imports: [
65
+ LucideDynamicIcon,
66
+ SidebarComponent,
67
+ SidebarContentDirective,
68
+ SidebarInsetDirective,
69
+ SidebarLayoutComponent,
70
+ SidebarMenuButtonDirective,
71
+ SidebarMenuDirective,
72
+ SidebarMenuItemDirective,
73
+ SidebarRailDirective,
74
+ SidebarStatusComponent
75
+ ],
76
+ templateUrl: "./remembered-example.component.html"
77
+ })
78
+ export class SidebarStateRememberedExampleComponent {
79
+ protected readonly expanded = signal(true);
80
+ protected readonly pages = [
81
+ { icon: LucideHouse, label: "Home" },
82
+ { icon: LucideUsers, label: "Team" },
83
+ { icon: LucideSettings, label: "Settings" }
84
+ ];
85
+ }
86
+ ```
87
+
88
+ `sidebar-status.component.ts`
89
+
90
+ ```typescript
91
+ import { Component } from "@angular/core";
92
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
93
+ import { injectSidebar } from "@nanahoshi/mona-ui/sidebar";
94
+
95
+ /** A toolbar in the inset that reads the layout's sidebar and drives it, with no binding to it. */
96
+ @Component({
97
+ selector: "app-sidebar-status",
98
+ imports: [ButtonDirective],
99
+ templateUrl: "./sidebar-status.component.html"
100
+ })
101
+ export class SidebarStatusComponent {
102
+ protected readonly sidebar = injectSidebar();
103
+ }
104
+ ```
105
+
106
+ `remembered-example.component.html`
107
+
108
+ ```html
109
+ <mona-sidebar-layout class="h-72 border border-border" modalScope="layout">
110
+ <mona-sidebar collapsible="icon" persistKey="mona-docs-remembered-sidebar" [(expanded)]="expanded">
111
+ <nav monaSidebarContent aria-label="Workspace">
112
+ <ul monaSidebarMenu>
113
+ @for (page of pages; track page.label) {
114
+ <li monaSidebarMenuItem [active]="$first">
115
+ <a
116
+ monaSidebarMenuButton
117
+ href="/workspace"
118
+ [tooltip]="page.label"
119
+ (click)="$event.preventDefault()">
120
+ <svg aria-hidden="true" [lucideIcon]="page.icon" [size]="16"></svg>
121
+ <span>{{ page.label }}</span>
122
+ </a>
123
+ </li>
124
+ }
125
+ </ul>
126
+ </nav>
127
+ <button monaSidebarRail type="button"></button>
128
+ </mona-sidebar>
129
+
130
+ <div class="gap-3 p-4" monaSidebarInset>
131
+ <app-sidebar-status></app-sidebar-status>
132
+ <p class="text-sm">Bound <code>expanded</code>: {{ expanded() }}. Reload the page and it stays this way.</p>
133
+ </div>
134
+ </mona-sidebar-layout>
135
+ ```
136
+
137
+ `sidebar-status.component.html`
138
+
139
+ ```html
140
+ <div class="flex flex-wrap items-center gap-2">
141
+ <button monaButton size="small" type="button" (click)="sidebar.expand()">Expand</button>
142
+ <button monaButton size="small" type="button" (click)="sidebar.collapse()">Collapse</button>
143
+ <button monaButton size="small" type="button" (click)="sidebar.toggle()">Toggle</button>
144
+ </div>
145
+ <dl class="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm">
146
+ <dt class="font-medium">state</dt>
147
+ <dd>{{ sidebar.state() }}</dd>
148
+ <dt class="font-medium">iconOnly</dt>
149
+ <dd>{{ sidebar.iconOnly() }}</dd>
150
+ <dt class="font-medium">compact</dt>
151
+ <dd>{{ sidebar.compact() }}</dd>
152
+ </dl>
153
+ ```
154
+
155
+ ### Two sidebars
156
+
157
+ Each sidebar has an `id`, and each trigger names the one it toggles with `for`.
158
+
159
+ `two-sidebars-example.component.ts`
160
+
161
+ ```typescript
162
+ import { Component, signal } from "@angular/core";
163
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
164
+ import {
165
+ SidebarComponent,
166
+ SidebarContentDirective,
167
+ SidebarInsetDirective,
168
+ SidebarLayoutComponent,
169
+ SidebarMenuButtonDirective,
170
+ SidebarMenuDirective,
171
+ SidebarMenuItemDirective,
172
+ SidebarTriggerDirective
173
+ } from "@nanahoshi/mona-ui/sidebar";
174
+
175
+ @Component({
176
+ selector: "app-sidebar-state-two-sidebars-example",
177
+ imports: [
178
+ ButtonDirective,
179
+ SidebarComponent,
180
+ SidebarContentDirective,
181
+ SidebarInsetDirective,
182
+ SidebarLayoutComponent,
183
+ SidebarMenuButtonDirective,
184
+ SidebarMenuDirective,
185
+ SidebarMenuItemDirective,
186
+ SidebarTriggerDirective
187
+ ],
188
+ templateUrl: "./two-sidebars-example.component.html"
189
+ })
190
+ export class SidebarStateTwoSidebarsExampleComponent {
191
+ protected readonly detailsOpen = signal(false);
192
+ protected readonly navOpen = signal(true);
193
+ protected readonly projects = ["Website redesign", "Mobile app", "Billing"];
194
+ }
195
+ ```
196
+
197
+ `two-sidebars-example.component.html`
198
+
199
+ ```html
200
+ <mona-sidebar-layout class="h-72 border border-border" modalScope="layout">
201
+ <mona-sidebar id="example-nav" side="start" width="12rem" [(expanded)]="navOpen">
202
+ <nav monaSidebarContent aria-label="Projects">
203
+ <ul monaSidebarMenu>
204
+ @for (project of projects; track project) {
205
+ <li monaSidebarMenuItem [active]="project === projects[0]">
206
+ <a monaSidebarMenuButton href="/projects" (click)="$event.preventDefault()">{{ project }}</a>
207
+ </li>
208
+ }
209
+ </ul>
210
+ </nav>
211
+ </mona-sidebar>
212
+
213
+ <div class="gap-2 p-4" monaSidebarInset>
214
+ <div class="flex gap-2">
215
+ <button monaButton monaSidebarTrigger for="example-nav" type="button">Projects</button>
216
+ <button monaButton monaSidebarTrigger for="example-details" type="button">Details</button>
217
+ </div>
218
+ <p class="text-sm">Projects open: {{ navOpen() }}, details open: {{ detailsOpen() }}</p>
219
+ </div>
220
+
221
+ <mona-sidebar id="example-details" aria-label="Details" side="end" width="12rem" [(expanded)]="detailsOpen">
222
+ <div class="space-y-1 p-3 text-sm" monaSidebarContent>
223
+ <p class="font-semibold">Website redesign</p>
224
+ <p>Owner: Grace Hopper</p>
225
+ <p>Due: 14 March</p>
226
+ </div>
227
+ </mona-sidebar>
228
+ </mona-sidebar-layout>
229
+ ```
230
+
231
+ ## Behavior
232
+
233
+ ### Collapsible modes
234
+
235
+ | Mode | Collapsed behaviour |
236
+ | --- | --- |
237
+ | `offcanvas` (default) | Panel shrinks to nothing and is made `inert`, so nothing inside stays focusable |
238
+ | `icon` | Panel narrows to `iconWidth`; labels, badges, trailing actions and submenus stand aside, as described on [Sidebar Menus](sidebar-menus.md#on-the-icon-rail) |
239
+ | `none` | Collapsing is disabled; the panel stays at full width. Below `mobileBreakpoint` it's still a drawer that opens and closes |
240
+
241
+ If focus is on something that collapsing takes away, it moves to a trigger for that sidebar, or to its rail when there's no trigger, rather than falling to the page.
242
+
243
+ ### Controlled state
244
+
245
+ `expanded` is a two-way model on `mona-sidebar`. On a compact viewport it reflects the drawer, so one binding drives both presentations:
246
+
247
+ ```html
248
+ <mona-sidebar-layout>
249
+ <mona-sidebar [(expanded)]="sidebarOpen">…</mona-sidebar>
250
+ </mona-sidebar-layout>
251
+ ```
252
+
253
+ ### More than one sidebar
254
+
255
+ A layout can hold more than one sidebar — a navigation column on one edge and an inspector on the other. Each keeps its own state on its own binding, and each needs an `id` so a trigger can name it, as in the [Two sidebars](#two-sidebars) example.
256
+
257
+ A trigger with no `for` drives the sidebar it is written inside, falling back to the first sidebar in the layout — which is all a layout with a single sidebar ever needs. A `for` naming no sidebar leaves the trigger inert rather than throwing.
258
+
259
+ On a compact viewport only one drawer is open at a time: opening one closes the other, and they share the single backdrop the layout paints behind them. When one drawer opens another, closing it sends focus back to whatever opened the first. The inset steps out of the way for whichever drawer is open, and takes its surface from the first sidebar in author order.
260
+
261
+ ### Remembering the state across reloads
262
+
263
+ Set `persistKey` and the sidebar comes back the way it was left:
264
+
265
+ ```html
266
+ <mona-sidebar persistKey="nav">…</mona-sidebar>
267
+ ```
268
+
269
+ Nothing is stored without a key — the sidebar never writes to storage on its own. Give each sidebar in a layout its own key.
270
+
271
+ Only the docked state is kept. A drawer is never restored open, because on the viewport that makes one it would cover the page on load, and opening a drawer never overwrites the state the desktop comes back to. A stored value wins over `expanded` and is pushed back out through that binding, so do not set a key on a sidebar whose state is already restored elsewhere.
272
+
273
+ #### Where it is kept
274
+
275
+ The default is `localStorage`, under exactly the key given, with no prefix, so pick one nothing else in the application writes to. Storage that is unavailable — a server, private browsing, a full quota — is not an error: the sidebar just opens the way its `expanded` input says.
276
+
277
+ **A server-rendered application will flash.** `localStorage` cannot be read on the server, so the markup is rendered with the default state and corrected on hydration. To avoid it, supply storage the server can read too — a cookie, or state transferred from the request:
278
+
279
+ ```typescript
280
+ import { provideSidebarStorage, type SidebarStorage } from "@nanahoshi/mona-ui/sidebar";
281
+
282
+ const cookieStorage: SidebarStorage = {
283
+ read: key => { … }, // null when nothing is stored
284
+ write: (key, expanded) => { … }
285
+ };
286
+
287
+ bootstrapApplication(AppComponent, {
288
+ providers: [provideSidebarStorage(cookieStorage)]
289
+ });
290
+ ```
291
+
292
+ `read` returns `null` when it has nothing for that key, which leaves the sidebar on its input's state. A storage that throws is reported in development and otherwise treated the same way.
293
+
294
+ `provideSidebarStorage()` also takes a factory, which runs in an injection context, for storage that needs something from the current request:
295
+
296
+ ```typescript
297
+ provideSidebarStorage(() => new CookieStorage(inject(REQUEST)))
298
+ ```
299
+
300
+ A value the default storage doesn't recognize, such as another feature's entry under the same key, counts as nothing stored, and stays there until the sidebar's state changes. Nothing is written until then. Storage isn't watched, so tabs don't follow each other.
301
+
302
+ ### Reading the sidebar from a descendant
303
+
304
+ `injectSidebar()` returns the sidebar's state and the commands that are safe to issue from anywhere:
305
+
306
+ ```typescript
307
+ import { injectSidebar } from "@nanahoshi/mona-ui/sidebar";
308
+
309
+ @Component({ … })
310
+ export class WorkspaceSwitcherComponent {
311
+ protected readonly sidebar = injectSidebar();
312
+
313
+ protected onSelect(): void {
314
+ if (this.sidebar.compact()) {
315
+ this.sidebar.collapse();
316
+ }
317
+ }
318
+ }
319
+ ```
320
+
321
+ The controller exposes `expanded`, `state`, `iconOnly`, `compact`, `mobileOpen`, `side`, `variant`, `collapsible` and `sidebarId` as signals, plus `expand()`, `collapse()` and `toggle()`. The reference page of [`SidebarController`](api/sidebar.md#sidebarcontroller) describes each one.
322
+
323
+ Structural facts are readable but not settable. `side`, `variant` and `collapsible` are authored as inputs on `mona-sidebar`; writing them from a descendant would leave the component and the shared state disagreeing until the next change detection pass. Bind the inputs instead.
324
+
325
+ Inside a `mona-sidebar` it reads that sidebar. Elsewhere in a `mona-sidebar-layout`, such as a toolbar in the inset, it reads the layout's first sidebar in author order, or the one you name with `injectSidebar({ for: "inspector" })`. A sidebar that hasn't rendered yet reads as closed, and commands to it do nothing.
326
+
327
+ Call it in an injection context. It throws when there's no sidebar or layout around the caller, unless you pass `{ optional: true }`, for a component that may be used outside a layout.
328
+
329
+ ### Responsive behaviour
330
+
331
+ Below `mobileBreakpoint` (default `768`) the sidebar becomes a modal drawer:
332
+
333
+ - Slides in from its docked edge; everything outside it goes `inert` and the page stops scrolling
334
+ - It's a `dialog` named by `aria-label` or `aria-labelledby`, with a localized default
335
+ - Focus is trapped inside it, on the panel itself if it has no controls. On close, however it closed, focus returns to whatever opened it, unless it has already moved somewhere else
336
+ - Escape and backdrop clicks close it, wherever focus is. A docked sidebar ignores Escape. A control that calls `preventDefault()` on the key keeps it, and so does a popup opened from the drawer. In nested layouts, it closes only the inner drawer
337
+ - Drawer state is separate from the desktop state and resets whenever the viewport crosses the breakpoint
338
+ - Activating a row closes the drawer, since the destination is underneath it — opt out with `[closeOnSelect]="false"`. A row that opens a submenu leaves it open without that binding
339
+
340
+ While the viewport is compact, `[(expanded)]` reports the drawer, so it reads `false` on a phone from the start. To remember the docked state, use `persistKey` rather than saving that value.
341
+
342
+ Set `mobileBreakpoint` to `0` to keep the docked presentation at every size.
343
+
344
+ ```html
345
+ <mona-sidebar-layout [mobileBreakpoint]="1024">
346
+ <mona-sidebar mobileWidth="20rem">…</mona-sidebar>
347
+ </mona-sidebar-layout>
348
+ ```
349
+
350
+ #### How far the drawer's modality reaches
351
+
352
+ By default an open drawer makes the whole page inert and locks its scroll, so an app header above the layout can't be reached behind it. Popups opened from the drawer, such as a menu or a tooltip, stay usable. The lock only acts when the page itself scrolls: in an app whose root doesn't, there's nothing for it to lock. The inset stops scrolling behind the drawer either way.
353
+
354
+ A sidebar embedded in part of a page can keep this to its layout, with `modalScope`. Anything beside the layout that has to stay usable while a drawer is open, such as a toolbar or a Close button, needs this too. What's around the layout stays usable and the page keeps scrolling, so the drawer isn't `aria-modal` then:
355
+
356
+ ```html
357
+ <mona-sidebar-layout modalScope="layout">…</mona-sidebar-layout>
358
+ ```
359
+
360
+ The backdrop covers the layout either way, and never more than that.
361
+
362
+ ### Server rendering
363
+
364
+ Supply a stable `id` on `mona-sidebar` so the client does not hydrate onto a different generated id:
365
+
366
+ ```html
367
+ <mona-sidebar id="app-sidebar">…</mona-sidebar>
368
+ ```
369
+
370
+ Where `matchMedia` is unavailable — a server render, a test environment — the sidebar keeps its docked presentation, which is the one that degrades gracefully.
371
+
372
+ `persistKey` needs storage the server can read, or the remembered state arrives a frame late. See [Where it is kept](#where-it-is-kept).
373
+
374
+ ## Accessibility
375
+
376
+ - Keep a `monaSidebarTrigger` in the layout, with an accessible name. The rail is a pointer shortcut and isn't in the tab order, so without a trigger a collapsed sidebar can't be opened from the keyboard. See [Provide a trigger](sidebar.md#provide-a-trigger).
377
+ - Name the drawer, with `aria-label` or `aria-labelledby` on `mona-sidebar`, when the localized default doesn't describe it.
378
+ - Use `modalScope="layout"` only when the layout really is part of a page. With the default, a screen reader can't wander out of an open drawer into content it covers.
379
+
380
+ ## API
381
+
382
+ Everything below is imported from `@nanahoshi/mona-ui/sidebar`. Each name links to its reference page, with every input, output, property and method.
383
+
384
+ | Name | Kind | Description |
385
+ | --- | --- | --- |
386
+ | [`LocalStorageSidebarStorage`](api/sidebar.md#localstoragesidebarstorage) | Class | The default `SidebarStorage`: `localStorage`, under the sidebar's `persistKey`. |
387
+ | [`injectSidebar`](api/sidebar.md#injectsidebar) | Function | Reads a sidebar from an injection context: the one that encloses the caller, or from elsewhere in a `mona-sidebar-layout`, such as a toolbar in the inset, the layout's first sidebar. |
388
+ | [`provideSidebarStorage`](api/sidebar.md#providesidebarstorage) | Function | Replaces where sidebars remember whether they were left open. |
389
+
390
+ ### Types
391
+
392
+ | Type | Kind | Description |
393
+ | --- | --- | --- |
394
+ | [`SIDEBAR_STORAGE`](api/sidebar.md#sidebar-storage) | Constant | Where sidebars given a `persistKey` remember whether they were left open. |
395
+ | [`SidebarController`](api/sidebar.md#sidebarcontroller) | Interface | The safe, read-and-command view of one sidebar, returned by `injectSidebar()`. |
396
+ | [`SidebarStorage`](api/sidebar.md#sidebarstorage) | Interface | Where a sidebar remembers whether it was left open. |
397
+ | [`InjectSidebarOptions`](api/sidebar.md#injectsidebaroptions) | Interface | |
398
+ | [`SidebarCollapsibleMode`](api/sidebar.md#sidebarcollapsiblemode) | Type alias | How the sidebar behaves when it is collapsed. |
399
+ | [`SidebarModalScope`](api/sidebar.md#sidebarmodalscope) | Type alias | How far an open drawer's modality reaches. - `"page"` makes everything outside the drawer inert and locks the page's scroll, and the drawer is `aria-modal`. - `"layout"` does that within `mona-sidebar-layout` only, for a sidebar embedded in part of a page. |
400
+
401
+ **Related types:** [`SidebarLogicalSide`](api/sidebar.md#sidebarlogicalside), [`SidebarVariant`](api/sidebar.md#sidebarvariant)