Skip to content

Conversation

@ericfennis
Copy link
Member

@ericfennis ericfennis commented Jun 13, 2025

Closes #2884

Adds context providers to globally adjust props on lucide icons.

Todo:

  • React
  • Svelte
  • Vue
  • Solid
  • Preact
  • Write Docs -> update docs branch

@github-actions github-actions bot added the 🪝 solid package About the Solid package label Jul 4, 2025
@jguddas
Copy link
Member

jguddas commented Jul 4, 2025

I would vote against this and would add support for this use case by pointing people to use css variables.

Purely due to the introduced complexity and performance impact.

@github-actions github-actions bot added ⚛️ react package Lucide React Package ⚛️ react native package About the React Native package labels Jul 4, 2025
@github-actions github-actions bot added 📦 dependencies Pull requests that update a dependency file ⚛️ preact package About the Preact Package labels Jul 4, 2025
@ericfennis
Copy link
Member Author

Docs will be written in a different branch

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@ericfennis ericfennis requested a review from Copilot October 16, 2025 17:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 45 out of 46 changed files in this pull request and generated 6 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@mathhulk
Copy link

mathhulk commented Nov 3, 2025

I have always been very curious why Lucide does not implement a provider. Has there been any previous discussion about this? We want to default our size to 16 instead of 24 but right now either have to implement a custom Icon component which wraps every icon or fork and set the default size to 16 ourselves. Obviously, neither of these are ideal.

@ericfennis
Copy link
Member Author

@mathhulk Not sure which framework and package you are using, but isn't that possible with CSS. See: https://lucide.dev/guide/advanced/global-styling

@joceqo
Copy link

joceqo commented Nov 19, 2025

this is the only PR on making a context to adjust default props but to also possibly pass a default class to have to create a new component or pass to every lucide icon this ?

https://lucide.dev/guide/basics/sizing#dynamically-change-the-icon-size-based-on-the-font-size

@ericfennis
Copy link
Member Author

@joceqo So if i'm understand correctly. You would like the adjust classNames as well?

@joceqo
Copy link

joceqo commented Nov 28, 2025

The main thing i would want to change currently with lucide is to have it possible to set width and height to 1em by default so i could wrap icon in Typographic component that handle size for all text and i would then just treat icons as text. I'm curious if this PR will allow this, because passing a specific class for this to every lucide icon is cumbersome

@ericfennis
Copy link
Member Author

Good point

@LeunensMichiel
Copy link

LeunensMichiel commented Dec 8, 2025

Quick question:

Using lucide in a react-native project, this would be the new preferred way for global styling right? Right now we have to manually provide props to each icon we use, or use a wrapper icon (which as the docs state, is not the preferred way because of importing the whole bundle)

Or am I missing something? Either way thank you for your work!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 45 out of 47 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (3)

packages/lucide-react/src/Icon.tsx:51

  • Missing fallback to defaultAttributes.stroke when both color and contextColor are undefined. Unlike React Native implementation (line 42) which includes this fallback, this could result in an undefined stroke value. For consistency and safety, add ?? defaultAttributes.stroke at the end.
    packages/vue/src/Icon.ts:72
  • The class prop from the parent component is missing from the class merging. The code includes contextClass but not props.class, which means any class passed directly to the icon component will be lost. The mergeClasses function should include props.class to preserve classes passed to the icon.
    packages/lucide-react-native/src/createLucideIcon.ts:5
  • Unused imports mergeClasses, toKebabCase.
import { mergeClasses, toKebabCase, toPascalCase } from '@lucide/shared';

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 45 out of 47 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/vue/src/Icon.ts:72

  • The props.class is missing from the mergeClasses call. The context class and generated icon classes are merged, but the component's own class prop is not included. This means any class passed directly to the icon component will be lost.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ericfennis ericfennis marked this pull request as ready for review December 12, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 dependencies Pull requests that update a dependency file 📖 documentation Improvements or additions to documentation 🚀 Lucide v1 ⚛️ preact package About the Preact Package ⚛️ react native package About the React Native package ⚛️ react package Lucide React Package 🌍 site Has to do something with the Lucide website 🪝 solid package About the Solid package 🧣 svelte package About the Svelte package 💎 vue package Lucide Vue package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow users to modify the default attributes

7 participants