Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rx.cond with Literal Values for tag in rx.icon #4628

Closed
sorousch9 opened this issue Jan 13, 2025 · 2 comments
Closed

Support rx.cond with Literal Values for tag in rx.icon #4628

sorousch9 opened this issue Jan 13, 2025 · 2 comments
Assignees

Comments

@sorousch9
Copy link

sorousch9 commented Jan 13, 2025

Describe the bug
Currently, using rx.cond with literal string values for the tag argument in rx.icon raises issues with safety or functionality. This limits the ability to dynamically assign icons based on a conditional state in a clear and concise manner.

To Reproduce
Steps to reproduce the behavior:

rx.icon(tag=rx.cond(MyState.bool, "arrow-up-wide-narrow", "arrow-down-narrow-wide"))

Expected behavior
It should be possible to use rx.cond with literal values for the tag argument safely and without requiring workarounds. The expected functionality would dynamically resolve the tag value based on the conditional expression.

Specifics (please complete the following information):

  • Python Version: 3.13.1
  • Reflex Version:0.6.7
  • OS: WSL2

Additional context
A potential workaround for this issue is to wrap the rx.icon calls within the rx.cond as follows:

rx.cond(
    MyState.bool,
    rx.icon(tag="arrow-up-wide-narrow"),
    rx.icon(tag="arrow-down-narrow-wide")
)

This workaround avoids the direct use of literal values with rx.cond, but a built-in solution would streamline development and improve code clarity.

Copy link

linear bot commented Jan 13, 2025

@Lendemor
Copy link
Collaborator

I don't think this particular feature would work for rx.icon because the name need to be known during compilation for the import to work.

I'm tempted to mark this one as closed once we merge the dynamic Icon PR, unless we have other use case that would require this outside of rx.icon ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants