@fibrae/semi-ui-svelte 0.9.0 → 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 (169) 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/cascader.svelte +1 -0
  16. package/dist/components/cascader/interface.d.ts +57 -0
  17. package/dist/components/checkbox/interface.d.ts +19 -0
  18. package/dist/components/code-highlight/interface.d.ts +3 -0
  19. package/dist/components/collapse/interface.d.ts +16 -0
  20. package/dist/components/collapsible/interface.d.ts +10 -0
  21. package/dist/components/color-picker/interface.d.ts +10 -0
  22. package/dist/components/config-provider/interface.d.ts +7 -0
  23. package/dist/components/cropper/interface.d.ts +11 -0
  24. package/dist/components/date-picker/interface.d.ts +47 -0
  25. package/dist/components/descriptions/interface.d.ts +6 -0
  26. package/dist/components/divider/interface.d.ts +4 -0
  27. package/dist/components/dropdown/interface.d.ts +8 -0
  28. package/dist/components/empty/interface.d.ts +7 -0
  29. package/dist/components/feedback/interface.d.ts +16 -0
  30. package/dist/components/float-button/interface.d.ts +14 -0
  31. package/dist/components/form/interface.d.ts +47 -0
  32. package/dist/components/form/label.svelte +2 -2
  33. package/dist/components/grid/interface.d.ts +13 -0
  34. package/dist/components/highlight/interface.d.ts +7 -0
  35. package/dist/components/hot-keys/interface.d.ts +3 -0
  36. package/dist/components/image/interface.d.ts +59 -0
  37. package/dist/components/input/interface.d.ts +67 -0
  38. package/dist/components/input-number/interface.d.ts +24 -0
  39. package/dist/components/json-viewer/interface.d.ts +7 -0
  40. package/dist/components/layout/interface.d.ts +3 -0
  41. package/dist/components/list/interface.d.ts +18 -0
  42. package/dist/components/locale/interface.d.ts +4 -0
  43. package/dist/components/lottie/interface.d.ts +2 -0
  44. package/dist/components/markdown-render/interface.d.ts +5 -0
  45. package/dist/components/modal/interface.d.ts +29 -0
  46. package/dist/components/navigation/interface.d.ts +47 -0
  47. package/dist/components/overflow-list/interface.d.ts +11 -0
  48. package/dist/components/pagination/interface.d.ts +12 -0
  49. package/dist/components/pincode/interface.d.ts +8 -0
  50. package/dist/components/popconfirm/interface.d.ts +12 -0
  51. package/dist/components/popover/interface.d.ts +30 -0
  52. package/dist/components/progress/interface.d.ts +13 -0
  53. package/dist/components/radio/interface.d.ts +22 -0
  54. package/dist/components/rating/interface.d.ts +12 -0
  55. package/dist/components/resizable/interface.d.ts +30 -0
  56. package/dist/components/scroll-list/interface.d.ts +6 -0
  57. package/dist/components/select/interface.d.ts +63 -0
  58. package/dist/components/side-sheet/interface.d.ts +19 -0
  59. package/dist/components/skeleton/interface.d.ts +7 -0
  60. package/dist/components/slider/interface.d.ts +23 -0
  61. package/dist/components/space/interface.d.ts +4 -0
  62. package/dist/components/spin/interface.d.ts +7 -0
  63. package/dist/components/steps/interface.d.ts +9 -0
  64. package/dist/components/switch/interface.d.ts +7 -0
  65. package/dist/components/table/interface.d.ts +48 -0
  66. package/dist/components/tabs/interface.d.ts +29 -0
  67. package/dist/components/tag/interface.d.ts +22 -0
  68. package/dist/components/tag-input/interface.d.ts +29 -0
  69. package/dist/components/time-picker/interface.d.ts +31 -0
  70. package/dist/components/timeline/interface.d.ts +5 -0
  71. package/dist/components/tooltip/interface.d.ts +20 -0
  72. package/dist/components/tooltip/tooltip.svelte +3 -0
  73. package/dist/components/transfer/interface.d.ts +18 -0
  74. package/dist/components/tree/interface.d.ts +45 -0
  75. package/dist/components/tree-select/interface.d.ts +55 -0
  76. package/dist/components/typography/interface.d.ts +33 -0
  77. package/dist/components/upload/interface.d.ts +64 -0
  78. package/dist/components/user-guide/interface.d.ts +15 -0
  79. package/dist/components/video-player/interface.d.ts +22 -0
  80. package/dist/styles.css +1 -1
  81. package/docs/advanced/dark-mode.md +288 -0
  82. package/docs/basic/button.md +605 -0
  83. package/docs/basic/divider.md +103 -0
  84. package/docs/basic/float-button.md +246 -0
  85. package/docs/basic/grid.md +427 -0
  86. package/docs/basic/layout.md +459 -0
  87. package/docs/basic/resizable.md +584 -0
  88. package/docs/basic/space.md +163 -0
  89. package/docs/basic/tokens.md +425 -0
  90. package/docs/basic/typography.md +615 -0
  91. package/docs/changes-from-semi.md +105 -0
  92. package/docs/ecosystem/tailwind.md +210 -0
  93. package/docs/experience/accessibility.md +82 -0
  94. package/docs/experience/content-guidelines.md +819 -0
  95. package/docs/experience/internationalization.md +7 -0
  96. package/docs/feedback/banner.md +198 -0
  97. package/docs/feedback/feedback.md +294 -0
  98. package/docs/feedback/notification.md +401 -0
  99. package/docs/feedback/popconfirm.md +243 -0
  100. package/docs/feedback/progress.md +389 -0
  101. package/docs/feedback/skeleton.md +388 -0
  102. package/docs/feedback/spin.md +172 -0
  103. package/docs/feedback/toast.md +393 -0
  104. package/docs/input/auto-complete.md +399 -0
  105. package/docs/input/cascader.md +1558 -0
  106. package/docs/input/checkbox.md +408 -0
  107. package/docs/input/color-picker.md +175 -0
  108. package/docs/input/date-picker.md +942 -0
  109. package/docs/input/form.md +2550 -0
  110. package/docs/input/input-number.md +451 -0
  111. package/docs/input/input.md +640 -0
  112. package/docs/input/pincode.md +191 -0
  113. package/docs/input/radio.md +337 -0
  114. package/docs/input/rating.md +214 -0
  115. package/docs/input/select.md +1230 -0
  116. package/docs/input/slider.md +347 -0
  117. package/docs/input/switch.md +206 -0
  118. package/docs/input/tag-input.md +465 -0
  119. package/docs/input/time-picker.md +358 -0
  120. package/docs/input/transfer.md +1061 -0
  121. package/docs/input/tree-select.md +1300 -0
  122. package/docs/input/upload.md +1811 -0
  123. package/docs/llms.txt +147 -0
  124. package/docs/navigation/anchor.md +377 -0
  125. package/docs/navigation/backtop.md +100 -0
  126. package/docs/navigation/breadcrumb.md +284 -0
  127. package/docs/navigation/navigation.md +851 -0
  128. package/docs/navigation/pagination.md +217 -0
  129. package/docs/navigation/steps.md +315 -0
  130. package/docs/navigation/tabs.md +754 -0
  131. package/docs/navigation/tree.md +1956 -0
  132. package/docs/other/config-provider.md +599 -0
  133. package/docs/other/locale.md +353 -0
  134. package/docs/plus/audio-player.md +155 -0
  135. package/docs/plus/code-highlight.md +150 -0
  136. package/docs/plus/drag-move.md +214 -0
  137. package/docs/plus/hot-keys.md +174 -0
  138. package/docs/plus/json-viewer.md +392 -0
  139. package/docs/plus/lottie.md +176 -0
  140. package/docs/plus/markdown-render.md +240 -0
  141. package/docs/plus/video-player.md +325 -0
  142. package/docs/show/avatar.md +475 -0
  143. package/docs/show/badge.md +276 -0
  144. package/docs/show/calendar.md +352 -0
  145. package/docs/show/card.md +485 -0
  146. package/docs/show/carousel.md +592 -0
  147. package/docs/show/collapse.md +289 -0
  148. package/docs/show/collapsible.md +216 -0
  149. package/docs/show/cropper.md +285 -0
  150. package/docs/show/descriptions.md +325 -0
  151. package/docs/show/dropdown.md +466 -0
  152. package/docs/show/empty.md +225 -0
  153. package/docs/show/highlight.md +144 -0
  154. package/docs/show/image.md +433 -0
  155. package/docs/show/list.md +927 -0
  156. package/docs/show/modal.md +517 -0
  157. package/docs/show/overflow-list.md +272 -0
  158. package/docs/show/popover.md +534 -0
  159. package/docs/show/scroll-list.md +156 -0
  160. package/docs/show/side-sheet.md +274 -0
  161. package/docs/show/table.md +5437 -0
  162. package/docs/show/tag.md +428 -0
  163. package/docs/show/timeline.md +277 -0
  164. package/docs/show/tooltip.md +442 -0
  165. package/docs/show/user-guide.md +419 -0
  166. package/docs/start/getting-started.md +234 -0
  167. package/docs/start/introduction.md +57 -0
  168. package/docs/start/overview.md +21 -0
  169. package/package.json +5 -4
