| 33 | >; |
| 34 | |
| 35 | export const ToggleGroup = <T extends ValidComponent = "div">( |
| 36 | props: PolymorphicProps<T, toggleGroupProps<T>>, |
| 37 | ) => { |
| 38 | const [local, rest] = splitProps(props as toggleGroupProps, [ |
| 39 | "class", |
| 40 | "children", |
| 41 | "size", |
| 42 | "variant", |
| 43 | ]); |
| 44 | |
| 45 | const value = createMemo<VariantProps<typeof toggleVariants>>(() => ({ |
| 46 | size: local.size, |
| 47 | variant: local.variant, |
| 48 | })); |
| 49 | |
| 50 | return ( |
| 51 | <ToggleGroupPrimitive |
| 52 | class={cn("flex items-center justify-center gap-1", local.class)} |
| 53 | {...rest} |
| 54 | > |
| 55 | <ToggleGroupContext.Provider value={value}> |
| 56 | {local.children} |
| 57 | </ToggleGroupContext.Provider> |
| 58 | </ToggleGroupPrimitive> |
| 59 | ); |
| 60 | }; |
| 61 | |
| 62 | type toggleGroupItemProps<T extends ValidComponent = "button"> = |
| 63 | ToggleGroupItemProps<T> & { |