svelte-toast icon indicating copy to clipboard operation
svelte-toast copied to clipboard

Question: Styling Using TailwindCSS

Open nickpoulos opened this issue 2 years ago • 1 comments

Hello, I was hoping to use this library but to re-style the component using a class based approach, a la TailwindCSS.

From the docs I was unsure how to go about this, it seems like only CSS variables or Svelte style block is supported.

Is it possible to add custom classes to various pieces of this toast component?

Thanks!

nickpoulos avatar Jun 02 '23 14:06 nickpoulos

Hey, you can try applying tailwind classes with user-defined classes. The classes are applied to each toast item. YMMV though, because of CSS specificity.

Generally I'll recommend using the exposed CSS vars and/or the Svelte :global modifier.

<div class="wrap">
  <SvelteToast />
</div>

<style lang="postcss">
.wrap :global(.toastItem) {
  --toastPadding: 1rem;
  ...
  @apply text-xs font-bold ...;
}
</style>

zerodevx avatar Jun 03 '23 19:06 zerodevx