Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing side prop for tooltip #988

Closed
lrwagner opened this issue Apr 3, 2024 · 4 comments
Closed

missing side prop for tooltip #988

lrwagner opened this issue Apr 3, 2024 · 4 comments
Labels
type: feature Introduction of new functionality to the application

Comments

@lrwagner
Copy link

lrwagner commented Apr 3, 2024

Describe the feature

The original tooltip component has a side prop to define on which side ("left" | "right" | "bottom" | "top") the tooltip will be rendered.

I'm happy to contribute, if you point me in the right direction, I assume this shouldn't be too complicated.

@lrwagner lrwagner added the type: feature Introduction of new functionality to the application label Apr 3, 2024
@huntabyte
Copy link
Owner

huntabyte commented Apr 3, 2024

It does have a side prop. It's passed to the primitive via $$restProps.

<Tooltip.Content side='left' >

@lrwagner
Copy link
Author

lrwagner commented Apr 4, 2024

Hm, something seems wrong with my setup then, I get the following error when adding the side prop, also the tooltip doesn't seem to behave according to the setting:
1. Object literal may only specify known properties, and '"side"' does not exist in type 'ContentProps'. [2353]

{#each tabs as tab}
	<Tooltip.Root>
		<Tooltip.Trigger asChild let:builder>
			<a
				href={tab.href}
				class="flex h-9 w-9 items-center justify-center rounded-lg transition-colors {activeStyle(
					tab.href,
					$page.url
				)} hover:text-foreground md:h-8 md:w-8"
				use:builder.action
				{...builder}
			>
				<svelte:component this={tab.icon} class="h-5 w-5" />
				<span class="sr-only">{tab.title}</span>
			</a>
		</Tooltip.Trigger>
		<Tooltip.Content side='right'>{tab.title}</Tooltip.Content>
	</Tooltip.Root>
{/each}

This is how the installed component looks like

<script lang="ts">
	import { Tooltip as TooltipPrimitive } from "bits-ui";
	import { cn, flyAndScale } from "$lib/utils.js";

	type $$Props = TooltipPrimitive.ContentProps;

	let className: $$Props["class"] = undefined;
	export let sideOffset: $$Props["sideOffset"] = 4;
	export let transition: $$Props["transition"] = flyAndScale;
	export let transitionConfig: $$Props["transitionConfig"] = {
		y: 8,
		duration: 150,
	};
	export { className as class };
</script>

<TooltipPrimitive.Content
	{transition}
	{transitionConfig}
	{sideOffset}
	class={cn(
		"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md",
		className
	)}
	{...$$restProps}
>
	<slot />
</TooltipPrimitive.Content>

@huntabyte
Copy link
Owner

Are you running the latest version of bits-ui?

@lrwagner
Copy link
Author

lrwagner commented Apr 4, 2024

Indeed, updating bits-ui to the latest version fixed it - thanks for your help and the amazing work on this library 😊

@lrwagner lrwagner closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

2 participants