nuxt / nuxt/icon

[BUG] `customize` option doesnt work

Open
#529 0 comments 0 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

It just doesn't work. I followed the instructions in the README, but nothing happens.

Operating system Windows 10.0.26200
CPU Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz (8 cores)
Node.js version v22.23.2
nuxt/cli version 3.37.0
Package manager pnpm@11.20.0
Nuxt version 4.5.2
Nitro version 2.13.4
Builder vite@8.2.1
Config compatibilityDate, css, dayjs, devtools, fonts, icon, ignore, modules, vite
Modules @nuxt/eslint@1.17.0, @nuxt/fonts@0.14.0, @nuxt/icon@2.4.1, @nuxt/image@2.1.0, @vueuse/nuxt@14.4.0, dayjs-nuxt@2.1.11 **
// nuxt.config.ts
export default defineNuxtConfig({
  ...
  modules: [
    ...
    '@nuxt/icon',
  ],
  icon: {
    mode: 'svg',
    clientBundle: {
      scan: true,
      includeCustomCollections: true,
    },
  },
})
// app.config.ts
export default defineAppConfig({
  icon: {
    customize: (content: string, name: string, prefix: string, provider: string) => {
      if (prefix !== 'tabler') return content // Ignore Prefix

      return content
        .replace(/stroke-width="[^"]*"/g, `stroke-width="5"`) // Change stroke width to **5**
        .replace(/stroke="[^"]*"/g, `stroke="#FF5733"`) // Change stroke color to red
        .replace(/fill="[^"]*"/g, `fill="#FF5733"`) // Change fill color to red
        .replace(/animation-duration="[^"]*"/g, `animation-duration="1s"`) // Change animation duration to 1s (for animated icons)
        .replace(/opacity="[^"]*"/g, `opacity="0.8"`);// Change opacity to 0.8
    }
  }
})

// Code in the project
<Icon
  name="tabler:bulb"
  class="-ml-0.5 mb-0.5 inline-block"
/>
// Rendered icon
<svg
  xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  aria-hidden="true"
  role="img"
  class="iconify iconify--tabler -ml-0.5 mb-0.5 inline-block"
  style=""
  width="1em"
  height="1em"
  viewBox="0 0 24 24"
>
  <path
    fill="none"
    stroke="currentColor"
    stroke-linecap="round"
    stroke-linejoin="round"
    stroke-width="2"
    d="M3 12h1m8-9v1m8 8h1M5.6 5.6l.7.7m12.1-.7l-.7.7M9 16a5 5 0 1 1 6 0a3.5 3.5 0 0 0-1 3a2 2 0 0 1-4 0a3.5 3.5 0 0 0-1-3m.7 1h4.6"
  ></path>
</svg>

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 app.config.ts customize callback and the nuxt.config.ts icon clientBundle settings, then reproduce the tabler:bulb example and compare its rendered SVG with the expected changes. Done means the customize callback applies the requested stroke, fill, animation-duration, and opacity changes to the rendered icon.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.