nuxt / nuxt/icon

Can't apply color to custom icons

Open
#402 5 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
96
Avg merge
8h 12m
Merged PRs (30d)
2

Description

I'm using icons library on Nuxt UI (still I don't know whose issue this is) for my Nuxt project which uses Tailwind v4 , and I set up some custom icons through a JSON file:

{
    "icons": {
        "arrow-small-right": {
            "body": "<path fill=\"currentColor\" d=...
        },
        "auction": {
            "body": "<path fill=\"currentColor\" d=...
        },
...
    }
}
// nuxt.config.ts

import customIcons from './icons.json' with { type: 'json' };

...

 icon: {
        customCollections: [{
            prefix: 'custom',
            icons: customIcons.icons,
            width: 512,
            height: 512,
        }],
    }

They can be imported, however when I try to change their color like text-white or fill-white, it doesn't work.

What I noticed is that icons imported from Iconify have important css rules such as mask-*, while mine don't.
So how am I supposed to inject these rules inside them, if there is a way?

p.s. sorry for creating my issue without completing it

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the custom icon configuration in nuxt.config.ts and the icon definitions in icons.json, then compare how these icons are rendered with the Iconify icons that receive mask rules. Reproduce the issue using text-white and fill-white on a custom icon. Done means custom icons respond to color classes or the supported limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, tailwindcss, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.