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

radiogroup high level api #2401

Merged
merged 13 commits into from Jan 19, 2024
Merged

radiogroup high level api #2401

merged 13 commits into from Jan 19, 2024

Conversation

tgberkeley
Copy link
Collaborator

@tgberkeley tgberkeley commented Jan 16, 2024

Must import as shown" from reflex.components.radix.themes.components import *

Most basic usage, pass in a list of strings :

radio_group(["1", "2", "3", "4", "5"])

Can set several props such as direction, gap:

radio_group(["1", "2", "3", "4", "5"], direction="row", gap="6"))

and any other prop that the RadioGroupRoot component takes:

radio_group(["1", "2", "3", "4", "5"], direction="row", gap="6", variant="soft", size="3", color_scheme="red", default_value="3")

The list of strings passed can also be a state var and this will still work

from reflex.components.radix.themes.components import *


class State(rx.State):
    """The app state."""

    rad: list[str] = ["Name", "Age", "Location"]


def index():
    """The main view."""
    return rx.center(
        rx.vstack(
            radio_group(["1", "2", "3", "4", "5"]),
            radio_group(State.rad),
            radio_group(["1", "2", "3", "4", "5"], direction="row", gap="6")),
            radio_group(["1", "2", "3", "4", "5"], direction="row", gap="6", variant="soft", size="3", color_scheme="red", default_value="3"),
        ),
    )

app = rx.App()
app.add_page(index)

Flex.create(
RadioGroupItem.create(value=value),
value,
gap="2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this also use the passed gap for consistency?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the gap=2 is the distance between the radio group and the text it is associated with. The gap that we allow the user to pass is the distance between the different radio group items. I therefore do not think they should be passed the same value, and think we should keep the value between the radio group and the text fixed.
Screenshot 2024-01-17 at 9 58 14 AM

@picklelo picklelo merged commit 676f2c5 into main Jan 19, 2024
43 checks passed
Alek99 pushed a commit that referenced this pull request Jan 24, 2024
@picklelo picklelo deleted the high-level-api-radio-group branch January 30, 2024 03:08
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.

None yet

3 participants