11
11
const theme = getTheme (" tabItem" );
12
12
const activeClasses = getContext <string >(" activeClasses" );
13
13
const ctx: TabCtxType = getContext (" ctx" );
14
-
14
+
15
15
const compoTabStyle = $derived (tabStyle ?? ctx .tabStyle ?? " full" );
16
16
const { active, inactive } = $derived (tabs ({ tabStyle: compoTabStyle , hasDivider: true }));
17
17
18
18
const tabId = $props .id ();
19
- const tabIdentifier = key ?? tabId ;
19
+ const tabIdentifier = key ?? tabId ;
20
20
const self: SelectedTab = { id: tabIdentifier , snippet: children };
21
21
22
22
const registerTab = getContext <(tab : SelectedTab ) => void >(" registerTab" );
27
27
$effect (() => {
28
28
updateSingleSelection (open , self );
29
29
registerTab ?.(self );
30
-
30
+
31
31
return () => {
32
32
if (self .id ) {
33
33
unregisterTab ?.(self .id );
34
34
}
35
- };
35
+ };
36
36
});
37
37
38
38
const { base, button } = $derived (tabItem ({ open , disabled }));
39
39
</script >
40
40
41
41
<li {...restProps } class ={base ({ class: clsx (theme ?.base , className ) })} role =" presentation" >
42
- <button
43
- type =" button"
44
- onclick ={() => (open = true )}
45
- role =" tab"
46
- id ={self .id }
47
- aria-controls ={ctx .panelId }
48
- aria-selected ={open }
49
- {disabled }
50
- class ={button ({
51
- class: clsx (
52
- open ? (activeClass ?? active ({ class: activeClasses })) : (inactiveClass ?? inactive ()),
53
- theme ?.button ,
54
- classes ?.button
55
- )
42
+ <button
43
+ type =" button"
44
+ onclick ={() => (open = true )}
45
+ role =" tab"
46
+ id ={self .id }
47
+ aria-controls ={ctx .panelId }
48
+ aria-selected ={open }
49
+ {disabled }
50
+ class ={button ({
51
+ class: clsx (open ? (activeClass ?? active ({ class: activeClasses })) : (inactiveClass ?? inactive ()), theme ?.button , classes ?.button )
56
52
})}
57
53
>
58
54
{#if titleSlot }
61
57
{title }
62
58
{/if }
63
59
</button >
64
- </li >
60
+ </li >
61
+
62
+ <!--
63
+ @component
64
+ [Go to docs](https://flowbite-svelte.com/)
65
+ ## Type
66
+ [TabitemProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L1730)
67
+ ## Props
68
+ @prop children
69
+ @prop titleSlot
70
+ @prop open = $bindable(false)
71
+ @prop title = "Tab title"
72
+ @prop key
73
+ @prop activeClass
74
+ @prop inactiveClass
75
+ @prop class: className
76
+ @prop classes
77
+ @prop disabled
78
+ @prop tabStyle
79
+ @prop ...restProps
80
+ -->
0 commit comments