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
This commit is contained in:
Ken Kunz
2026-09-15 22:48:50 -05:00
parent 58ef6830c6
commit 6fd4f5173c
5 changed files with 14 additions and 14 deletions
+4 -4
View File
@@ -2,9 +2,9 @@ import { createContext, h, type ComponentChildren } from 'preact';
import { useContext, useMemo } from 'preact/hooks';
const LucideContext = createContext<{
size?: number;
size?: number | string;
color?: string;
strokeWidth?: number;
strokeWidth?: number | string;
/**
* @deprecated Use `nonScalingStroke` instead.
*/
@@ -22,9 +22,9 @@ const LucideContext = createContext<{
interface LucideProviderProps {
children: ComponentChildren;
size?: number;
size?: number | string;
color?: string;
strokeWidth?: number;
strokeWidth?: number | string;
/**
* @deprecated Use `nonScalingStroke` instead.
*/
+2 -2
View File
@@ -4,9 +4,9 @@ import { createContext, createElement, type ReactNode, useContext, useMemo } fro
import { LucideProps } from './types';
type LucideConfig = {
size: number;
size: number | string;
color: string;
strokeWidth: number;
strokeWidth: number | string;
/**
* @deprecated Use `nonScalingStroke` instead.
*/
+4 -4
View File
@@ -1,9 +1,9 @@
import { createContext, splitProps, type JSXElement } from 'solid-js';
export const LucideContext = createContext<{
size?: number;
size?: number | string;
color?: string;
strokeWidth?: number;
strokeWidth?: number | string;
/**
* @deprecated Use `nonScalingStroke` instead.
*/
@@ -21,9 +21,9 @@ export const LucideContext = createContext<{
interface LucideProviderProps {
children: JSXElement;
size?: number;
size?: number | string;
color?: string;
strokeWidth?: number;
strokeWidth?: number | string;
/**
* @deprecated Use `nonScalingStroke` instead.
*/
+2 -2
View File
@@ -4,8 +4,8 @@ const LucideContext = Symbol('lucide-context');
export interface LucideGlobalContext {
color?: string;
size?: number;
strokeWidth?: number;
size?: number | string;
strokeWidth?: number | string;
/**
* @deprecated Use `nonScalingStroke` instead.
*/
+2 -2
View File
@@ -3,9 +3,9 @@ import { provide, inject } from 'vue';
export const LUCIDE_CONTEXT = Symbol('lucide-icons');
interface LucideIconsContext {
size?: number;
size?: number | string;
color?: string;
strokeWidth?: number;
strokeWidth?: number | string;
/**
* @deprecated Use `nonScalingStroke` instead.
*/