@fibrae/semi-ui-svelte 0.9.1 → 0.10.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 (165) hide show
  1. package/README.md +8 -4
  2. package/README.zh-CN.md +8 -4
  3. package/dist/components/anchor/interface.d.ts +14 -0
  4. package/dist/components/audio-player/interface.d.ts +5 -0
  5. package/dist/components/auto-complete/interface.d.ts +29 -0
  6. package/dist/components/avatar/interface.d.ts +24 -0
  7. package/dist/components/backtop/interface.d.ts +2 -0
  8. package/dist/components/badge/interface.d.ts +7 -0
  9. package/dist/components/banner/interface.d.ts +7 -0
  10. package/dist/components/breadcrumb/interface.d.ts +10 -0
  11. package/dist/components/button/interface.d.ts +18 -0
  12. package/dist/components/calendar/interface.d.ts +16 -0
  13. package/dist/components/card/interface.d.ts +18 -0
  14. package/dist/components/carousel/interface.d.ts +16 -0
  15. package/dist/components/cascader/interface.d.ts +57 -0
  16. package/dist/components/checkbox/interface.d.ts +19 -0
  17. package/dist/components/code-highlight/interface.d.ts +3 -0
  18. package/dist/components/collapse/interface.d.ts +16 -0
  19. package/dist/components/collapsible/interface.d.ts +10 -0
  20. package/dist/components/color-picker/interface.d.ts +10 -0
  21. package/dist/components/config-provider/interface.d.ts +7 -0
  22. package/dist/components/cropper/interface.d.ts +11 -0
  23. package/dist/components/date-picker/interface.d.ts +47 -0
  24. package/dist/components/descriptions/interface.d.ts +6 -0
  25. package/dist/components/divider/interface.d.ts +4 -0
  26. package/dist/components/dropdown/interface.d.ts +8 -0
  27. package/dist/components/empty/interface.d.ts +7 -0
  28. package/dist/components/feedback/interface.d.ts +16 -0
  29. package/dist/components/float-button/interface.d.ts +14 -0
  30. package/dist/components/form/interface.d.ts +47 -0
  31. package/dist/components/grid/interface.d.ts +13 -0
  32. package/dist/components/highlight/interface.d.ts +7 -0
  33. package/dist/components/hot-keys/interface.d.ts +3 -0
  34. package/dist/components/image/interface.d.ts +59 -0
  35. package/dist/components/input/interface.d.ts +67 -0
  36. package/dist/components/input-number/interface.d.ts +24 -0
  37. package/dist/components/json-viewer/interface.d.ts +7 -0
  38. package/dist/components/layout/interface.d.ts +3 -0
  39. package/dist/components/list/interface.d.ts +18 -0
  40. package/dist/components/locale/interface.d.ts +4 -0
  41. package/dist/components/lottie/interface.d.ts +2 -0
  42. package/dist/components/markdown-render/interface.d.ts +5 -0
  43. package/dist/components/modal/interface.d.ts +29 -0
  44. package/dist/components/navigation/interface.d.ts +47 -0
  45. package/dist/components/overflow-list/interface.d.ts +11 -0
  46. package/dist/components/pagination/interface.d.ts +12 -0
  47. package/dist/components/pincode/interface.d.ts +8 -0
  48. package/dist/components/popconfirm/interface.d.ts +12 -0
  49. package/dist/components/popover/interface.d.ts +30 -0
  50. package/dist/components/progress/interface.d.ts +13 -0
  51. package/dist/components/radio/interface.d.ts +22 -0
  52. package/dist/components/rating/interface.d.ts +12 -0
  53. package/dist/components/resizable/interface.d.ts +30 -0
  54. package/dist/components/scroll-list/interface.d.ts +6 -0
  55. package/dist/components/select/interface.d.ts +63 -0
  56. package/dist/components/side-sheet/interface.d.ts +19 -0
  57. package/dist/components/skeleton/interface.d.ts +7 -0
  58. package/dist/components/slider/interface.d.ts +23 -0
  59. package/dist/components/space/interface.d.ts +4 -0
  60. package/dist/components/spin/interface.d.ts +7 -0
  61. package/dist/components/steps/interface.d.ts +9 -0
  62. package/dist/components/switch/interface.d.ts +7 -0
  63. package/dist/components/table/interface.d.ts +48 -0
  64. package/dist/components/tabs/interface.d.ts +29 -0
  65. package/dist/components/tag/interface.d.ts +22 -0
  66. package/dist/components/tag-input/interface.d.ts +29 -0
  67. package/dist/components/time-picker/interface.d.ts +31 -0
  68. package/dist/components/timeline/interface.d.ts +5 -0
  69. package/dist/components/tooltip/interface.d.ts +20 -0
  70. package/dist/components/transfer/interface.d.ts +18 -0
  71. package/dist/components/tree/interface.d.ts +45 -0
  72. package/dist/components/tree-select/interface.d.ts +55 -0
  73. package/dist/components/typography/interface.d.ts +33 -0
  74. package/dist/components/upload/interface.d.ts +64 -0
  75. package/dist/components/user-guide/interface.d.ts +15 -0
  76. package/dist/components/video-player/interface.d.ts +22 -0
  77. package/docs/advanced/dark-mode.md +288 -0
  78. package/docs/basic/button.md +605 -0
  79. package/docs/basic/divider.md +103 -0
  80. package/docs/basic/float-button.md +246 -0
  81. package/docs/basic/grid.md +427 -0
  82. package/docs/basic/layout.md +459 -0
  83. package/docs/basic/resizable.md +584 -0
  84. package/docs/basic/space.md +163 -0
  85. package/docs/basic/tokens.md +425 -0
  86. package/docs/basic/typography.md +615 -0
  87. package/docs/changes-from-semi.md +105 -0
  88. package/docs/ecosystem/tailwind.md +210 -0
  89. package/docs/experience/accessibility.md +82 -0
  90. package/docs/experience/content-guidelines.md +819 -0
  91. package/docs/experience/internationalization.md +7 -0
  92. package/docs/feedback/banner.md +198 -0
  93. package/docs/feedback/feedback.md +294 -0
  94. package/docs/feedback/notification.md +401 -0
  95. package/docs/feedback/popconfirm.md +243 -0
  96. package/docs/feedback/progress.md +389 -0
  97. package/docs/feedback/skeleton.md +388 -0
  98. package/docs/feedback/spin.md +172 -0
  99. package/docs/feedback/toast.md +393 -0
  100. package/docs/input/auto-complete.md +399 -0
  101. package/docs/input/cascader.md +1558 -0
  102. package/docs/input/checkbox.md +408 -0
  103. package/docs/input/color-picker.md +175 -0
  104. package/docs/input/date-picker.md +942 -0
  105. package/docs/input/form.md +2550 -0
  106. package/docs/input/input-number.md +451 -0
  107. package/docs/input/input.md +640 -0
  108. package/docs/input/pincode.md +191 -0
  109. package/docs/input/radio.md +337 -0
  110. package/docs/input/rating.md +214 -0
  111. package/docs/input/select.md +1230 -0
  112. package/docs/input/slider.md +347 -0
  113. package/docs/input/switch.md +206 -0
  114. package/docs/input/tag-input.md +465 -0
  115. package/docs/input/time-picker.md +358 -0
  116. package/docs/input/transfer.md +1061 -0
  117. package/docs/input/tree-select.md +1300 -0
  118. package/docs/input/upload.md +1811 -0
  119. package/docs/llms.txt +147 -0
  120. package/docs/navigation/anchor.md +377 -0
  121. package/docs/navigation/backtop.md +100 -0
  122. package/docs/navigation/breadcrumb.md +284 -0
  123. package/docs/navigation/navigation.md +851 -0
  124. package/docs/navigation/pagination.md +217 -0
  125. package/docs/navigation/steps.md +315 -0
  126. package/docs/navigation/tabs.md +754 -0
  127. package/docs/navigation/tree.md +1956 -0
  128. package/docs/other/config-provider.md +599 -0
  129. package/docs/other/locale.md +353 -0
  130. package/docs/plus/audio-player.md +155 -0
  131. package/docs/plus/code-highlight.md +150 -0
  132. package/docs/plus/drag-move.md +214 -0
  133. package/docs/plus/hot-keys.md +174 -0
  134. package/docs/plus/json-viewer.md +392 -0
  135. package/docs/plus/lottie.md +176 -0
  136. package/docs/plus/markdown-render.md +240 -0
  137. package/docs/plus/video-player.md +325 -0
  138. package/docs/show/avatar.md +475 -0
  139. package/docs/show/badge.md +276 -0
  140. package/docs/show/calendar.md +352 -0
  141. package/docs/show/card.md +485 -0
  142. package/docs/show/carousel.md +592 -0
  143. package/docs/show/collapse.md +289 -0
  144. package/docs/show/collapsible.md +216 -0
  145. package/docs/show/cropper.md +285 -0
  146. package/docs/show/descriptions.md +325 -0
  147. package/docs/show/dropdown.md +466 -0
  148. package/docs/show/empty.md +225 -0
  149. package/docs/show/highlight.md +144 -0
  150. package/docs/show/image.md +433 -0
  151. package/docs/show/list.md +927 -0
  152. package/docs/show/modal.md +517 -0
  153. package/docs/show/overflow-list.md +272 -0
  154. package/docs/show/popover.md +534 -0
  155. package/docs/show/scroll-list.md +156 -0
  156. package/docs/show/side-sheet.md +274 -0
  157. package/docs/show/table.md +5437 -0
  158. package/docs/show/tag.md +428 -0
  159. package/docs/show/timeline.md +277 -0
  160. package/docs/show/tooltip.md +442 -0
  161. package/docs/show/user-guide.md +419 -0
  162. package/docs/start/getting-started.md +234 -0
  163. package/docs/start/introduction.md +57 -0
  164. package/docs/start/overview.md +21 -0
  165. package/package.json +5 -4
