diff --git a/packages/react/components/Tooltip.tsx b/packages/react/components/Tooltip.tsx index 0a27845..5dd0227 100644 --- a/packages/react/components/Tooltip.tsx +++ b/packages/react/components/Tooltip.tsx @@ -1,5 +1,5 @@ import React, { useState } from "react"; -import { VariantProps, vcn } from "@pswui-lib"; +import { AsChild, Slot, VariantProps, vcn } from "@pswui-lib"; interface TooltipContextBody { position: "top" | "bottom" | "left" | "right"; @@ -48,18 +48,26 @@ const [tooltipVariant, resolveTooltipVariantProps] = vcn({ interface TooltipProps extends React.HTMLAttributes, - VariantProps {} + VariantProps, + AsChild {} const Tooltip = React.forwardRef((props, ref) => { const [variantProps, rest] = resolveTooltipVariantProps(props); + const { asChild, ...extractedRest } = rest; const contextState = useState({ ...tooltipContextInitial, ...variantProps, }); + const Comp = asChild ? Slot : "div"; + return ( -
+ ); });