@nanahoshi/mona-ui 0.25.1 → 0.26.0

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 (222) hide show
  1. package/README.md +2 -0
  2. package/command/package.json +4 -0
  3. package/docs/auto-complete.md +733 -0
  4. package/docs/avatar.md +220 -0
  5. package/docs/breadcrumb.md +320 -0
  6. package/docs/button-group.md +392 -0
  7. package/docs/button.md +256 -0
  8. package/docs/calendar.md +515 -0
  9. package/docs/card.md +292 -0
  10. package/docs/chart.md +4058 -0
  11. package/docs/checkbox.md +374 -0
  12. package/docs/chip.md +339 -0
  13. package/docs/circular-progress-bar.md +287 -0
  14. package/docs/collapsible.md +308 -0
  15. package/docs/color-gradient.md +336 -0
  16. package/docs/color-palette.md +317 -0
  17. package/docs/color-picker.md +387 -0
  18. package/docs/combo-box.md +764 -0
  19. package/docs/command.md +582 -0
  20. package/docs/contextmenu.md +530 -0
  21. package/docs/date-picker.md +251 -0
  22. package/docs/datetime-picker.md +284 -0
  23. package/docs/decimal-textbox.md +260 -0
  24. package/docs/dialog.md +822 -0
  25. package/docs/dropdown-button.md +507 -0
  26. package/docs/dropdown-list.md +779 -0
  27. package/docs/editor.md +374 -0
  28. package/docs/expansion-panel.md +348 -0
  29. package/docs/fieldset.md +217 -0
  30. package/docs/forms.md +162 -0
  31. package/docs/grid.md +2053 -0
  32. package/docs/input.md +197 -0
  33. package/docs/installation.md +54 -0
  34. package/docs/introduction.md +46 -0
  35. package/docs/label.md +340 -0
  36. package/docs/list-box.md +637 -0
  37. package/docs/list-view.md +584 -0
  38. package/docs/menubar.md +559 -0
  39. package/docs/multi-select.md +765 -0
  40. package/docs/notification.md +460 -0
  41. package/docs/numeric-textbox.md +301 -0
  42. package/docs/otp-input.md +539 -0
  43. package/docs/pager.md +513 -0
  44. package/docs/placeholder.md +176 -0
  45. package/docs/popover.md +423 -0
  46. package/docs/popup-menu.md +658 -0
  47. package/docs/popup.md +617 -0
  48. package/docs/progress-bar.md +368 -0
  49. package/docs/radio-button.md +451 -0
  50. package/docs/range-slider.md +367 -0
  51. package/docs/rating.md +518 -0
  52. package/docs/scroll-view.md +375 -0
  53. package/docs/segmented.md +434 -0
  54. package/docs/sheet.md +348 -0
  55. package/docs/sidebar.md +1126 -0
  56. package/docs/skeleton.md +181 -0
  57. package/docs/slider.md +423 -0
  58. package/docs/spinner.md +370 -0
  59. package/docs/split-button.md +522 -0
  60. package/docs/splitter.md +342 -0
  61. package/docs/stepper.md +539 -0
  62. package/docs/switch.md +340 -0
  63. package/docs/tabs.md +542 -0
  64. package/docs/textarea.md +196 -0
  65. package/docs/textbox.md +332 -0
  66. package/docs/theming.md +403 -0
  67. package/docs/time-picker.md +254 -0
  68. package/docs/tooltip-directive.md +340 -0
  69. package/docs/tooltip.md +321 -0
  70. package/docs/tree-view.md +1018 -0
  71. package/docs/window.md +663 -0
  72. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
  73. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +8 -0
  74. package/fesm2022/nanahoshi-mona-ui-button.mjs +12 -0
  75. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +5 -2
  76. package/fesm2022/nanahoshi-mona-ui-chart.mjs +86 -0
  77. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +4 -0
  78. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +4 -0
  79. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +16 -2
  80. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
  81. package/fesm2022/nanahoshi-mona-ui-command.mjs +924 -0
  82. package/fesm2022/nanahoshi-mona-ui-common.mjs +4 -0
  83. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +10 -6
  84. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +2 -1
  85. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +2 -1
  86. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +9 -5
  87. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +9 -5
  88. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +55 -1
  89. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3 -2
  90. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +13 -0
  91. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +5 -0
  92. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs} +2 -2
  93. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs → nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs} +5 -5
  94. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs → nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs} +18 -35
  95. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs} +5 -5
  96. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs} +4653 -4529
  97. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  98. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
  99. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1 -0
  100. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +168 -0
  101. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +19 -1
  102. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +14 -0
  103. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +32 -0
  104. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +10 -0
  105. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +10 -0
  106. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +10 -0
  107. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +10 -0
  108. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +10 -0
  109. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +10 -0
  110. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +10 -0
  111. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +10 -0
  112. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +10 -0
  113. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +10 -0
  114. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +10 -0
  115. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +10 -0
  116. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +10 -0
  117. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +15 -8
  118. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +8 -5
  119. package/fesm2022/nanahoshi-mona-ui-notification.mjs +9 -0
  120. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1 -1
  121. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +5 -0
  122. package/fesm2022/nanahoshi-mona-ui-pager.mjs +2 -1
  123. package/fesm2022/nanahoshi-mona-ui-popover.mjs +14 -6
  124. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +48 -183
  125. package/fesm2022/nanahoshi-mona-ui-popup.mjs +16 -0
  126. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +4 -0
  127. package/fesm2022/nanahoshi-mona-ui-rating.mjs +2 -0
  128. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +1 -0
  129. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +5 -5
  130. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +1 -1
  131. package/fesm2022/nanahoshi-mona-ui-slider.mjs +7 -2
  132. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +9 -6
  133. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +18 -21
  134. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +11 -8
  135. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +9 -1
  136. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +2 -1
  137. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +16 -5
  138. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +13 -11
  139. package/fesm2022/nanahoshi-mona-ui-window.mjs +12 -5
  140. package/i18n/catalogs/en-US.messages.json +10 -0
  141. package/internal/popup-menu/package.json +4 -0
  142. package/llms.txt +123 -0
  143. package/locales/ar-sa/ar-sa.messages.json +10 -0
  144. package/locales/de-de/de-de.messages.json +10 -0
  145. package/locales/es-es/es-es.messages.json +10 -0
  146. package/locales/fr-fr/fr-fr.messages.json +10 -0
  147. package/locales/id-id/id-id.messages.json +10 -0
  148. package/locales/it-it/it-it.messages.json +10 -0
  149. package/locales/ja-jp/ja-jp.messages.json +10 -0
  150. package/locales/ko-kr/ko-kr.messages.json +10 -0
  151. package/locales/pt-br/pt-br.messages.json +10 -0
  152. package/locales/ru-ru/ru-ru.messages.json +10 -0
  153. package/locales/tr-tr/tr-tr.messages.json +10 -0
  154. package/locales/zh-cn/zh-cn.messages.json +10 -0
  155. package/locales/zh-tw/zh-tw.messages.json +10 -0
  156. package/package.json +9 -1
  157. package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -1
  158. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +8 -0
  159. package/types/nanahoshi-mona-ui-button.d.ts +12 -0
  160. package/types/nanahoshi-mona-ui-calendar.d.ts +3 -0
  161. package/types/nanahoshi-mona-ui-chart.d.ts +200 -0
  162. package/types/nanahoshi-mona-ui-check-box.d.ts +4 -0
  163. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +4 -0
  164. package/types/nanahoshi-mona-ui-collapsible.d.ts +10 -0
  165. package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -1
  166. package/types/nanahoshi-mona-ui-command.d.ts +253 -0
  167. package/types/nanahoshi-mona-ui-common.d.ts +17 -1
  168. package/types/nanahoshi-mona-ui-contextmenu.d.ts +5 -2
  169. package/types/nanahoshi-mona-ui-date-picker.d.ts +2 -1
  170. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +2 -1
  171. package/types/nanahoshi-mona-ui-dialog.d.ts +58 -1
  172. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +7 -3
  173. package/types/nanahoshi-mona-ui-dropdowns.d.ts +55 -1
  174. package/types/nanahoshi-mona-ui-editor.d.ts +31 -0
  175. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +13 -0
  176. package/types/nanahoshi-mona-ui-fieldset.d.ts +5 -0
  177. package/types/nanahoshi-mona-ui-grid.d.ts +162 -35
  178. package/types/nanahoshi-mona-ui-i18n.d.ts +144 -1
  179. package/types/nanahoshi-mona-ui-internal-list.d.ts +16 -1
  180. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +165 -0
  181. package/types/nanahoshi-mona-ui-internal-tree.d.ts +21 -2
  182. package/types/nanahoshi-mona-ui-internal.d.ts +4 -5
  183. package/types/nanahoshi-mona-ui-label.d.ts +1 -0
  184. package/types/nanahoshi-mona-ui-list-box.d.ts +27 -4
  185. package/types/nanahoshi-mona-ui-list-view.d.ts +34 -1
  186. package/types/nanahoshi-mona-ui-list.d.ts +1 -1
  187. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +10 -0
  188. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +10 -0
  189. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +10 -0
  190. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +10 -0
  191. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +10 -0
  192. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +10 -0
  193. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +10 -0
  194. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +10 -0
  195. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +10 -0
  196. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +10 -0
  197. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +10 -0
  198. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +10 -0
  199. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +10 -0
  200. package/types/nanahoshi-mona-ui-menubar.d.ts +10 -3
  201. package/types/nanahoshi-mona-ui-multi-select.d.ts +3 -3
  202. package/types/nanahoshi-mona-ui-notification.d.ts +9 -0
  203. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -1
  204. package/types/nanahoshi-mona-ui-otp-input.d.ts +1 -0
  205. package/types/nanahoshi-mona-ui-pager.d.ts +5 -1
  206. package/types/nanahoshi-mona-ui-popover.d.ts +9 -1
  207. package/types/nanahoshi-mona-ui-popup-menu.d.ts +48 -161
  208. package/types/nanahoshi-mona-ui-popup.d.ts +16 -0
  209. package/types/nanahoshi-mona-ui-progress-bar.d.ts +4 -0
  210. package/types/nanahoshi-mona-ui-rating.d.ts +2 -0
  211. package/types/nanahoshi-mona-ui-segmented.d.ts +1 -0
  212. package/types/nanahoshi-mona-ui-sheet.d.ts +1 -1
  213. package/types/nanahoshi-mona-ui-slider.d.ts +2 -0
  214. package/types/nanahoshi-mona-ui-spinner.d.ts +7 -0
  215. package/types/nanahoshi-mona-ui-split-button.d.ts +7 -4
  216. package/types/nanahoshi-mona-ui-stepper.d.ts +11 -2
  217. package/types/nanahoshi-mona-ui-tabs.d.ts +4 -1
  218. package/types/nanahoshi-mona-ui-text-box.d.ts +9 -1
  219. package/types/nanahoshi-mona-ui-time-picker.d.ts +2 -1
  220. package/types/nanahoshi-mona-ui-tooltip.d.ts +10 -2
  221. package/types/nanahoshi-mona-ui-tree-view.d.ts +6 -5
  222. package/types/nanahoshi-mona-ui-window.d.ts +66 -1