@@ -0,0 +1,754 @@
1
+ # Tabs
2
+
3
+ > When the content needs to be grouped and displayed in different modules or pages, you could use Tabs to switch between different groups or pages
4
+
5
+ Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/navigation/tabs/
6
+
7
+ ## Demos
8
+
9
+ ### How to import
10
+
11
+ ```svelte
12
+ <script lang="ts">
13
+ import { Tabs } from '@fibrae/semi-ui-svelte';
14
+ </script>
15
+ ```
16
+
17
+ ### Basic Usage
18
+
19
+ Tabs supports four types of styles: `line`, `button`, `card`, and `slash`. By default, the first enabled tab is selected.
20
+
21
+ Tabs supports two declare ways, and the rendering process of the two is different:
22
+
23
+ - Pass the array of objects through `tabList`, when using `tabList`, only render the currently passed node each time
24
+ - Or use `<TabPane>` to explicitly pass in item by item. When using `<TabPane>`, all panels will be rendered by default. You can set `keepDOM` to `false` to only render the current panel, and there will be no animation effect at this time.
25
+
26
+ > **Notice**
27
+ >
28
+ > 1. When tabList and TabPane Children are used at the same time, the data passed in through tabList will be rendered first. It is not recommended to configure both
29
+ > 2. When using TabPane Children, TabPane must be a direct child element of Tabs, otherwise Tabs will not be able to correctly collect related attributes such as itemKey and other subcomponents
30
+
31
+ Svelte has no `TabPane`; tabs are passed through `tabList` only. The items of `tabList` hold data only (`itemKey`, `tab`, `disabled`, `closable`); for markup use the `tab` and `icon` snippets of Tabs, which receive `{ item, index }`. Without a `tab` snippet the `tab` text of the item is shown. Write the content in the `panel` snippet, which receives `{ item, index, itemKey }`: every tab is its own tabpanel, and `keepDOM`, `lazyRender` and motion apply to it. Without `panel`, the `children` of Tabs are the content of the active tab. Bind `activeKey` with `bind:activeKey`; there is no `defaultActiveKey`, so write the initial value as `activeKey="1"`.
32
+
33
+ ```svelte
34
+ <script lang="ts">
35
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
36
+
37
+ const tabList: PlainTab[] = [
38
+ { itemKey: '1', tab: '文档' },
39
+ { itemKey: '2', tab: '快速起步' },
40
+ { itemKey: '3', tab: '帮助' },
41
+ ];
42
+ const paragraphStyle = 'line-height: 1.8';
43
+ const questionStyle = 'line-height: 1.8; color: var(--semi-color-text-0); font-weight: 600';
44
+ const answerStyle = 'line-height: 1.8; color: var(--semi-color-text-1)';
45
+ const codeStyle = 'margin: 24px 0; padding: 20px; border: none; white-space: normal; border-radius: var(--semi-border-radius-medium); color: var(--semi-color-text-1); background-color: var(--semi-color-fill-0)';
46
+ </script>
47
+
48
+ <div>
49
+ <Tabs {tabList} type="line">
50
+ {#snippet panel(pane)}
51
+ {#if pane.itemKey === '1'}
52
+ <h3>文档</h3>
53
+ <p style={paragraphStyle}>Semi Design Next 是 Semi Design 的社区版设计系统,一套组件在 React、Vue、Solid、Svelte 中原生可用。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。</p>
54
+ <p style={paragraphStyle}>区别于其他的设计系统而言,Semi Design 以用户中心、内容优先、设计人性化为设计理念,具有以下优势:</p>
55
+ <ul>
56
+ <li>
57
+ <p>Semi Design 以内容优先进行设计。</p>
58
+ </li>
59
+ <li>
60
+ <p>更容易地自定义主题。</p>
61
+ </li>
62
+ <li>
63
+ <p>适用国际化场景。</p>
64
+ </li>
65
+ <li>
66
+ <p>效率场景加入人性化关怀。</p>
67
+ </li>
68
+ </ul>
69
+ {:else if pane.itemKey === '2'}
70
+ <h3>快速起步</h3>
71
+ <pre style={codeStyle}><code>yarn add @fibrae/semi-ui-svelte</code></pre>
72
+ {:else}
73
+ <h3>帮助</h3>
74
+ <p style={questionStyle}>Q:有新组件需求、或者现有组件feature不能满足业务需求?</p>
75
+ <p style={answerStyle}>右上角问题反馈,提交issue,label选择Feature Request / New Component Request 我们会高优处理这些需求。</p>
76
+ <p style={questionStyle}>Q:对组件的使用有疑惑?</p>
77
+ <p style={answerStyle}>欢迎进我们的客服lark群进行咨询提问。</p>
78
+ {/if}
79
+ {/snippet}
80
+ </Tabs>
81
+ </div>
82
+ ```
83
+
84
+ ```svelte
85
+ <script lang="ts">
86
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
87
+
88
+ const tabList: PlainTab[] = [
89
+ { itemKey: '1', tab: '文档' },
90
+ { itemKey: '2', tab: '快速起步' },
91
+ { itemKey: '3', tab: '帮助' },
92
+ ];
93
+ </script>
94
+
95
+ <Tabs {tabList} type="button">
96
+ {#snippet panel(pane)}{pane.item.tab}{/snippet}
97
+ </Tabs>
98
+ ```
99
+
100
+ ```svelte
101
+ <script lang="ts">
102
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
103
+
104
+ const contentList = ['文档', '快速起步', '帮助'];
105
+ const tabList: PlainTab[] = [
106
+ { tab: '文档', itemKey: '1' },
107
+ { tab: '快速起步', itemKey: '2' },
108
+ { tab: '帮助', itemKey: '3' },
109
+ ];
110
+ let key = $state<string | null | undefined>('1');
111
+ </script>
112
+
113
+ <Tabs bind:activeKey={key} {tabList} type="card">
114
+ <div>{contentList[Number(key) - 1]}</div>
115
+ </Tabs>
116
+ ```
117
+
118
+ ```svelte
119
+ <script lang="ts">
120
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
121
+
122
+ const contentList = ['文档', '快速起步', '帮助'];
123
+ const tabList: PlainTab[] = [
124
+ { tab: '文档', itemKey: '1' },
125
+ { tab: '快速起步', itemKey: '2' },
126
+ { tab: '帮助', itemKey: '3' },
127
+ ];
128
+ let key = $state<string | null | undefined>('1');
129
+ </script>
130
+
131
+ <Tabs bind:activeKey={key} {tabList} type="slash">
132
+ <div>{contentList[Number(key) - 1]}</div>
133
+ </Tabs>
134
+ ```
135
+
136
+ ### With Icon
137
+
138
+ ```svelte
139
+ <script lang="ts">
140
+ import { IconFile, IconGlobe, IconHelpCircle } from '@fibrae/semi-icons-svelte';
141
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
142
+
143
+ const tabList: PlainTab[] = [
144
+ { itemKey: '1', tab: '文档' },
145
+ { itemKey: '2', tab: '快速起步' },
146
+ { itemKey: '3', tab: '帮助' },
147
+ ];
148
+ const icons = { '1': IconFile, '2': IconGlobe, '3': IconHelpCircle } as const;
149
+ </script>
150
+
151
+ <Tabs {tabList}>
152
+ {#snippet tab(tabItem)}
153
+ {@const Icon = icons[tabItem.item.itemKey as keyof typeof icons]}
154
+ <span><Icon />{tabItem.item.tab}</span>
155
+ {/snippet}
156
+ {#snippet panel(pane)}{pane.item.tab}{/snippet}
157
+ </Tabs>
158
+ ```
159
+
160
+ ### More with Dropdown
161
+
162
+ Supports merging redundant tabs into a `more` drop-down menu. Just pass in a number for `more`. The number represents the number of tabs included in the drop-down menu.
163
+
164
+ ```svelte
165
+ <script lang="ts">
166
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
167
+
168
+ const tabList: PlainTab[] = Array.from({ length: 10 }, (_, i) => ({ itemKey: `Tab-${i}`, tab: `Tab-${i}` }));
169
+ </script>
170
+
171
+ <Tabs more={4} style="width: 60%; margin: 20px" {tabList} type="card">
172
+ {#snippet panel(pane)}Content of card tab {pane.index}{/snippet}
173
+ </Tabs>
174
+ ```
175
+
176
+ Advanced configuration is also supported, passing the object to `more`, and it can be passed in
177
+
178
+ - `count`: Represents the number of Tabs in the income drop-down menu
179
+ - `dropdownProps`: Dropdown props, passed through to the drop-down menu
180
+
181
+ Customize the "More" trigger with the `moreTrigger` snippet, and the content of the drop-down menu with the `moreContent` snippet, whose `{ items }` are the tabs moved into the menu.
182
+
183
+ ```svelte
184
+ <script lang="ts">
185
+ import { Button, Tabs, type PlainTab, type TabsMore } from '@fibrae/semi-ui-svelte';
186
+
187
+ const tabList: PlainTab[] = Array.from({ length: 10 }, (_, i) => ({ itemKey: `Tab-${i}`, tab: `Tab-${i}` }));
188
+ const more: TabsMore = { count: 4, dropdownProps: { trigger: 'click', position: 'bottomRight' } };
189
+ </script>
190
+
191
+ <Tabs {more} style="width: 60%; margin: 20px" {tabList} type="card">
192
+ {#snippet moreTrigger()}
193
+ <Button type="tertiary">Click to show More</Button>
194
+ {/snippet}
195
+ {#snippet panel(pane)}Content of card tab {pane.index}{/snippet}
196
+ </Tabs>
197
+ ```
198
+
199
+ ### Vertical mode
200
+
201
+ When `type` is `line`, `card`, or `button`, horizontal and vertical modes are supported, `tabPosition='left|top'`,default is top. When `type` is `slash`, only horizontal mode is supported.
202
+
203
+ ```svelte
204
+ <script lang="ts">
205
+ import { IconFile, IconGlobe, IconHelpCircle } from '@fibrae/semi-icons-svelte';
206
+ import { Radio, RadioGroup, Tabs, type PlainTab, type RadioValue, type TabType } from '@fibrae/semi-ui-svelte';
207
+
208
+ let value = $state<RadioValue | undefined>('line');
209
+ const type = $derived(value as TabType);
210
+ const tabList: PlainTab[] = [
211
+ { itemKey: '1', tab: '文档' },
212
+ { itemKey: '2', tab: '快速起步' },
213
+ { itemKey: '3', tab: '帮助' },
214
+ ];
215
+ const icons = { '1': IconFile, '2': IconGlobe, '3': IconHelpCircle } as const;
216
+ const contentStyle = 'padding: 0 24px';
217
+ const paragraphStyle = 'line-height: 1.8';
218
+ const questionStyle = 'line-height: 1.8; color: var(--semi-color-text-0); font-weight: 600';
219
+ const answerStyle = 'line-height: 1.8; color: var(--semi-color-text-1)';
220
+ const codeStyle = 'margin: 24px 0; padding: 20px; border: none; white-space: normal; border-radius: 6px; color: var(--semi-color-text-1); background-color: var(--semi-color-fill-0)';
221
+ </script>
222
+
223
+ <RadioGroup bind:value style="display: flex; width: 200px; justify-content: center" type="button">
224
+ <Radio value="line">Line</Radio>
225
+ <Radio value="card">Card</Radio>
226
+ <Radio value="button">Button</Radio>
227
+ </RadioGroup>
228
+ <br />
229
+ <br />
230
+ <Tabs {tabList} tabPosition="left" {type}>
231
+ {#snippet tab(tabItem)}
232
+ {@const Icon = icons[tabItem.item.itemKey as keyof typeof icons]}
233
+ <span><Icon />{tabItem.item.tab}</span>
234
+ {/snippet}
235
+ {#snippet panel(pane)}
236
+ <div style={contentStyle}>
237
+ {#if pane.itemKey === '1'}
238
+ <h3>文档</h3>
239
+ <p style={paragraphStyle}>Semi Design Next 是 Semi Design 的社区版设计系统,一套组件在 React、Vue、Solid、Svelte 中原生可用。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的 Web 应用。</p>
240
+ <p style={paragraphStyle}>区别于其他的设计系统而言,Semi Design 以用户中心、内容优先、设计人性化为设计理念,具有以下优势:</p>
241
+ {:else if pane.itemKey === '2'}
242
+ <h3>快速起步</h3>
243
+ <pre style={codeStyle}><code>yarn add @fibrae/semi-ui-svelte</code></pre>
244
+ {:else}
245
+ <h3>帮助</h3>
246
+ <p style={questionStyle}>Q:有新组件需求、或者现有组件feature不能满足业务需求?</p>
247
+ <p style={answerStyle}>右上角问题反馈,提交issue,label选择Feature Request / New Component Request 我们会高优处理这些需求。</p>
248
+ <p style={questionStyle}>Q:对组件的使用有疑惑?</p>
249
+ <p style={answerStyle}>欢迎进我们的客服lark群进行咨询提问。</p>
250
+ {/if}
251
+ </div>
252
+ {/snippet}
253
+ </Tabs>
254
+ ```
255
+
256
+ ### Scrollable Tabs
257
+
258
+ You could use `collapsible` for a scrollable tabs with dropdown menu. Horizontal mode only.
259
+
260
+ ```svelte
261
+ <script lang="ts">
262
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
263
+
264
+ const tabList: PlainTab[] = Array.from({ length: 10 }, (_, i) => ({ itemKey: `Tab-${i}`, tab: `Tab-${i}` }));
265
+ </script>
266
+
267
+ <Tabs collapsible style="width: 60%; margin: 20px" {tabList} type="card">
268
+ {#snippet panel(pane)}Content of card tab {pane.index}{/snippet}
269
+ </Tabs>
270
+ ```
271
+
272
+ **Modify the scrolling rendering Arrow**
273
+
274
+ The `arrow` snippet modifies the arrows in collapsible mode. It receives `{ items, position, onClick, defaultNode }`: the overflowed tabs, the position, the click function and the default arrow `defaultNode` (render it with `{@render defaultNode()}`).
275
+
276
+ ```svelte
277
+ <script lang="ts">
278
+ import { Dropdown, Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
279
+
280
+ let activeKey = $state<string | null | undefined>('Tab-0');
281
+ const tabList: PlainTab[] = Array.from({ length: 10 }, (_, i) => ({ itemKey: `Tab-${i}`, tab: `Tab-${i}` }));
282
+ const arrowStyle = 'width: 32px; height: 32px; margin: 0 12px; display: flex; justify-content: center; align-items: center; padding: 0; border: none; border-radius: 100%; background: var(--semi-grey-1); color: var(--semi-color-text); font-family: inherit; font-size: inherit; cursor: pointer';
283
+ </script>
284
+
285
+ <Tabs bind:activeKey collapsible style="width: 50%; margin: 20px" {tabList} type="card">
286
+ {#snippet arrow(arrowProps)}
287
+ <Dropdown>
288
+ {#snippet child(trigger)}
289
+ <button {...trigger.props} style={arrowStyle} type="button" onclick={arrowProps.onClick}>
290
+ {arrowProps.position === 'start' ? '←' : '→'}
291
+ </button>
292
+ {/snippet}
293
+ {#snippet content()}
294
+ <Dropdown.Menu>
295
+ {#each arrowProps.items as item (item.itemKey)}
296
+ <Dropdown.Item onclick={() => (activeKey = item.itemKey)}>{item.itemKey}</Dropdown.Item>
297
+ {/each}
298
+ </Dropdown.Menu>
299
+ {/snippet}
300
+ </Dropdown>
301
+ {/snippet}
302
+ {#snippet panel(pane)}Content of card tab {pane.index}{/snippet}
303
+ </Tabs>
304
+ ```
305
+
306
+ **Modify Arrow rendering position**
307
+
308
+ Use `arrowPosition` to modify the overflow indicator position, optional start both end
309
+
310
+ ```svelte
311
+ <script lang="ts">
312
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
313
+
314
+ const positions = ['start', 'both', 'end'] as const;
315
+ const tabList: PlainTab[] = Array.from({ length: 10 }, (_, i) => ({ itemKey: `Tab-${i}`, tab: `Tab-${i}` }));
316
+ </script>
317
+
318
+ {#each positions as position (position)}
319
+ <Tabs arrowPosition={position} collapsible style="width: 60%; margin: 20px" {tabList} type="card">
320
+ {#snippet panel(pane)}Content of card tab {pane.index}{/snippet}
321
+ </Tabs>
322
+ {/each}
323
+ ```
324
+
325
+ ### Auto Overflow Detection
326
+
327
+ Set `collapsible="auto"` to enable automatic overflow detection. The component will automatically detect whether tabs overflow the container:
328
+
329
+ - When tabs exceed the container width or wrap to multiple lines, it automatically enables collapse mode (shows left/right arrows)
330
+ - When the container width increases or tab count decreases and all tabs can be fully displayed, it automatically exits collapse mode
331
+
332
+ This feature eliminates the need for developers to manually determine whether folding is needed, making it especially suitable for responsive layouts.
333
+
334
+ ```svelte
335
+ <script lang="ts">
336
+ import { Button, Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
337
+
338
+ const boxStyle = 'border: 1px solid var(--semi-color-border); padding: 12px';
339
+ const noteStyle = 'margin-block-end: 8px; color: var(--semi-color-text-2); font-size: 12px';
340
+
341
+ let count = $state(8);
342
+ const tabList = $derived<PlainTab[]>(Array.from({ length: count }, (_, i) => ({ itemKey: `${i}`, tab: `Tab-${i + 1}` })));
343
+ </script>
344
+
345
+ {#snippet panel(pane: { index: number })}Content of Tab {pane.index + 1}{/snippet}
346
+
347
+ <div>
348
+ <div style="margin-block-end: 12px">
349
+ <Button style="margin-inline-end: 8px" onclick={() => (count = Math.max(3, count - 2))}>减少 Tab</Button>
350
+ <Button onclick={() => (count = Math.min(15, count + 2))}>增加 Tab</Button>
351
+ <span style="margin-inline-start: 12px">当前 Tab 数量: {count}</span>
352
+ </div>
353
+
354
+ <div style={`${boxStyle}; margin-block-end: 16px`}>
355
+ <p style={noteStyle}>collapsible="auto" - 自动检测溢出</p>
356
+ <Tabs collapsible="auto" {panel} {tabList} type="card" />
357
+ </div>
358
+
359
+ <div style={`${boxStyle}; max-width: 400px`}>
360
+ <p style={noteStyle}>固定宽度 400px,测试较窄容器</p>
361
+ <Tabs collapsible="auto" {panel} {tabList} type="card" />
362
+ </div>
363
+ </div>
364
+ ```
365
+
366
+ ### Disable
367
+
368
+ Disable one tab.
369
+
370
+ ```svelte
371
+ <script lang="ts">
372
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
373
+
374
+ const tabList: PlainTab[] = [
375
+ { itemKey: '1', tab: '文档' },
376
+ { itemKey: '2', tab: '快速起步', disabled: true },
377
+ { itemKey: '3', tab: '帮助' },
378
+ ];
379
+ </script>
380
+
381
+ <Tabs activeKey="1" {tabList}>
382
+ {#snippet panel(pane)}{pane.item.tab}{/snippet}
383
+ </Tabs>
384
+ ```
385
+
386
+ ### Extra Content
387
+
388
+ Use the `tabBarExtraContent` snippet to add extra content on the right side of tabBar.
389
+
390
+ ```svelte
391
+ <script lang="ts">
392
+ import { Button, Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
393
+
394
+ const tabList: PlainTab[] = [
395
+ { itemKey: '1', tab: '文档' },
396
+ { itemKey: '2', tab: '快速起步' },
397
+ { itemKey: '3', tab: '帮助' },
398
+ ];
399
+
400
+ const onExtraClick = () => {
401
+ alert('you have clicked me!');
402
+ };
403
+ </script>
404
+
405
+ <Tabs activeKey="1" {tabList}>
406
+ {#snippet tabBarExtraContent()}
407
+ <Button onclick={onExtraClick}>Extra Action</Button>
408
+ {/snippet}
409
+ {#snippet panel(pane)}{pane.item.tab}{/snippet}
410
+ </Tabs>
411
+ ```
412
+
413
+ ### Custom Render
414
+
415
+ Use the `tabBar` snippet, which receives `{ tabBarProps, tabBar }`, to customize the tab bar. `tabBarProps` holds data only (see TabBarProps below) and `tabBar` is the default tab bar, rendered with `{@render tabBar()}`.
416
+
417
+ When `tabBar` replaces the bar entirely, the `aria-label` and `aria-labelledby` of Tabs do not reach your own element: put the accessible name on your own `role="tablist"` element.
418
+
419
+ ```svelte
420
+ <script lang="ts">
421
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
422
+
423
+ const tabList: PlainTab[] = [
424
+ { itemKey: '1', tab: '文档' },
425
+ { itemKey: '2', tab: '快速起步' },
426
+ { itemKey: '3', tab: '帮助' },
427
+ ];
428
+ </script>
429
+
430
+ <Tabs activeKey="1" {tabList}>
431
+ {#snippet tabBar(bar)}
432
+ <div class="tab-bar-box">
433
+ 这是二次封装的Tab Bar,当前ActiveKey:{bar.tabBarProps.activeKey}
434
+ {@render bar.tabBar()}
435
+ </div>
436
+ {/snippet}
437
+ {#snippet panel(pane)}{pane.item.tab}{/snippet}
438
+ </Tabs>
439
+ ```
440
+
441
+ ### Drag and Drop Reordering
442
+
443
+ Through the `tabBar` snippet, render the tabs with `TabItem` inside your own `role="tablist"` element and combine them with dragging to reorder the tab bar. Inside a Tabs a `TabItem` selects its tab on click by itself, and native attributes and listeners such as `draggable` and the drag events land on its root element. The demo uses native browser drag and drop, which supports pointer input only; when you need keyboard sorting, use a drag library with keyboard support instead.
444
+
445
+ ```svelte
446
+ <script lang="ts">
447
+ import { TabItem } from '@fibrae/semi-ui-svelte';
448
+ </script>
449
+ ```
450
+
451
+ ```svelte
452
+ <script lang="ts">
453
+ import { TabItem, Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
454
+
455
+ let activeKey = $state<string | null | undefined>('1');
456
+ let tabList = $state<PlainTab[]>([
457
+ { itemKey: '1', tab: '文档' },
458
+ { itemKey: '2', tab: '表格' },
459
+ { itemKey: '3', tab: '幻灯片' },
460
+ { itemKey: '4', tab: '表单' },
461
+ ]);
462
+ const contents: Record<string, string> = { '1': '文档内容', '2': '表格内容', '3': '幻灯片内容', '4': '表单内容' };
463
+
464
+ // HTML5 drag and drop on the TabItems: the website has no sortable library for Svelte, and a sortable list would wrap
465
+ // each tab in a button-role element that nests focusable tabs. Known limit: pointer only; use a sortable library for keyboard sorting.
466
+ let draggingKey = $state<string | null>(null);
467
+ const moveTo = (targetKey: string) => {
468
+ const from = tabList.findIndex((item) => item.itemKey === draggingKey);
469
+ const to = tabList.findIndex((item) => item.itemKey === targetKey);
470
+ if (from < 0 || to < 0 || from === to) return;
471
+ const next = [...tabList];
472
+ const [moved] = next.splice(from, 1);
473
+ next.splice(to, 0, moved);
474
+ tabList = next;
475
+ };
476
+ </script>
477
+
478
+ <Tabs bind:activeKey {tabList} type="line">
479
+ <!-- the bar keeps Semi's own .semi-tabs-bar shell; the TabItems inside select their Tabs by themselves -->
480
+ {#snippet tabBar()}
481
+ <div aria-orientation="horizontal" class="semi-tabs-bar semi-tabs-bar-line semi-tabs-bar-top" role="tablist">
482
+ {#each tabList as item (item.itemKey)}
483
+ <TabItem
484
+ draggable="true"
485
+ itemKey={item.itemKey}
486
+ selected={activeKey === item.itemKey}
487
+ style={`cursor: grab; opacity: ${draggingKey === item.itemKey ? 0.5 : 1}; display: inline-flex`}
488
+ ondragend={() => (draggingKey = null)}
489
+ ondragenter={(event) => {
490
+ event.preventDefault();
491
+ moveTo(item.itemKey);
492
+ }}
493
+ ondragover={(event) => event.preventDefault()}
494
+ ondragstart={() => (draggingKey = item.itemKey)}
495
+ >
496
+ {#snippet tab()}{item.tab}{/snippet}
497
+ </TabItem>
498
+ {/each}
499
+ </div>
500
+ {/snippet}
501
+ {#snippet panel(pane)}
502
+ <div style="padding: 20px">{contents[pane.itemKey]}</div>
503
+ {/snippet}
504
+ </Tabs>
505
+ ```
506
+
507
+ ### Dynamic Update
508
+
509
+ You can add events to update tabBar dynamically.
510
+
511
+ ```svelte
512
+ <script lang="ts">
513
+ import { Button, ButtonGroup, Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
514
+
515
+ let newTabIndex = 0;
516
+ let tabList = $state<PlainTab[]>([
517
+ { tab: 'Tab 1', itemKey: '1' },
518
+ { tab: 'Tab 2', itemKey: '2' },
519
+ ]);
520
+ const contents: Record<string, string> = { '1': 'Content of Tab Pane 1', '2': 'Content of Tab Pane 2' };
521
+ let activeKey = $state<string | null | undefined>('1');
522
+
523
+ const add = () => {
524
+ const index = newTabIndex++;
525
+ tabList = [...tabList, { tab: `New Tab ${index}`, itemKey: `newTab${index}` }];
526
+ activeKey = `newTab${index}`;
527
+ };
528
+
529
+ const remove = () => {
530
+ if (tabList.length > 1) {
531
+ tabList = tabList.slice(0, -1);
532
+ activeKey = tabList[tabList.length - 1].itemKey;
533
+ }
534
+ };
535
+ </script>
536
+
537
+ <Tabs bind:activeKey {tabList}>
538
+ {#snippet tabBarExtraContent()}
539
+ <ButtonGroup>
540
+ <Button onclick={add}>新增</Button>
541
+ <Button onclick={remove}>删除</Button>
542
+ </ButtonGroup>
543
+ {/snippet}
544
+ {#snippet panel(pane)}{contents[pane.itemKey] ?? 'New Tab Pane'}{/snippet}
545
+ </Tabs>
546
+ ```
547
+
548
+ ### Closeable
549
+
550
+ Close a tab in the tab bar. All four tab styles support the close option; set `closable` on the tab to turn it on. A disabled tab cannot be closed. The caller removes the tab in the close callback.
551
+
552
+ ```svelte
553
+ <script lang="ts">
554
+ import { Tabs, type PlainTab } from '@fibrae/semi-ui-svelte';
555
+
556
+ let tabList = $state<PlainTab[]>([
557
+ { tab: '文档', itemKey: '1', closable: true },
558
+ { tab: '快速起步', itemKey: '2', closable: true },
559
+ { tab: '帮助', itemKey: '3', closable: false },
560
+ ]);
561
+
562
+ const close = (key: string) => {
563
+ tabList = tabList.filter((t) => t.itemKey !== key);
564
+ };
565
+ </script>
566
+
567
+ <Tabs onTabClose={close} {tabList} type="card">
568
+ {#snippet panel(pane)}{pane.item.tab}{/snippet}
569
+ </Tabs>
570
+ ```
571
+
572
+ ## API Reference
573
+
574
+ ### Tab
575
+
576
+ **Props**
577
+
578
+ | Property | Description | Type | Default |
579
+ | - | - | - | - |
580
+ | activeKey | The itemKey of the active tab, bound with `bind:activeKey`. `null` activates no tab and is still controlled; omitted or `undefined` means uncontrolled, with the first enabled tab selected. | `string \| null` | - |
581
+ | arrow | Snippet that replaces each scroll arrow in collapsible mode, with `{ items, position, onClick, defaultNode }`: the scrolled-out tabs, the position, the click handler and the default arrow (render it with `{@render defaultNode()}`). | `Snippet<[TabsArrowSnippetProps]>` | - |
582
+ | arrowPosition | Position of the scroll arrows in collapsible mode. | `'both' \| 'end' \| 'start'` | `"both"` |
583
+ | children | The content area when there is no `panel`: the content of the active tab, one tabpanel labelled by the selected tab. | `Snippet` | - |
584
+ | classNames | Class names of the inner parts, keyed by `tabBar`, `content` (the outer content area) and `visibleTabs` (the whole scrolling area in collapsible mode); merged with the built-in classes. | `Partial<Record<TabsPart, ClassValue>>` | - |
585
+ | collapsible | Whether to collapse overflowing tabs into a scrollable bar (horizontal mode only). `'auto'` collapses when the tabs overflow or wrap and leaves the collapse once they fit. | `boolean \| 'auto'` | `false` |
586
+ | dropdownProps | In collapsible mode, the Dropdown props passed to the start-side and end-side arrow menus. | `TabsDropdownProps` | - |
587
+ | icon | Snippet for the icon of each `tabList` entry, with `{ item, index }`; the icon container renders even when the snippet outputs nothing. | `Snippet<[TabsTabSnippetProps]>` | - |
588
+ | keepDOM | With `panel`, whether to render the DOM of inactive panels. When false only the active panel is rendered, without motion. | `boolean` | `true` |
589
+ | lazyRender | Lazy rendering: a panel is rendered into the DOM only after it has been active. | `boolean` | `false` |
590
+ | more | Moves the last tabs into a More dropdown. A number is the count of tabs moved; in an object, `count` is that number and `dropdownProps` is passed to the dropdown. The trigger and the menu content are customized with the `moreTrigger` and `moreContent` snippets. | `number \| TabsMore` | - |
591
+ | moreContent | Snippet that replaces the content of the More menu, with the tabs moved into it as `{ items }`. | `Snippet<[TabsMoreContentSnippetProps]>` | - |
592
+ | moreTrigger | Snippet that replaces the trigger of the More menu. | `Snippet` | - |
593
+ | onChange | Called when the tab changes, with the itemKey of the new active tab. | `(activeKey: string) => void` | - |
594
+ | onTabClick | Called when a tab is clicked or activated with Enter or Space; the event is a KeyboardEvent for keyboard activation. | `(activeKey: string, event: MouseEvent \| KeyboardEvent) => void` | - |
595
+ | onTabClose | Called when a tab is closed, with the itemKey of the closed tab. The caller removes the tab. | `(tabKey: string) => void` | - |
596
+ | onVisibleTabsChange | In collapsible mode, called when the visibility of the tabs changes, with a Map from itemKey to whether it is visible. | `(visibleState: Map<string, boolean>) => void` | - |
597
+ | panel | Snippet for the content of each `tabList` entry, with `{ item, index, itemKey }`; it makes every entry its own tabpanel, and `keepDOM`, `lazyRender` and motion apply. | `Snippet<[TabsPanelSnippetProps]>` | - |
598
+ | preventScroll | Whether focus calls inside the component stop the browser from scrolling the document to the newly focused element. | `boolean` | - |
599
+ | showRestInDropdown | In collapsible mode, whether the collapsed tabs are listed in a dropdown menu. | `boolean` | `true` |
600
+ | size | Size of the tab bar; currently only the line type supports it. | `TabSize` | `"large"` |
601
+ | styles | Inline style strings of the inner parts, keyed like `classNames`. | `Partial<Record<TabsPart, string>>` | - |
602
+ | tab | Snippet for the tab of each `tabList` entry, with `{ item, index }`; without it the entry's `tab` text shows. | `Snippet<[TabsTabSnippetProps]>` | - |
603
+ | tabBar | Snippet that replaces the whole tab bar, with `{ tabBarProps, tabBar }`: `tabBarProps` holds data only and `tabBar` is the default tab bar, rendered with `{@render tabBar()}`; a TabItem inside the custom bar controls its Tabs on its own. | `Snippet<[TabsTabBarSnippetProps]>` | - |
604
+ | tabBarExtraContent | Snippet for the extra content of the tab bar, placed outside the tablist. | `Snippet` | - |
605
+ | tabList | An array of tab data, each with itemKey, tab, disabled and closable, data only. Tab markup goes in the `tab` and `icon` snippets, and the content in the `panel` snippet or `children`. | `PlainTab[]` | `[]` |
606
+ | tabPaneMotion | Whether switching panels is animated. | `boolean` | `true` |
607
+ | tabPosition | Position of the tab bar: top is horizontal, left is vertical. | `TabPosition` | `"top"` |
608
+ | type | Style of the tab bar: line, card, button or slash. slash supports horizontal mode only. | `TabType` | `"line"` |
609
+
610
+ `activeKey` is used with `bind:activeKey`. `aria-label` and `aria-labelledby` land on the `role="tablist"` element; `class`, `style` and other native attributes land on the root element.
611
+
612
+ **PlainTab**
613
+
614
+ The data item of `tabList`; it holds data only.
615
+
616
+ | Property | Description | Type | Default Value |
617
+ | - | - | - | - |
618
+ | itemKey | Unique key of the tab, matched against `activeKey` | string | None |
619
+ | tab | Tab text; the `tab` snippet takes precedence | string \| number | None |
620
+ | disabled | Whether the tab is disabled | boolean | None |
621
+ | closable | Whether the tab can be closed | boolean | None |
622
+
623
+ **TabsMore**
624
+
625
+ The shape of `more` when it is an object.
626
+
627
+ | Property | Description | Type | Default Value |
628
+ | - | - | - | - |
629
+ | count | Number of Tabs moved into the drop-down menu | number | None |
630
+ | dropdownProps | Dropdown props passed through to the menu | TabsDropdownItemProps | None |
631
+
632
+ `TabsDropdownItemProps` is the props of Dropdown plus `class`, `style` and `onVisibleChange`. The `start` and `end` of `dropdownProps` use the same type.
633
+
634
+ **TabBarProps**
635
+
636
+ The `tabBarProps` of the `tabBar` snippet, the data of the default tab bar.
637
+
638
+ | Property | Description | Type |
639
+ | - | - | - |
640
+ | activeKey | The active itemKey; null for a controlled empty value | string \| null |
641
+ | list | Tab data | PlainTab\[] |
642
+ | type | Style of the tab bar | 'line' \| 'card' \| 'button' \| 'slash' |
643
+ | size | Size | 'small' \| 'medium' \| 'large' |
644
+ | tabPosition | Position | 'top' \| 'left' |
645
+ | collapsible | Whether collapsible | boolean \| 'auto' |
646
+ | showRestInDropdown | In collapsible mode, whether collapsed tabs are listed in a dropdown | boolean |
647
+ | more | Configuration of the More menu | number \| TabsMore |
648
+ | arrowPosition | Position of the arrows in collapsible mode | 'both' \| 'start' \| 'end' |
649
+ | classNames | Key `visibleTabs`: class name of the whole scrolling area in collapsible mode | `Partial<Record<'visibleTabs', ClassValue>>` |
650
+ | styles | Key `visibleTabs`: style of the whole scrolling area in collapsible mode | `Partial<Record<'visibleTabs', string>>` |
651
+ | dropdownProps | Dropdown props of the arrow menus in collapsible mode | TabsDropdownProps |
652
+ | class | `classNames.tabBar` of Tabs | string |
653
+ | style | `styles.tabBar` of Tabs | string |
654
+
655
+ ### TabPane
656
+
657
+ Svelte has no `TabPane`; provide the content of a tab with the `panel` snippet of Tabs.
658
+
659
+ ### TabItem
660
+
661
+ A single tab inside a custom tab bar (the `tabBar` snippet). Inside a Tabs, clicking it selects its tab by itself and triggers the `onChange` and `onTabClick` callbacks of the Tabs.
662
+
663
+ **Props**
664
+
665
+ | Property | Description | Type | Default |
666
+ | - | - | - | - |
667
+ | closable | Whether to show the close button. | `boolean` | `false` |
668
+ | disabled | Whether the tab is disabled; clicks, the close button and the Enter, Space, Delete and Backspace keys have no effect, while the close button still shows. | `boolean` | `false` |
669
+ | icon | Snippet for the tab icon; the icon container renders even when the snippet outputs nothing. | `Snippet` | - |
670
+ | itemKey | Unique key of the tab. | `string` | `""` |
671
+ | onClick | Called when the tab is clicked, with the itemKey and the event; not called while disabled. Inside a Tabs the click already selects the tab. | `(itemKey: string, event: MouseEvent) => void` | - |
672
+ | selected | Whether the tab is selected. | `boolean` | `false` |
673
+ | size | Size; defaults to the size of the enclosing Tabs. | `TabSize` | - |
674
+ | tab | Snippet for the tab content. | `Snippet` | - |
675
+ | tabPosition | Position; defaults to the tabPosition of the enclosing Tabs, else top. | `TabPosition` | - |
676
+ | type | Style; defaults to the type of the enclosing Tabs, else line. | `TabType` | - |
677
+
678
+ `class`, `style` and native attributes and events land on the root element; `role`, `id`, `aria-selected`, `aria-disabled`, `aria-controls` and `tabindex` are managed by the component and are not overridden.
679
+
680
+ ## Accessibility
681
+
682
+ ### ARIA
683
+
684
+ - About role
685
+ - The element in TabBar that holds only the Tabs has a role of `tablist`; the scroll arrows, the "more" trigger and `tabBarExtraContent` sit outside it
686
+ - Tab in TabBar has a role of `tab`
687
+ - TabPane has a role of `tabpanel`
688
+ - aria-label, aria-labelledby: When passed to Tabs they land on the `role="tablist"` element and name the tab bar
689
+ - aria-orientation: Indicates TabBar's orientation, can be `vertical` or `horizontal`. When tabPosition is `left`,aria-orientation will be `vertical`, when tabPosition is `top`, aria-orientation will be `horizontal`.
690
+ - aria-disabled: When TabPane is disabled, the related Tab's aria-disabled will be set to true.
691
+ - aria-selected: Indicates whether the Tab is selected.
692
+ - aria-controls: Indicates the TabPane controlled by the Tab; when only the active tab's panel is in the document (with `tabList`, or with `keepDOM` set to false), only the selected Tab carries it
693
+ - aria-labelledby: Indicates the element labels the TabPane
694
+
695
+ ### Keyboard and Focus
696
+
697
+ WAI-ARIA: <https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/>
698
+
699
+ - Tabs can be given focus, except for disabled tabs
700
+ - Keyboard users can use the `Tab` key to move the focus to the tab panel of the selected tab element
701
+ - Use `left and right arrows` to toggle options when focus is on a tab element in a horizontal tab list (the two arrows swap in an RTL page)
702
+ - Use `up and down arrows` to toggle options when focus is on a tab element in a vertical tab list
703
+ - When the focus is on an inactive tab element in the tab list, the `Space` or `Enter` keys can be used to activate the tab
704
+ - When keyboard users want to focus directly on the last tab element in the tab list:
705
+ - Mac users: `fn` + `right arrow`
706
+ - Windows users: `End`
707
+ - When keyboard users want to focus directly on the first tab element in the tab list:
708
+ - Mac users: `fn` + `left arrow`
709
+ - Windows users: `Home`
710
+ - With `more`, the default "More" trigger is a native `button`: focus it with `Tab`, open the dropdown with `Enter` or `Space`; it carries `aria-haspopup="menu"` and `aria-expanded`
711
+ - When a tab is allowed to be deleted:
712
+ - Users can use the `Delete` or `Backspace` key to delete a tab, except a disabled one
713
+ - After deletion, the focus is transferred to the next element of the deleted tab element; if the deleted element has no subsequent element, it is transferred to the previous element
714
+
715
+ ## Design Token
716
+
717
+ The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/navigation/tabs/>
718
+
719
+ ## Content Guidelines
720
+
721
+ - Label copy needs to explain the label content accurately and clearly
722
+ - Use short, easily distinguishable labels
723
+ - try to stay within one word
724
+
725
+ ## FAQ
726
+
727
+ - **Why typography with ellipses in Tabs doesn't work?**
728
+
729
+ Because when Tabs renders TabPane, the default is to render display: none. At this point these components cannot get the correct width or height values. It is recommended to enable lazyRender in or disable keepDOM.
730
+
731
+ - **Why are the height or width values ​​wrong when using components such as Collapse/Collapsible/Resizable Table in Tabs?**
732
+
733
+ The reason is the same as above. In addition, if the collapse does not need animation, you can also turn off the animation effect by setting its `motion` to false. There is no need to get the height of the component at this point。
734
+
735
+ ## Changes from Semi Design
736
+
737
+ From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
738
+
739
+ - 破坏性:删除 `tabBarClassName`、`tabBarStyle`、`contentStyle`、`visibleTabsStyle`,改用 `classNames`、`styles` 的 `tabBar`、`content`、`visibleTabs`(折叠模式下可见页签的滚动容器)键。
740
+ - 破坏性(主题 token):`$radius-tabs_tab_card_left` 由四值圆角改为单个半径值,使用处按逻辑角赋值;左侧卡片式页签的圆角在 RTL 下镜像,LTR 不变。
741
+ - 破坏性:删除 `TabPane.isTabPane`,改为声明 `elementType: 'Tabs.TabPane'`;删除 `TabBarProps.closable`;`activeKey` 类型加入 `null`;`onTabClick` 事件参数为 `MouseEvent | KeyboardEvent`;非受控 Tabs 的当前 key 不在新列表中时回落到第一个启用的页签;children 写法只把 `TabPane` 当页签。
742
+ - `activeKey={null}` 是受控空值(不选中任何页签),`undefined` 按非受控;`role="tablist"` 移到只含 Tab 的 `.semi-tabs-bar-tablist`;`Tabs.TabItem` 透传的 `role`、`tabIndex`、`aria-*` 不再覆盖组件值;tab 与 panel 的 `id` 对 `itemKey` 做 URL 编码;新增语言包键 `Tabs.prevTabs`、`Tabs.nextTabs`。
743
+ - 没有选中页签(`activeKey` 为 `null` 或不命中任何页签)时,tablist 中第一个启用的页签作为 Tab 停靠点;按住 Alt、Ctrl 或 Meta 的按键交给浏览器,不再移动焦点或选中页签;选中的页签收进「更多」菜单时,其 `id` 落在 tablist 外的 `hidden` 元素上,面板仍以该页签的标题命名。
744
+ - `collapsible` 把选中的页签滚进可见区域时只滚动标签栏,不再滚动页面(原来首次出现或切换选中项时,若页面已滚离 Tabs,会被拉回 Tabs 所在位置);Firefox 与 Safari 中标签栏不在视口内时直接滚到位,不播放平滑滚动。
745
+ - 可关闭页签按 Backspace 或 Delete 关闭时阻止按键的默认行为,Safari 不再因此后退页面。
746
+ - 面板滑动动画:页面取消动画(`animation: none`)时立即结束(React 原来停在动画类上);同一元素有多个动画时等最后一个结束(Solid、Svelte 原来在第一个 `animationend` 就结束)。
747
+ - 折叠模式点击箭头不再修改 `renderArrow`(Vue `#arrow`)收到的 `items` 数组,惰性渲染的下拉菜单不再少项。
748
+ - 键盘导航(方向键、Home、End、Delete)在最近的 `role="tablist"` 内查找全部页签,不再要求页签共享同一个父节点,页签被额外包裹(折叠模式的 OverflowList、自定义标签栏)时仍能移动;自定义 `renderTabBar`(Vue `#tabBar`、Svelte `tabBar`)须在页签外层渲染 `role="tablist"` 元素,否则按键时报错。
749
+ - Solid 破坏性(类型):`tabList` 的数据项只放数据,`PlainTab.tab` 收窄为 `string | number`,删除 `PlainTab.icon`(`OverflowItem` 随之没有 `icon`);节点形式的标签与图标用 Tabs 的 `renderTab(item, index)`、`renderIcon(item, index)`(类型 `TabRender`,同 Vue 的 `#tab`、`#icon`),在页签、「更多」菜单项与面板名称处各调用一次,数据相同的新对象不重新调用,标签内的节点与焦点保留;`renderArrow` 的 `defaultNode` 改为 `() => JSX.Element`,在插入处调用 `defaultNode()`。TabPane 写法下 `renderTabBar` 的 `tabBarProps.list` 与 `renderArrow` 的 `items` 是普通数据,只含 `itemKey`、`disabled`、`closable`,不带 `tab`,需要标签文本时用 `tabList`。
750
+ - Solid 破坏性:`more.render` 改为接收 `getTriggerProps`,使用方把 `getTriggerProps()` 展开到自己的触发元素上(同 Dropdown 的函数 children),返回值不再包在可聚焦的 `span` 中。
751
+ - Svelte:`Tabs` 用 `tabList` 数据属性加 snippet 描述标签和面板,不提供公开的 `TabPane`;snippet 为 `panel`、`tab`、`icon`、`tabBarExtraContent`、`tabBar`、`arrow`、`moreTrigger`、`moreContent`,没有 `panel` 时 `children` 是单一面板。
752
+ - Svelte:`activeKey` 可绑定,支持 `bind:`、函数绑定、单向传值和不传四种写法,单向传值时点击在本地覆盖,父级再推新值时以父级为准。
753
+ - Svelte:`TabItem` 可用在自定义 `tabBar` 中,通过 context 控制所在 `Tabs`,在 `Tabs` 外单独使用时不输出悬空的 `id` 和 `aria-controls`;`aria-label` 和 `aria-labelledby` 落在 tablist 上,其余未声明属性落在根元素。
754
+ - Svelte:折叠模式下 tablist 就是 OverflowList 的滚动容器,箭头在 tablist 之外,方向键、Home、End 在整个 tablist 内移动;被收进「更多」菜单的标签在 DOM 里保留隐藏的 `id` 元素,面板的 `aria-labelledby` 仍然有效。