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

[REF-3135]Radix Primitive components should not ignore provided class_name prop #3676

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

ElijahAhianyo
Copy link
Collaborator

@ElijahAhianyo ElijahAhianyo commented Jul 16, 2024

Currently, for radix primitives, the class_name is set to the tag name of the component, so if you provide a class-name for a primitive component(eg. rx.form), the provided class name will be stripped off or overridden.
With this PR, we respect the provided class_name which now allows us to achieve something like this:

def index():
    return rx.vstack(
        rx.form(
            rx.vstack(
                rx.input(
                    placeholder="First Name",
                    name="first_name",
                ),
                rx.input(
                    placeholder="Last Name",
                    name="last_name",
                ),
                rx.hstack(
                    rx.checkbox("Checked", name="check"),
                    rx.switch("Switched", name="switch"),
                ),
                rx.button("Submit", type="submit"),
            ),
            on_submit=FormState.handle_submit,
            reset_on_submit=True,
            class_name="bg-white p-6 rounded-lg shadow-md w-full max-w-sm"
        ),
    )

The renderered js code is now:

return (
    <RadixFormRoot className={`Root bg-white p-6 rounded-lg shadow-md w-full max-w-sm`} css={{ "width": "100%" }} onSubmit={handleSubmit_deab2d5728fb5f3e32b00729f023971b}>
      ...
    </RadixFormRoot>
  )

@ElijahAhianyo ElijahAhianyo changed the title Radix Primitive components should not ignore provided class_name prop [REF-3135]Radix Primitive components should not ignore provided class_name prop Jul 16, 2024
Copy link

linear bot commented Jul 16, 2024

@ElijahAhianyo ElijahAhianyo marked this pull request as ready for review July 16, 2024 15:22
picklelo
picklelo previously approved these changes Jul 17, 2024
Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

nice catch

@picklelo picklelo merged commit 1bc1978 into main Jul 18, 2024
47 checks passed
@masenf masenf deleted the elijah/radix-primitives-class-name branch December 12, 2024 07:18
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

Successfully merging this pull request may close these issues.

2 participants