package/docs/tabs.md ADDED
@@ -0,0 +1,542 @@
1
+ # Tabs
2
+
3
+ > Switches between panels of related content.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/tabs`
6
+
7
+ **Selector:** `mona-tabs`
8
+
9
+ `TabsComponent` renders a set of `mona-tab` panels and lets the consumer switch between them by clicking a tab or navigating with the keyboard. Tabs are the right choice when each option labels an associated content panel — for example `Account | Security | Notifications`.
10
+
11
+ The tab strip is line-based: a horizontal rule separates the tab list from the content below it, and the active tab is marked by a short indicator line. The strip can be placed on any edge via the `position` input.
12
+
13
+ For compact value selection that does not switch content panels — for example `List | Grid` or `Day | Week | Month` — use `SegmentedComponent` instead.
14
+
15
+ ## Overview
16
+
17
+ Tabs organizes related content into named panels and shows one panel at a time. Each panel is declared as a `<mona-tab>` projected inside `<mona-tabs>`; `TabsComponent` renders the clickable tab strip and swaps the visible panel when the consumer selects a different tab.
18
+
19
+ **Use Tabs when:**
20
+
21
+ - Content naturally divides into a small, fixed set of named sections that share the same context (for example, "Login" and "Register" panels in the same card).
22
+ - Only one section needs to be visible at a time, and switching between them should not navigate to a different route.
23
+
24
+ Tabs is not a routing mechanism. Switching tabs does not change the URL. To deep-link to a tab, read the route yourself and bind `selectedIndex`, or `selected` on the tab.
25
+
26
+ ## Import & Quick Start
27
+
28
+ ```typescript
29
+ import { TabComponent, TabContentTemplateDirective, TabsComponent } from "@nanahoshi/mona-ui/tabs";
30
+ ```
31
+
32
+ ```html
33
+ <mona-tabs aria-label="Account">
34
+ <mona-tab title="Profile">
35
+ <ng-template monaTabContentTemplate>
36
+ <p>Profile content.</p>
37
+ </ng-template>
38
+ </mona-tab>
39
+ <mona-tab title="Settings">
40
+ <ng-template monaTabContentTemplate>
41
+ <p>Settings content.</p>
42
+ </ng-template>
43
+ </mona-tab>
44
+ </mona-tabs>
45
+ ```
46
+
47
+ A `<mona-tab>` renders no content of its own — content must be provided through a `monaTabContentTemplate` template, as shown above. A tab with no `monaTabContentTemplate` renders an empty panel.
48
+
49
+ ## Anatomy
50
+
51
+ Each structural directive below is an `ng-template` placed as projected content inside `<mona-tab>...</mona-tab>`. Neither template exposes a template context.
52
+
53
+ | Directive | Selector | Template context | Replaces |
54
+ |-------------------------------|---------------------------------------|------------------|-----------------------------------------------------------------------------|
55
+ | `TabContentTemplateDirective` | `ng-template[monaTabContentTemplate]` | None | No default — the tab's panel renders empty without it |
56
+ | `TabTitleTemplateDirective` | `ng-template[monaTabTitleTemplate]` | None | The default `<span>{{ title }}</span>` rendering of the tab's `title` input |
57
+
58
+ ```html
59
+ <mona-tab>
60
+ <ng-template monaTabTitleTemplate>
61
+ <svg lucideSettings [size]="16" aria-hidden="true"></svg>
62
+ <span>Settings</span>
63
+ </ng-template>
64
+ <ng-template monaTabContentTemplate>
65
+ <p>Settings content.</p>
66
+ </ng-template>
67
+ </mona-tab>
68
+ ```
69
+
70
+ A title template renders inside the tab, whose content is presentational to assistive technology, so it can hold text and icons but not links or other controls.
71
+
72
+ ## Examples
73
+
74
+ ### Setting the selected tab
75
+
76
+ `selectedIndex` is the zero-based index of the selected tab, and works two-way. Writing it selects that tab. A disabled or out-of-range index is refused, and the value goes back to the selected tab's index. If the tabs haven't arrived yet, the index waits for them.
77
+
78
+ `selected-index-example.component.ts`
79
+
80
+ ```typescript
81
+ import { Component, signal } from "@angular/core";
82
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
83
+ import { TabComponent, TabContentTemplateDirective, TabsComponent } from "@nanahoshi/mona-ui/tabs";
84
+
85
+ @Component({
86
+ selector: "app-tabs-selected-index-example",
87
+ imports: [ButtonDirective, TabComponent, TabContentTemplateDirective, TabsComponent],
88
+ templateUrl: "./selected-index-example.component.html"
89
+ })
90
+ export class TabsSelectedIndexExampleComponent {
91
+ protected readonly activeTab = signal(0);
92
+ }
93
+ ```
94
+
95
+ `selected-index-example.component.html`
96
+
97
+ ```html
98
+ <div class="flex flex-col gap-3">
99
+ <mona-tabs aria-label="Account" [(selectedIndex)]="activeTab">
100
+ <mona-tab title="Account">
101
+ <ng-template monaTabContentTemplate>
102
+ <p class="p-4 text-sm">Name, email and language.</p>
103
+ </ng-template>
104
+ </mona-tab>
105
+ <mona-tab title="Security">
106
+ <ng-template monaTabContentTemplate>
107
+ <p class="p-4 text-sm">Password and two-factor sign-in.</p>
108
+ </ng-template>
109
+ </mona-tab>
110
+ </mona-tabs>
111
+ <div class="flex items-center gap-3">
112
+ <button monaButton type="button" (click)="activeTab.set(1)">Review security</button>
113
+ <span class="text-sm">Selected index: {{ activeTab() }}</span>
114
+ </div>
115
+ </div>
116
+ ```
117
+
118
+ `selected` on a `mona-tab` does the same from the tab's side, which suits tabs added conditionally, where the index isn't known. The two stay in sync: `[(selected)]` follows the selection, and `selectedIndex` follows `selected`. Setting `selected` to `true` selects the tab unless it's disabled. A newly flagged tab takes the selection from the tab that has it, and if several are flagged at once, the first wins. Setting `selected` to `false` is refused, because the group always keeps one tab selected, and the value goes back to `true`. Use one or the other: when both are set at the start, `selected` wins.
119
+
120
+ With nothing set, the first enabled tab is selected. When every `mona-tab` is disabled, none is. `disabled` on `mona-tabs` doesn't count here: it stops the user changing the selection, and code can still change it.
121
+
122
+ `selectedIndexChange` fires for every change, including the ones the component makes itself. `tabSelect` fires only for a click or key, before it selects a tab. It doesn't fire for a value written to `selectedIndex` or `selected`, or when the selected tab is removed, so it can't veto those.
123
+
124
+ ### Closable tabs
125
+
126
+ `closable` on `mona-tabs` shows a close button on every tab. A tab's own `closable` input, when `true`, shows a close button for that tab even if the parent's `closable` is `false` — see [`closable` and `disabled` on a tab and its parent](#closable-and-disabled-on-a-tab-and-its-parent).
127
+
128
+ `closable-example.component.ts`
129
+
130
+ ```typescript
131
+ import { Component, signal } from "@angular/core";
132
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
133
+ import type { TabCloseEvent } from "@nanahoshi/mona-ui/tabs";
134
+ import { TabComponent, TabContentTemplateDirective, TabsComponent } from "@nanahoshi/mona-ui/tabs";
135
+
136
+ interface Report {
137
+ readonly id: number;
138
+ readonly title: string;
139
+ }
140
+
141
+ @Component({
142
+ selector: "app-tabs-closable-example",
143
+ imports: [ButtonDirective, TabComponent, TabContentTemplateDirective, TabsComponent],
144
+ templateUrl: "./closable-example.component.html"
145
+ })
146
+ export class TabsClosableExampleComponent {
147
+ #nextId = 4;
148
+ protected readonly reports = signal<readonly Report[]>([
149
+ { id: 1, title: "January" },
150
+ { id: 2, title: "February" },
151
+ { id: 3, title: "March" }
152
+ ]);
153
+
154
+ protected add(): void {
155
+ const id = this.#nextId++;
156
+ this.reports.update(reports => [...reports, { id, title: `Report ${id}` }]);
157
+ }
158
+
159
+ /** The tabs only ask; removing the tab from the data is what closes it. */
160
+ protected close(event: TabCloseEvent): void {
161
+ this.reports.update(reports => reports.filter((_, index) => index !== event.index));
162
+ }
163
+ }
164
+ ```
165
+
166
+ `closable-example.component.html`
167
+
168
+ ```html
169
+ <div class="flex flex-col gap-3">
170
+ <mona-tabs aria-label="Reports" [closable]="true" (tabClose)="close($event)">
171
+ @for (report of reports(); track report.id) {
172
+ <mona-tab [title]="report.title">
173
+ <ng-template monaTabContentTemplate>
174
+ <p class="p-4 text-sm">{{ report.title }} figures go here.</p>
175
+ </ng-template>
176
+ </mona-tab>
177
+ }
178
+ </mona-tabs>
179
+ <button monaButton class="self-start" type="button" (click)="add()">Add report</button>
180
+ </div>
181
+ ```
182
+
183
+ Closing a tab is entirely the consumer's responsibility — see [Tabs are removed by the consumer](#tabs-are-removed-by-the-consumer).
184
+
185
+ ### Disabled tabs
186
+
187
+ `disabled` on `mona-tabs` disables every tab. `disabled` on an individual `mona-tab` disables only that tab, even if the parent's `disabled` is `false`. A disabled tab cannot be selected or closed by pointer or keyboard. A tab that becomes disabled while it's selected stays selected until something else is chosen, so its panel doesn't disappear from under the user.
188
+
189
+ ```html
190
+ <mona-tabs>
191
+ <mona-tab title="Available">
192
+ <ng-template monaTabContentTemplate>Available content.</ng-template>
193
+ </mona-tab>
194
+ <mona-tab title="Locked" [disabled]="true">
195
+ <ng-template monaTabContentTemplate>Locked content.</ng-template>
196
+ </mona-tab>
197
+ </mona-tabs>
198
+ ```
199
+
200
+ ### Preserving tab content when switching tabs
201
+
202
+ `keepTabContent` (default `true`) keeps every tab's panel mounted in the DOM and toggles its visibility, so component state inside an inactive tab (such as unsaved form input) survives switching away and back. Set it to `false` to mount only the active tab's content, destroying and recreating panels as the consumer switches tabs.
203
+
204
+ ```html
205
+ <mona-tabs [keepTabContent]="false">
206
+ <mona-tab title="Draft"><ng-template monaTabContentTemplate>...</ng-template></mona-tab>
207
+ <mona-tab title="Preview"><ng-template monaTabContentTemplate>...</ng-template></mona-tab>
208
+ </mona-tabs>
209
+ ```
210
+
211
+ ### Position
212
+
213
+ `position` places the tab strip on one of the four edges of the tab content. Top and bottom strips lay out horizontally; left and right strips lay out vertically. This strip is on the left, and its titles use a `monaTabTitleTemplate` to add icons.
214
+
215
+ `vertical-example.component.ts`
216
+
217
+ ```typescript
218
+ import { Component } from "@angular/core";
219
+ import { LucideBell, LucideCreditCard, LucideDynamicIcon, LucideUser } from "@lucide/angular";
220
+ import {
221
+ TabComponent,
222
+ TabContentTemplateDirective,
223
+ TabsComponent,
224
+ TabTitleTemplateDirective
225
+ } from "@nanahoshi/mona-ui/tabs";
226
+
227
+ @Component({
228
+ selector: "app-tabs-vertical-example",
229
+ imports: [LucideDynamicIcon, TabComponent, TabContentTemplateDirective, TabsComponent, TabTitleTemplateDirective],
230
+ templateUrl: "./vertical-example.component.html"
231
+ })
232
+ export class TabsVerticalExampleComponent {
233
+ protected readonly sections = [
234
+ { description: "Your name, photo and time zone.", icon: LucideUser, title: "Profile" },
235
+ { description: "Which emails and alerts you get.", icon: LucideBell, title: "Notifications" },
236
+ { description: "Your plan, invoices and payment method.", icon: LucideCreditCard, title: "Billing" }
237
+ ];
238
+ }
239
+ ```
240
+
241
+ `vertical-example.component.html`
242
+
243
+ ```html
244
+ <mona-tabs class="h-64" aria-label="Settings" position="left">
245
+ @for (section of sections; track section.title) {
246
+ <mona-tab>
247
+ <ng-template monaTabTitleTemplate>
248
+ <svg aria-hidden="true" [lucideIcon]="section.icon" [size]="16"></svg>
249
+ <span>{{ section.title }}</span>
250
+ </ng-template>
251
+ <ng-template monaTabContentTemplate>
252
+ <p class="p-4 text-sm">{{ section.description }}</p>
253
+ </ng-template>
254
+ </mona-tab>
255
+ }
256
+ </mona-tabs>
257
+ ```
258
+
259
+ A left or right strip requires a constrained available height so its tabs can scroll vertically when they overflow — see [Vertical layout constraints](#vertical-layout-constraints).
260
+
261
+ ### Size
262
+
263
+ `size` controls the tab strip's dimensions.
264
+
265
+ ```html
266
+ <mona-tabs size="small">
267
+ <mona-tab title="A"><ng-template monaTabContentTemplate>A</ng-template></mona-tab>
268
+ <mona-tab title="B"><ng-template monaTabContentTemplate>B</ng-template></mona-tab>
269
+ </mona-tabs>
270
+ ```
271
+
272
+ ### Migrating from the removed `rounded` input
273
+
274
+ The `rounded` input has been removed. Tabs are line-based: the tab strip is separated from the content by a rule and the active tab is marked by an indicator line, so no radius is applied to the strip or the content.
275
+
276
+ ```text
277
+ Before:
278
+ <mona-tabs rounded="large">
279
+
280
+ After:
281
+ <mona-tabs>
282
+ ```
283
+
284
+ Tab content no longer receives a default card-like surface. Consumers that need that appearance should wrap their tab content in `mona-card` or apply their own surface styles.
285
+
286
+ For compact value selection that does not switch panels — `List | Grid`, `Day | Week | Month`, `Discover | My courses` — use `SegmentedComponent` instead.
287
+
288
+ ### Reacting to and canceling tab selection
289
+
290
+ `tabSelect` emits before the newly clicked or keyboard-activated tab becomes active. Calling `preventDefault()` on the emitted `TabSelectEvent` keeps the current tab selected. Arrow keys still move focus to a tab you veto, so the keyboard can reach the tabs after it.
291
+
292
+ `cancel-select-example.component.ts`
293
+
294
+ ```typescript
295
+ import { Component, signal } from "@angular/core";
296
+ import type { TabSelectEvent } from "@nanahoshi/mona-ui/tabs";
297
+ import { TabComponent, TabContentTemplateDirective, TabsComponent } from "@nanahoshi/mona-ui/tabs";
298
+
299
+ @Component({
300
+ selector: "app-tabs-cancel-select-example",
301
+ imports: [TabComponent, TabContentTemplateDirective, TabsComponent],
302
+ templateUrl: "./cancel-select-example.component.html"
303
+ })
304
+ export class TabsCancelSelectExampleComponent {
305
+ protected readonly message = signal("");
306
+
307
+ protected select(event: TabSelectEvent): void {
308
+ if (event.index === 1) {
309
+ event.preventDefault();
310
+ this.message.set("Upgrade to see the Pro plan.");
311
+ return;
312
+ }
313
+ this.message.set("");
314
+ }
315
+ }
316
+ ```
317
+
318
+ `cancel-select-example.component.html`
319
+
320
+ ```html
321
+ <div class="flex flex-col gap-3">
322
+ <mona-tabs aria-label="Plans" (tabSelect)="select($event)">
323
+ <mona-tab title="Free">
324
+ <ng-template monaTabContentTemplate>
325
+ <p class="p-4 text-sm">Three projects and one member.</p>
326
+ </ng-template>
327
+ </mona-tab>
328
+ <mona-tab title="Pro">
329
+ <ng-template monaTabContentTemplate>
330
+ <p class="p-4 text-sm">Unlimited projects and members.</p>
331
+ </ng-template>
332
+ </mona-tab>
333
+ </mona-tabs>
334
+ <p aria-live="polite" class="text-sm">{{ message() }}</p>
335
+ </div>
336
+ ```
337
+
338
+ ## Behavior
339
+
340
+ ### Tabs are removed by the consumer
341
+
342
+ `TabsComponent` does not remove a `<mona-tab>` from the DOM when it is closed. `tabClose` only notifies the consumer that a close was requested (by clicking the close button or pressing Delete/Backspace on a tab); the consumer is responsible for removing the corresponding tab from whatever collection drives the projected `<mona-tab>` elements (typically an `@for` loop).
343
+
344
+ ### What happens when the selected tab goes away
345
+
346
+ The next enabled tab is selected, or the nearest enabled one before it when there's none after. `selectedIndexChange` reports it, and `tabSelect` doesn't fire. If focus was on the removed tab or its close button, it moves to the selected tab. If it had already left the tab strip, it stays where it is.
347
+
348
+ ### `tabClose` has nothing to prevent
349
+
350
+ `TabCloseEvent` extends `PreventableEvent`, like the other events, but since the component never removes a tab, there's no default action. Calling `preventDefault()` in a `tabClose` handler has no effect. To refuse a close, don't remove the tab.
351
+
352
+ ### `closable` and `disabled` on a tab and its parent
353
+
354
+ A tab shows a close button when either its own `closable` or the parent's is on, and is disabled when either `disabled` is on. A tab can't opt out of what its parent turns on: there is no way to hide the close button on one tab when the parent's `closable` is `true`.
355
+
356
+ ### Panels are kept by tab, not by value
357
+
358
+ Changing a tab's `title`, `disabled` or `closable` leaves its panel and everything in it alone, including what's been typed there. Only removing the `mona-tab` itself destroys the panel.
359
+
360
+ ### Lazy content
361
+
362
+ `keepTabContent` is all or nothing: `true` creates every panel's content at the start, and `false` destroys content on each switch. There's no mode that renders on first visit and then keeps it. For heavy content in a tab, use `@if` inside the template with your own "has been visited" flag.
363
+
364
+ ### Scrolling is automatic and pointer-only
365
+
366
+ When the tab strip overflows its container, scroll buttons appear automatically — this is not controlled by a public input. Top and bottom strips overflow horizontally (left/right scroll buttons); left and right strips overflow vertically (up/down scroll buttons). The scroll buttons are hidden from assistive technology and are not a Tab stop. Keyboard users can still reach tabs outside the visible area because moving focus with the arrow keys scrolls the newly focused tab into view. A tab selected by code is scrolled into view within the strip, without scrolling the page. Scroll buttons don't animate when the user asks for reduced motion.
367
+
368
+ ### Vertical layout constraints
369
+
370
+ A left or right tab strip needs a constrained available height. If the strip is as tall as its content, the tabs have no room to scroll and overflow tabs become unreachable. Give the `mona-tabs` host a bounded height (for example `class="h-96"`) when using `position="left"` or `position="right"`.
371
+
372
+ - `"top" | "bottom" | "left" | "right"`. The values of the `position` input.
373
+
374
+ ## Forms Integration
375
+
376
+ Not applicable. `TabsComponent` and `TabComponent` are not form controls and do not implement `ControlValueAccessor` or the signal forms control interfaces.
377
+
378
+ ## Accessibility
379
+
380
+ ### Keyboard
381
+
382
+ | Key | Action |
383
+ |------------------------------------------------|-----------------------------------------------------------------------------------------------|
384
+ | `ArrowLeft` / `ArrowRight` (top/bottom) | Select the previous/next enabled tab, wrapping around at the ends. Disabled tabs are skipped. |
385
+ | `ArrowUp` / `ArrowDown` (left/right) | Select the previous/next enabled tab, wrapping around at the ends. Disabled tabs are skipped. |
386
+ | `Home` / `End` | Select the first/last enabled tab. |
387
+ | `Delete` / `Backspace` | Close the tab that has focus, if it is closable and not disabled. |
388
+ | `Tab` | Moves focus from the tab strip into the selected tab's panel. |
389
+ | `Shift+Tab` (while the panel itself has focus) | Moves focus back to the selected tab. |
390
+
391
+ In a right-to-left layout, `ArrowLeft` and `ArrowRight` swap, so they still follow the strip.
392
+
393
+ These keys are left to the browser when `Alt`, `Ctrl` or `Meta` is held, so `Alt+ArrowLeft` still goes back, and when `Shift` is held on the arrows.
394
+
395
+ The close button on each tab is not a Tab stop; keyboard users close a tab with `Delete`/`Backspace` instead of activating the close button directly.
396
+
397
+ A vetoed tab can have focus without being selected. `Tab` still goes to the selected tab's panel, and coming back lands on the selected tab.
398
+
399
+ ### Focus
400
+
401
+ The selected tab is the only tab in the Tab order (`tabindex="0"`); all other tabs have `tabindex="-1"` (roving tabindex). The active panel has `tabindex="0"` and becomes a Tab stop while visible. Both show a solid outline when focused from the keyboard, drawn inside their edges because the strip and the content area clip anything outside them.
402
+
403
+ ### ARIA
404
+
405
+ | Element | Attribute | When present | Value |
406
+ |----------|--------------------|----------------------------------------------------------------|------------------------------------------------------------------------------------------|
407
+ | Tab list | `role` | Always | `"tablist"` |
408
+ | Tab list | `aria-label` | When the `aria-label` input is set | The input's value |
409
+ | Tab list | `aria-labelledby` | When the `aria-labelledby` input is set | The input's value |
410
+ | Tab list | `aria-orientation` | Always | `"horizontal"` for top/bottom positions, `"vertical"` for left/right |
411
+ | Tab | `role` | Always | `"tab"` |
412
+ | Tab | `aria-selected` | Always | Reflects whether the tab is the active tab |
413
+ | Tab | `aria-disabled` | Always | Reflects the tab's effective disabled state (own `disabled`, or the parent's `disabled`) |
414
+ | Tab | `aria-controls` | Always | The corresponding panel's element id |
415
+ | Tab | `aria-keyshortcuts` | The tab can close and isn't disabled | `"Delete Backspace"` |
416
+ | Panel | `role` | Always | `"tabpanel"` |
417
+ | Panel | `aria-hidden` | Always | `"true"` on a kept panel that isn't the active one, otherwise `"false"` |
418
+ | Panel | `aria-labelledby` | Always | The corresponding tab's element id |
419
+
420
+ Give the tab list a name with `aria-label` or `aria-labelledby` on `mona-tabs` when the page has more than one set of tabs, or when nothing nearby says what they're for. The inputs go to the tab list, not the host.
421
+
422
+ A tab list may only contain tabs, and a tab's content is presentational, so a close button can't be exposed in either place. Axe rejects one anywhere inside the tab list, even beside the tab. That's why the visible close button, which is there for the pointer, is hidden from assistive technology with `aria-hidden` and `tabindex="-1"`. Each closable tab also gets a visually hidden button after the tab list, named "Close tab" plus the tab's title, which screen readers can reach and activate, including on touch devices. It's out of the Tab order too, since the keyboard's route is `Delete` or `Backspace`. Its text comes from `closeTab` in the `tabs` messages.
423
+
424
+ ## API
425
+
426
+ Everything below is imported from `@nanahoshi/mona-ui/tabs`.
427
+
428
+ ### `TabsComponent`
429
+
430
+ **Selector:** `mona-tabs`
431
+
432
+ #### Inputs
433
+
434
+ | Name | Type | Default | Description |
435
+ | --- | --- | --- | --- |
436
+ | `aria-label` | `string` | `""` | Accessible name for the tab list. |
437
+ | `aria-labelledby` | `string` | `""` | The id of an element that names the tab list. Takes precedence over `aria-label`. |
438
+ | `class` | `string` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
439
+ | `closable` | `boolean` | `false` | Displays a close button on each tab. A tab's own `closable` can add a button, not remove this one. |
440
+ | `disabled` | `boolean` | `false` | Renders every tab with reduced visual emphasis and removes pointer and keyboard interaction. |
441
+ | `keepTabContent` | `boolean` | `true` | Keeps a tab's content in the DOM after it is deselected instead of removing it. |
442
+ | `position` | `"bottom" \| "left" \| "right" \| "top"` | `"top"` | Placement of the tab list relative to the tab content. |
443
+ | `selectedIndex` (two-way) | `number` | `0` | The zero-based index of the selected tab. Writing it selects that tab, unless it's disabled or out of range, in which case the value goes back to the selected tab's index. It also changes when the component moves the selection itself, such as when the selected tab is removed. |
444
+ | `size` | `"large" \| "medium" \| "small"` | `"medium"` | Size preset controlling the tabs' dimensions. |
445
+
446
+ #### Outputs
447
+
448
+ | Name | Type | Description |
449
+ | --- | --- | --- |
450
+ | `selectedIndexChange` | `number` | Emitted when `selectedIndex` changes. |
451
+ | `tabClose` | `TabCloseEvent` | Emitted with a `TabCloseEvent` when a close is requested. The component doesn't remove the tab: remove it from whatever renders the `mona-tab` elements. |
452
+ | `tabSelect` | `TabSelectEvent` | Emitted with a `TabSelectEvent` before a click or key selects a tab. This event is preventable. It doesn't fire for selections made through `selectedIndex` or `selected`, or when the selected tab is removed. |
453
+
454
+ ### `TabComponent`
455
+
456
+ **Selector:** `mona-tab`
457
+
458
+ #### Inputs
459
+
460
+ | Name | Type | Default | Description |
461
+ | --- | --- | --- | --- |
462
+ | `closable` | `boolean` | `false` | Displays a close button on this tab. Turning it on here shows the button even when the parent `mona-tabs` has `closable` off; turning it off here doesn't hide a button the parent asked for. |
463
+ | `disabled` | `boolean` | `false` | Renders this tab with reduced visual emphasis and removes pointer and keyboard interaction. A tab is disabled when this or the parent `mona-tabs` component's `disabled` input is on. |
464
+ | `selected` (two-way) | `boolean` | `false` | Whether the tab is selected. Setting it to `true` selects the tab unless it's disabled, and it follows the selection, so `[(selected)]` stays current. Setting it to `false` doesn't clear the selection, because a group of tabs always keeps one selected. |
465
+ | `title` | `string` | `""` | Title text displayed on the tab. |
466
+
467
+ #### Outputs
468
+
469
+ | Name | Type | Description |
470
+ | --- | --- | --- |
471
+ | `selectedChange` | `boolean` | Emitted when `selected` changes. |
472
+
473
+ ### `TabContentTemplateDirective`
474
+
475
+ **Selector:** `ng-template[monaTabContentTemplate]`
476
+
477
+ ### `TabTitleTemplateDirective`
478
+
479
+ **Selector:** `ng-template[monaTabTitleTemplate]`
480
+
481
+ ### `TabCloseEvent`
482
+
483
+ **Extends:** `PreventableEvent`
484
+
485
+ #### Properties
486
+
487
+ | Name | Type | Description |
488
+ | --- | --- | --- |
489
+ | `index` (read-only) | `number` | Index of the tab a close was requested for. |
490
+ | `selected` (read-only) | `boolean` | Whether the tab a close was requested for was the selected tab. |
491
+
492
+ ### `TabSelectEvent`
493
+
494
+ **Extends:** `PreventableEvent`
495
+
496
+ #### Properties
497
+
498
+ | Name | Type | Description |
499
+ | --- | --- | --- |
500
+ | `index` (read-only) | `number` | Index of the tab being selected. |
501
+
502
+ ### Types
503
+
504
+ #### `TABS_DEFAULT_MESSAGES`
505
+
506
+ ```typescript
507
+ const TABS_DEFAULT_MESSAGES: MonaTabsMessages;
508
+ ```
509
+
510
+ #### `TabsPosition`
511
+
512
+ ```typescript
513
+ type TabsPosition = | "top" | "bottom" | "left" | "right";
514
+ ```
515
+
516
+ #### `MonaTabsMessages`
517
+
518
+ From `@nanahoshi/mona-ui/i18n`.
519
+
520
+ | Name | Type |
521
+ | --- | --- |
522
+ | `closeTab` (read-only) | `string` |
523
+ | `scrollNext` (read-only) | `string` |
524
+ | `scrollPrevious` (read-only) | `string` |
525
+
526
+ #### `PreventableEvent`
527
+
528
+ From `@nanahoshi/mona-ui/common`.
529
+
530
+ **Type parameters:** `E extends Event = Event`
531
+
532
+ | Name | Type | Description |
533
+ | --- | --- | --- |
534
+ | `originalEvent` (read-only) | `E \| undefined` | The DOM event that caused this one, when there is one. |
535
+ | `type` (read-only) | `string \| undefined` | A name for the kind of event, when the component that emits it sets one. |
536
+
537
+ **Methods**
538
+
539
+ | Signature | Description |
540
+ | --- | --- |
541
+ | `isDefaultPrevented(): boolean` | Whether `preventDefault()` was called. |
542
+ | `preventDefault(): void` | Cancels what the event announces, such as opening or closing a popup, or closing a dialog. |