vueform / multiselect

Vue 3 multiselect component with single select, multiselect and tagging options (+Tailwind CSS support).
https://vueform.com
MIT License
807 stars 150 forks source link

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

Open andrewskipolski opened 9 months ago

andrewskipolski commented 9 months ago

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 commented 9 months ago

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 commented 6 months ago

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>