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

Different clearIcon svg fill color for dark and light mode #397

Open
andrewskipolski opened this issue Feb 23, 2024 · 2 comments
Open

Different clearIcon svg fill color for dark and light mode #397

andrewskipolski opened this issue Feb 23, 2024 · 2 comments

Comments

@andrewskipolski
Copy link

Using tailwind how can I apply different fill colours for remove button svg in dark mode and light mode?

        'multiselect-remove': `url("${svgToDataUri(
          `<svg viewBox="0 0 320 512" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"></path></svg>`,
        )}")`,
@andrewskipolski
Copy link
Author

the only method I figured out for now is to replace background svg inside component:

<style>
  @media (prefers-color-scheme: dark) {
          .bg-multiselect-remove {  
            background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 320 512' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z'%3e%3c/path%3e%3c/svg%3e");
          }
        }
</style>

@mathieutu
Copy link

On my side, I'm using the slots to handle the icons.

<template #clear="{ clear }">
  <button type="button" title="Clear the field" class="absolute inset-y-0 right-0 mr-5 flex items-center px-2 text-gray-400 hover:text-gray-600 focus:outline-none" @click="clear">
    <XMarkIcon
      class="size-4 "
      aria-hidden="true"
    />
  </button>
</template>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants