lucide/packages/angular
Ken Kunz c1a02a04d4
fix(packages): allow string values for size and strokeWidth in global icon config (#4870)
* Allow string values for `size` and `strokeWidth` in icon contexts

The global icon context types declare `size` and `strokeWidth` as `number`,
while the component props they supply defaults for accept `number | string`.
The context value is passed through to the component untouched, so a CSS
length that works on a single icon is rejected when set as a default:

    setLucideProps({ size: '1em' });  // Type 'string' is not assignable to 'number'
    <Moon size="1em" />               // same value, same code path, no error

* Accept a string `size` on vue icon components

@lucide/vue types the component prop as `size?: 24 | number`, so it rejects the
CSS lengths its own `strokeWidth?: number | string` accepts, and that every other
framework accepts. The value goes straight to the `width`/`height` attributes,
so a string already works at runtime.

* Allow string `size` and `strokeWidth` in the icon context

Copilot's PR comment correctly surfaced a gap in the PR - the same type
bug exists in the lucide-react-native project and wasn't fixed there.

Same narrowing as the other framework contexts: `LucideProps` accepts
`size?: string | number`, and `strokeWidth` resolves to react-native-svg's
`NumberProp` (`string | number`), but the context and `LucideProviderProps`
declared both as `number`. `Icon.ts` passes the context value straight through
— `width: width ?? size ?? contextSize` — so nothing downstream needs a number.

* Don't emit NaN stroke width for non-numeric absolute lengths

`absoluteStrokeWidth` scales the stroke by `Number(size)`, so a CSS unit such
as `1em` produced `NaN` and a size of `0` produced `Infinity` – both invalid as
a `stroke-width` attribute. Fall back to the unscaled stroke width whenever the
conversion isn't finite, so the deprecated prop degrades rather than breaking
the rendered icon.

* fix(packages/angular): allow a string `strokeWidth` in the global config

`LucideConfig` already types `size` as `string | number` but left `strokeWidth`
as `number`, while `LucideIconBase` accepts `string | number` for both and
passes the configured value straight to the shared builder. So
`provideLucideConfig({ strokeWidth: '1em' })` was rejected for no reason.

* refactor(shared): keep absolute stroke scaling inside its branch

The finite-value fallback added in b65ee945 computed the scaled width before
testing `absoluteStrokeWidth`, so the default path paid for three `Number`
conversions and a division it never used. Start from the unscaled width and
overwrite it only when scaling both applies and yields a finite result, which
also states the rule more directly.

---------

Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
2026-11-20 14:43:11 +01:00
..
.vscode feat(packages/angular): add new @lucide/angular package (#3897) 2026-03-20 15:31:34 +01:00
scripts feat(packages/angular): add new @lucide/angular package (#3897) 2026-03-20 15:31:34 +01:00
src fix(packages): allow string values for size and strokeWidth in global icon config (#4870) 2026-11-20 14:43:11 +01:00
angular.json feat(pipeline): revert to working-directory solution for testing 2026-03-24 16:10:24 +01:00
eslint.config.mjs chore(dev): upgrade ESLint to latest compatible stack (v10) (#4378) 2026-08-18 13:09:22 +02:00
MIGRATION.md feat(packages/angular): add new @lucide/angular package (#3897) 2026-03-20 15:31:34 +01:00
ng-package.json fix(packages/angular): remove ./ from ng-packagr paths 2026-03-24 15:36:16 +01:00
package.json chore(deps-dev): bump the angular-deps group across 1 directory with 15 updates (#5114) 2026-11-02 18:00:37 +01:00
README.md feat(site): Add sponsor page (#5132) 2026-11-02 12:21:25 +01:00
tsconfig.json chore(dependencies): Update dependencies (#4806) 2026-09-04 17:34:58 +02:00
tsconfig.lib.json feat(packages/angular): add new @lucide/angular package (#3897) 2026-03-20 15:31:34 +01:00
tsconfig.lib.prod.json feat(packages/angular): add new @lucide/angular package (#3897) 2026-03-20 15:31:34 +01:00
tsconfig.spec.json feat(packages/angular): add new @lucide/angular package (#3897) 2026-03-20 15:31:34 +01:00

Lucide icon library for Angular applications.

Lucide icon library for Angular applications.

npm NPM Downloads License

About · Icons · Documentation · License

Lucide Angular

A standalone, signal based, zoneless implementation of the Lucide icon library for Angular applications.

Installation

pnpm add @lucide/angular
npm install @lucide/angular
yarn add @lucide/angular
bun add @lucide/angular

Documentation

For full documentation, visit lucide.dev

Migration guide

Migrating from lucide-angular? Read our comprehensive migration guide.

Community

Join the Discord server to chat with the maintainers and other users.

License

Lucide is licensed under the ISC license. See LICENSE.

Sponsors

Powered by Vercel

Bronze 🥉

Sourcegraph – Understand, fix, and automate across your codebase with Sourcegraph's code intelligence platform    Zephyr Cloud

Other contributors 💸

You can find all our past and non-recurring financial contributors at our Open Collective page.