@@ -0,0 +1,428 @@
1
+ # Tag
2
+
3
+ > Tag component is used to display a collection of concise information for rapid identification and grouping.
4
+
5
+ Package: `@fibrae/semi-ui-svelte`. Web page: https://semi-design-next.pages.dev/en-US/svelte/show/tag/
6
+
7
+ ## Demos
8
+
9
+ ### How to import
10
+
11
+ ```svelte
12
+ <script lang="ts">
13
+ import { Tag, TagGroup, SplitTagGroup } from '@fibrae/semi-ui-svelte';
14
+ </script>
15
+ ```
16
+
17
+ ### Basic usage
18
+
19
+ To use this tag, just wrap the content with the `<Tag>` tag.\
20
+ It can be turned into a closable label by adding the `closable` property.
21
+
22
+ At this time, clicking x to close will call `onClose(event, tagKey)`, and calling `preventDefault` on the event in `onClose` keeps the tag shown after clicking. The tag content goes inside the Tag tag, as the `children` snippet.
23
+
24
+ ```svelte
25
+ <script lang="ts">
26
+ import { Space, Tag, type TagCloseEvent } from '@fibrae/semi-ui-svelte';
27
+
28
+ const preventClose = (event: TagCloseEvent) => event.preventDefault();
29
+ </script>
30
+
31
+ <div>
32
+ <Space>
33
+ <Tag>default tag</Tag>
34
+ <Tag closable>Closable Tag</Tag>
35
+ <Tag closable onClose={preventClose}>Closable Tag, Prevent Default</Tag>
36
+ </Space>
37
+ </div>
38
+ ```
39
+
40
+ ### Size
41
+
42
+ Supports two sizes: `large` and `small` (default).
43
+
44
+ ```svelte
45
+ <script lang="ts">
46
+ import { Space, Tag } from '@fibrae/semi-ui-svelte';
47
+ </script>
48
+
49
+ <Space>
50
+ <Tag color="light-blue" size="small">small tag</Tag>
51
+ <Tag color="cyan" size="large">large tag</Tag>
52
+ </Space>
53
+ ```
54
+
55
+ ### Shape
56
+
57
+ Supports two Shape: `square`(default)、`circle`。
58
+
59
+ ```svelte
60
+ <script lang="ts">
61
+ import { Space, Tag } from '@fibrae/semi-ui-svelte';
62
+ </script>
63
+
64
+ <Space>
65
+ <Tag color="amber" shape="circle" size="small">small circle tag</Tag>
66
+ <Tag color="violet" shape="circle" size="large">large circle tag</Tag>
67
+ </Space>
68
+ ```
69
+
70
+ ### Icon
71
+
72
+ Use the `prefixIcon` and `suffixIcon` snippets to add icons before or after the content: write `{#snippet prefixIcon()}...{/snippet}` inside the Tag tag, or define it and pass it as a prop.
73
+
74
+ ```svelte
75
+ <script lang="ts">
76
+ import { IconGithubLogo, IconSemiLogo } from '@fibrae/semi-icons-svelte';
77
+ import { Space, Tag } from '@fibrae/semi-ui-svelte';
78
+ </script>
79
+
80
+ <Space>
81
+ <Tag color="light-blue" shape="circle" size="large">
82
+ {#snippet prefixIcon()}
83
+ <IconGithubLogo />
84
+ {/snippet}
85
+ Semi Design
86
+ </Tag>
87
+ <Tag color="cyan" shape="circle" size="large">
88
+ Semi: one component library for four frameworks
89
+ {#snippet suffixIcon()}
90
+ <IconSemiLogo />
91
+ {/snippet}
92
+ </Tag>
93
+ </Space>
94
+ ```
95
+
96
+ ### Color
97
+
98
+ Tag supports 16 colors including whites from Semi's palette: `amber`, `blue`, `cyan`, `green`, `grey`, `indigo`, `light-blue`, `light-green`, `lime`, `orange`, `pink`, `purple`, `red`, `teal`, `violet`, `yellow`, `white`. You can also customize color through `style`.
99
+
100
+ ```svelte
101
+ <script lang="ts">
102
+ import { Space, Tag, type TagColor } from '@fibrae/semi-ui-svelte';
103
+
104
+ const colors: TagColor[] = ['amber', 'blue', 'cyan', 'green', 'grey', 'indigo', 'light-blue', 'light-green', 'lime', 'orange', 'pink', 'purple', 'red', 'teal', 'violet', 'yellow', 'white'];
105
+ </script>
106
+
107
+ <Space wrap>
108
+ {#each colors as color (color)}
109
+ <Tag {color}>{color}</Tag>
110
+ {/each}
111
+ </Space>
112
+ ```
113
+
114
+ ### AI style - colorful labels
115
+
116
+ Set `colorful` to `true` to get colorful labels.
117
+
118
+ ```svelte
119
+ <script lang="ts">
120
+ import { IconAIFilledLevel1, IconAIFilledLevel3 } from '@fibrae/semi-icons-svelte';
121
+ import { Tag } from '@fibrae/semi-ui-svelte';
122
+
123
+ const grid = 'display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 10px; width: fit-content';
124
+ </script>
125
+
126
+ {#snippet level1()}
127
+ <IconAIFilledLevel1 size="small" />
128
+ {/snippet}
129
+ {#snippet level3()}
130
+ <IconAIFilledLevel3 size="small" />
131
+ {/snippet}
132
+
133
+ <div style="display: flex; flex-direction: column; row-gap: 30px">
134
+ <div style={grid}>
135
+ <Tag colorful gradient prefixIcon={level1} shape="circle" type="solid">AI</Tag>
136
+ <Tag colorful gradient prefixIcon={level3} shape="circle" type="light">AI</Tag>
137
+ <Tag colorful gradient prefixIcon={level3} shape="circle" type="ghost">AI</Tag>
138
+ <Tag colorful prefixIcon={level1} shape="circle" type="solid">AI</Tag>
139
+ <Tag colorful prefixIcon={level1} shape="circle" type="light">AI</Tag>
140
+ <Tag colorful prefixIcon={level1} shape="circle" type="ghost">AI</Tag>
141
+ </div>
142
+ <div style={grid}>
143
+ <Tag colorful gradient prefixIcon={level1} type="solid">AI</Tag>
144
+ <Tag colorful gradient prefixIcon={level3} type="light">AI</Tag>
145
+ <Tag colorful gradient prefixIcon={level3} type="ghost">AI</Tag>
146
+ <Tag colorful prefixIcon={level1} type="solid">AI</Tag>
147
+ <Tag colorful prefixIcon={level1} type="light">AI</Tag>
148
+ <Tag colorful prefixIcon={level1} type="ghost">AI</Tag>
149
+ </div>
150
+ </div>
151
+ ```
152
+
153
+ ### Type
154
+
155
+ Tag supports three different types, including: `light`(default), `ghost`, `solid`.
156
+
157
+ ```svelte
158
+ <script lang="ts">
159
+ import { IconGithubLogo, IconSemiLogo } from '@fibrae/semi-icons-svelte';
160
+ import { Space, Tag } from '@fibrae/semi-ui-svelte';
161
+ </script>
162
+
163
+ <Space wrap>
164
+ <Tag color="light-blue" shape="circle" size="large" type="light">
165
+ {#snippet prefixIcon()}
166
+ <IconGithubLogo />
167
+ {/snippet}
168
+ Semi Design Light Tag
169
+ </Tag>
170
+ <Tag color="cyan" shape="circle" size="large" type="light">
171
+ Semi: one component library for four frameworks
172
+ {#snippet suffixIcon()}
173
+ <IconSemiLogo />
174
+ {/snippet}
175
+ </Tag>
176
+ <Tag color="light-blue" shape="circle" size="large" type="ghost">
177
+ {#snippet prefixIcon()}
178
+ <IconGithubLogo />
179
+ {/snippet}
180
+ Semi Design Ghost Tag
181
+ </Tag>
182
+ <Tag color="cyan" shape="circle" size="large" type="ghost">
183
+ Semi: one component library for four frameworks
184
+ {#snippet suffixIcon()}
185
+ <IconSemiLogo />
186
+ {/snippet}
187
+ </Tag>
188
+ <Tag color="light-blue" shape="circle" size="large" type="solid">
189
+ {#snippet prefixIcon()}
190
+ <IconGithubLogo />
191
+ {/snippet}
192
+ Semi Design Solid Tag
193
+ </Tag>
194
+ <Tag color="cyan" shape="circle" size="large" type="solid">
195
+ Semi: one component library for four frameworks
196
+ {#snippet suffixIcon()}
197
+ <IconSemiLogo />
198
+ {/snippet}
199
+ </Tag>
200
+ </Space>
201
+ ```
202
+
203
+ ### Avatar Tag
204
+
205
+ You can get a avatar tag with `avatarSrc` property. `avatarShape` can change the shape of avatar tag including `square`(default) and `circle`.
206
+
207
+ ```svelte
208
+ <script lang="ts">
209
+ import { Space, Tag } from '@fibrae/semi-ui-svelte';
210
+
211
+ const src = '/assets/placeholder/avatar-a.svg';
212
+ </script>
213
+
214
+ <Space align="start" vertical>
215
+ <Tag avatarSrc={src}>焦锐志</Tag>
216
+ <Tag avatarSrc={src} size="large">焦锐志</Tag>
217
+ <Tag avatarSrc={src} closable size="large">焦锐志</Tag>
218
+ <Tag avatarShape="circle" avatarSrc={src}>焦锐志</Tag>
219
+ <Tag avatarShape="circle" avatarSrc={src} size="large">焦锐志</Tag>
220
+ <Tag avatarShape="circle" avatarSrc={src} closable size="large">焦锐志</Tag>
221
+ </Space>
222
+ ```
223
+
224
+ ### Invisible
225
+
226
+ You can use `visible` property to control whether the tag is visible.
227
+
228
+ ```svelte
229
+ <script lang="ts">
230
+ import { Radio, RadioGroup, Tag, type RadioValue } from '@fibrae/semi-ui-svelte';
231
+
232
+ let value = $state<RadioValue | undefined>(0);
233
+ </script>
234
+
235
+ <div>
236
+ <RadioGroup aria-label="标签可见性" bind:value name="demo-tag-visible" type="button">
237
+ <Radio value={1}>Show</Radio>
238
+ <Radio value={0}>Hide</Radio>
239
+ </RadioGroup>
240
+ <div style="margin-top: 10px">
241
+ <Tag color="light-blue" size="large" visible={value === 1}>Invisible tag</Tag>
242
+ </div>
243
+ </div>
244
+ ```
245
+
246
+ ### TagGroup
247
+
248
+ You can pass in configs for tags through `tagList` to create a TagGroup. The `maxTagCount` can be used to cap the number of list and will be displayed as `+N` when the limit is exceeded.\
249
+ Set the `showPopover` property to control whether the remaining content is displayed by Popover when hover to + N Tag
250
+
251
+ ```svelte
252
+ <script lang="ts">
253
+ import { TagGroup, type TagGroupItem } from '@fibrae/semi-ui-svelte';
254
+
255
+ const src = '/assets/placeholder/avatar-a.svg';
256
+ const tagList: TagGroupItem[] = [
257
+ { color: 'light-blue', children: '短视频' },
258
+ { color: 'cyan', children: '直播' },
259
+ { color: 'violet', children: '剪辑' },
260
+ { color: 'white', children: '醒图' },
261
+ ];
262
+ const tagList2: TagGroupItem[] = [
263
+ { color: 'white', children: 'Short Video', avatarSrc: src },
264
+ { color: 'white', children: 'Hotsoon', avatarSrc: src },
265
+ { color: 'white', children: 'Capcut', avatarSrc: src },
266
+ { color: 'white', children: 'Xingtu', avatarSrc: src },
267
+ ];
268
+ const divStyle = 'background-color: var(--semi-color-fill-0); height: 35px; width: 300px; display: flex; align-items: center; padding: 0 10px; margin-bottom: 30px';
269
+ const tagGroupStyle = 'display: flex; align-items: center; width: 350px';
270
+ </script>
271
+
272
+ <div style={divStyle}>
273
+ <TagGroup maxTagCount={3} size="large" style={tagGroupStyle} {tagList} />
274
+ </div>
275
+ <div style={divStyle}>
276
+ <TagGroup avatarShape="circle" maxTagCount={2} showPopover size="large" style={tagGroupStyle} tagList={tagList2} />
277
+ </div>
278
+ ```
279
+
280
+ If the tags in the TagGroup can be deleted, the user needs to update the `tagList` passed to the TagGroup in `onTagClose`. Provide a `tagKey` for every item when tags are removed from the list; otherwise removing the earlier of two tags with the same text shifts the later one onto its instance. Items of `tagList` take `string | number` as `children`; use the `tag` snippet, whose parameter is `{ tag, index }`, to render a fully custom node for each tag. Both the item's own `onClose` in `tagList` and the group's `onTagClose` are called.
281
+
282
+ ```svelte
283
+ <script lang="ts">
284
+ import { TagGroup, type TagCloseEvent, type TagGroupItem } from '@fibrae/semi-ui-svelte';
285
+
286
+ let tagList = $state<TagGroupItem[]>([
287
+ { tagKey: '1', color: 'light-blue', children: '短视频', closable: true },
288
+ { tagKey: '3', color: 'cyan', children: '剪辑', closable: true },
289
+ { tagKey: '2', color: 'violet', children: '醒图', closable: true },
290
+ { tagKey: '4', color: 'teal', children: '轻颜相机', closable: true },
291
+ { tagKey: '5', color: 'white', children: '办公', closable: true },
292
+ ]);
293
+
294
+ const closeTag = (_event: TagCloseEvent, tagKey?: string | number) => {
295
+ tagList = tagList.filter((tag) => tag.tagKey !== tagKey);
296
+ };
297
+ </script>
298
+
299
+ <div style="background-color: var(--semi-color-fill-0); height: 35px; width: 300px; display: flex; align-items: center; padding: 0 10px; margin-bottom: 30px">
300
+ <TagGroup maxTagCount={3} onTagClose={closeTag} showPopover size="large" style="display: flex; align-items: center; width: 350px" {tagList} />
301
+ </div>
302
+ ```
303
+
304
+ ### SplitTagGroup
305
+
306
+ Use `SplitTagGroup` to combine multiple tags into a single connected group. The first and last tags keep their rounded corners while the middle tags are rendered with a square edge, producing a continuous visual unit.
307
+
308
+ ```svelte
309
+ <script lang="ts">
310
+ import { Space, SplitTagGroup, Tag } from '@fibrae/semi-ui-svelte';
311
+ </script>
312
+
313
+ <Space align="start" vertical>
314
+ <SplitTagGroup>
315
+ <Tag color="blue" type="solid">标签一</Tag>
316
+ <Tag color="cyan" type="solid">标签二</Tag>
317
+ <Tag color="teal" type="solid">标签三</Tag>
318
+ </SplitTagGroup>
319
+
320
+ <SplitTagGroup>
321
+ <Tag color="violet" shape="circle">组合</Tag>
322
+ <Tag color="purple" shape="circle">标签</Tag>
323
+ <Tag color="pink" shape="circle">示例</Tag>
324
+ <Tag color="red" shape="circle">效果</Tag>
325
+ </SplitTagGroup>
326
+
327
+ <SplitTagGroup>
328
+ <Tag color="amber" type="light">浅色</Tag>
329
+ <Tag color="orange" type="light">组合</Tag>
330
+ <Tag color="yellow" type="light">标签</Tag>
331
+ </SplitTagGroup>
332
+
333
+ <SplitTagGroup>
334
+ <Tag color="green" type="ghost">镂空</Tag>
335
+ <Tag color="light-green" type="ghost">样式</Tag>
336
+ <Tag color="lime" type="ghost">组合</Tag>
337
+ </SplitTagGroup>
338
+ </Space>
339
+ ```
340
+
341
+ ## API Reference
342
+
343
+ ### Tag
344
+
345
+ **Props**
346
+
347
+ | Property | Description | Type | Default |
348
+ | - | - | - | - |
349
+ | avatarShape | Shape of the avatar in an avatar tag: square or circle. | `AvatarShape` | `"square"` |
350
+ | avatarSrc | Avatar image URL. Setting it makes an avatar tag. | `string` | - |
351
+ | children | Snippet for the tag content. | `Snippet` | - |
352
+ | closable | Whether the tag can be closed. | `boolean` | `false` |
353
+ | color | Tag color: one of the 16 palette colors or white. | `TagColor` | `"grey"` |
354
+ | colorful | Whether the tag is colorful. | `boolean` | `false` |
355
+ | gradient | Whether a colorful tag uses a gradient. Requires colorful. | `boolean` | `false` |
356
+ | onClose | Called when the tag is closed, with the close event and the tagKey: a click event for the close icon, a keydown event for Backspace or Delete. Call preventDefault on the event to keep the tag visible. | `(event: TagCloseEvent, tagKey?: string \| number) => void` | - |
357
+ | onkeydown | Called when a key is pressed on the tag. | `KeyboardEventHandler<T> \| null` | - |
358
+ | prefixIcon | Snippet for the icon before the content. | `Snippet` | - |
359
+ | shape | Tag shape: square or circle. | `TagShape` | `"square"` |
360
+ | size | Tag size: small, default or large. | `TagSize` | `"default"` |
361
+ | suffixIcon | Snippet for the icon after the content. | `Snippet` | - |
362
+ | tabindex | tabindex of the tag. An interactive tag defaults to 0. | `number \| null` | - |
363
+ | tagKey | Unique identifier of the tag, passed as the second argument of onClose. | `string \| number` | - |
364
+ | type | Style type: light, ghost or solid. | `TagType` | `"light"` |
365
+ | visible | Whether the tag is visible; bind it with `bind:visible`. The setter of a function binding can reject closing. Without it the tag closes itself and shows until then. | `boolean` | - |
366
+
367
+ `class`, `style` and native attributes are spread onto the root element (`div`); native events use lowercase names (`onclick`, `onmouseenter`). An `onclick` listener or `closable` makes the tag interactive.
368
+
369
+ ### TagGroup
370
+
371
+ **Props**
372
+
373
+ | Property | Description | Type | Default |
374
+ | - | - | - | - |
375
+ | avatarShape | Avatar shape of the avatar tags in the group. | `AvatarShape` | `"square"` |
376
+ | maxTagCount | Maximum number of visible tags. The rest is shown as +N. | `number` | - |
377
+ | onPlusNMouseEnter | Called when the pointer enters the +N tag. | `(event: MouseEvent) => void` | - |
378
+ | onTagClose | Called when a tag in the group is closed, with the close event and the tagKey of the tag; the item's own onClose is called too. Update tagList in the callback. | `(event: TagCloseEvent, tagKey?: string \| number) => void` | - |
379
+ | popoverProps | Props passed to the Popover, such as position and trigger; `child` and `content` are fixed by TagGroup. | `PopoverProps` | - |
380
+ | restCount | The number shown in +N. Defaults to the number of tags beyond maxTagCount. | `number` | - |
381
+ | showPopover | Whether hovering +N shows the remaining tags in a Popover. | `boolean` | - |
382
+ | size | Size of the tags in the group. | `TagSize` | `"default"` |
383
+ | tag | Snippet for custom rendering of each tag, with the parameter `{ tag, index }`: the tag configuration and its index, counted across the visible tags and the +N popover. | `Snippet<[scope: { tag: TagGroupItem; index: number }]>` | - |
384
+ | tagList | Tag configurations. Each item holds the props of a Tag, with children as the string or number label. | `TagGroupItem[]` | - |
385
+
386
+ `class`, `style` and native attributes are spread onto the TagGroup root element (`div`). The `+N` Tag is itself the Popover trigger, with no extra `span` around it.
387
+
388
+ ### SplitTagGroup
389
+
390
+ **Props**
391
+
392
+ | Property | Description | Type | Default |
393
+ | - | - | - | - |
394
+ | children | Snippet for the Tag components combined into one. | `Snippet` | - |
395
+
396
+ `class`, `style`, `aria-label` and other native attributes are spread onto the root element (`div`). The root `role` is fixed to `group`.
397
+
398
+ ## Accessibility
399
+
400
+ ### ARIA
401
+
402
+ - `aria-label` is used to indicate the role of `Tag`, for deletable or clickable `Tag`, we recommend using this attribute
403
+
404
+ ### Keyboard and Focus
405
+
406
+ - If the current `Tag` is interactive, then this `Tag` can be focused. Such as:
407
+ - When the `onClick` attribute (`@click` in Vue, `onclick` in Svelte) is used, the keyboard user can activate this `Tag` with the `Enter` or `Space` key
408
+ - When the `closable` property is `true`, keyboard users can delete this `Tag` by pressing the `Delete` or `Backspace` key, and focus moves to the adjacent focusable `Tag`
409
+
410
+ ## Content Guidelines
411
+
412
+ - Due to limited space, label text should be as short as possible
413
+ - avoid line breaks
414
+ - use sentence case
415
+
416
+ ## Design Tokens
417
+
418
+ The design token table of this component is on the web page: <https://semi-design-next.pages.dev/en-US/svelte/show/tag/>
419
+
420
+ ## Changes from Semi Design
421
+
422
+ From the project release notes (written in Chinese). Your knowledge of Semi Design does not cover these.
423
+
424
+ - 破坏性(类型):`TagGroupProps` 删除泛型参数 `T`,改为按 `mode` 判别的联合且 `tagList` 必填:`<TagGroup<'custom'> ...>` 改为 `<TagGroup mode="custom" ...>`,`TagGroupProps<'custom'>` 改为 `TagGroupProps`;`onClose`、`onTagClose` 事件参数改为 `React.MouseEvent | React.KeyboardEvent`。
425
+ - 可点击 Tag 按 Enter、空格时对自身 `click()`,`onClick` 收到真实 click 事件;`visible={undefined}` 按非受控;TagGroup、SplitTagGroup 透传未声明属性到根 div(F2)。
426
+ - Solid 破坏性:TagGroup 删除 `mode`,`tagList` 只收数据 `TagGroupItem[]`(Tag 的属性,`children` 为 `string | number`,不含 `prefixIcon`、`suffixIcon`),新导出类型 `TagGroupItem`;自定义标签节点用 `renderTag={(tag, index) => JSX.Element}`,对应 Vue 的 `#tag` 插槽。`renderTag` 只为显示的标签调用,超出 `maxTagCount` 的标签在 +N 弹层打开时才创建;`maxTagCount` 变化时跨过折叠边界的项重新调用 `renderTag`。
427
+ - Svelte:Tag 的内容与图标用 `children`、`prefixIcon`、`suffixIcon` snippet;`visible` 可绑定,函数绑定的 setter 可以拒绝关闭;`onClose(event, tagKey)` 去掉 children 参数;`tabIndex` 改为 `tabindex`;点击、键盘、悬停用原生小写属性 `onclick`、`onkeydown`、`onmouseenter`;aria-label 与省略样式在挂载后读 DOM 判断,服务端首帧没有 aria-label。
428
+ - Svelte 破坏性:TagGroup 删除 `mode`,`tagList` 只收数据 `TagGroupItem[]`(`children` 为 `string | number`);自定义标签用 `tag` snippet(参数 `{ tag, index }`,`index` 在可见区与弹层里连续计数);`onTagClose(event, tagKey)`、`onPlusNMouseEnter(event)`;数据项自己的 `onClose` 与分组的 `onTagClose` 都会触发;`+N` 的 Tag 自己是 Popover 触发器,不额外包 span;`popoverProps` 可覆盖 Popover 的默认值,但 `child` 与 `content` 由 TagGroup 固定。