forked from themesberg/flowbite-svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonGroup.svelte
More file actions
41 lines (35 loc) · 1.06 KB
/
ButtonGroup.svelte
File metadata and controls
41 lines (35 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<script lang="ts">
import { buttonGroup } from "./theme";
import clsx from "clsx";
import type { ButtonGroupProps } from "$lib";
import { getTheme } from "$lib/theme/themeUtils";
import { setButtonGroupContext } from "$lib/context";
let { children, size = "md", disabled, class: className, ...restProps }: ButtonGroupProps = $props();
let groupClass = $derived(buttonGroup({ size, class: clsx(getTheme("buttonGroup"), className) }));
// Create a reactive context object
// The object itself stays the same, but its properties are reactive
const reactiveCtx = {
get size() {
return size;
},
get disabled() {
return disabled;
}
};
setButtonGroupContext(reactiveCtx);
</script>
<div {...restProps} class={groupClass} role="group">
{@render children()}
</div>
<!--
@component
[Go to docs](https://flowbite-svelte.com/)
## Type
[ButtonGroupProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L320)
## Props
@prop children
@prop size = "md"
@prop disabled
@prop class: className
@prop ...restProps
-->