Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Svelte Flowbite Tooltip not showing prettified JSON

I am building a simple Svelte application to show JSON in a tooltip. However, it is not show prettified (nicely formatted) JSON.

I am using the Flowbite Svelte Tooltip.

MyComponent.svelte

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<script>
    import { Tooltip } from 'flowbite-svelte'
    export let content
</script>

<div>
    <div>Content</div>
    <Tooltip arrow={true} type="custom" defaultClass="" class="p-4 font-medium bg-primary-100 w-2/5">
        {JSON.stringify(content, null, 4)}
    </Tooltip>
</div>

The tooltip is showing up fine but the JSON that is shown is all in a single line instead of being nicely formatted (human readable). I’ve tried JSON.stringify(content, null, '\t')

Like this:

enter image description here

How do I get the JSON to show up in the tooltip in a nicely formatted way and not all in a single line.

As a separate issue, the tooltip arrow is now appearing despite me having arrow={true} so not sure about that either.

>Solution :

It’s a matter of whitespace handling, setting white-space to something like pre-wrap should work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading