themesberg / flowbite-svelte

Official Svelte components built for Flowbite and Tailwind CSS
https://flowbite-svelte.com
MIT License
2.17k stars 267 forks source link

[Feature] Add ability to customize default tooltip classes #201

Closed dennismphil closed 2 years ago

dennismphil commented 2 years ago

Summary

A brief explanation of the feature.

Can we please add the ability to customize the tooltip?

Basic example

<Tooltip
    content="tooltip text"

    <!-- proposal -->
    textClass="font-xs z-100"
    arrowClass="..."
    containerClass="..."
>
    <Button ... />
</Tooltip>

If the proposal involves a new or changed API, include a basic code example. Omit this section if it's not applicable.

Motivation

Why are we doing this? What use cases does it support? What is the expected outcome?

The z-index of other absolute positioned elements in the application interferes with the default z-index given. By giving the flexibility to customize the class of the tooltip elements, we solve this problem. Also, this provides developers to customize the font size, color, and allow for custom styling

shinokada commented 2 years ago

Can you use class in the Tooltip component:

<script>
    import { Tooltip, Button } from 'flowbite-svelte';
</script>

<div class="p-24" >
  <Tooltip content="Tooltip content" class="text-red-700">
    <Button>Default tooltip</Button>
  </Tooltip>
</div>

Demo

dennismphil commented 2 years ago

Thanks for the detailed demo on stackblitz.

The documentation is missing the class property

2022-08-03_05-58-56

I attempted using the class, but the classes rarely work due to conflicts and not being applied to the correct containers. Examples are noted below

  1. We cannot customize the padding of the tooltip
  2. We cannot change the font size due to the conflicting classes

2022-08-03_05-52-16

shinokada commented 2 years ago

I updated the Tooltip component, v0.22.30. You can find the doc at https://flowbite-svelte.com/tooltips#Custom_style. Let me know what you think.

dennismphil commented 2 years ago

Tested and this works like magic. Thank you.

Only a minor nit in the documentation .. Would be perfect if tipClass and tipColor is listed in the documentation here as well 

2022-08-03_09-50-08

Many thanks

shinokada commented 2 years ago

Yes, I will update the props. Thanks.