-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: accordion #1075
base: main
Are you sure you want to change the base?
feat: accordion #1075
Conversation
@ui.component | ||
def ui_accordion_event(): | ||
expanded_keys, set_expanded_keys = ui.use_state([]) | ||
|
||
def handle_expanded_keys_change(e): | ||
set_expanded_keys(e) | ||
print("Expanded key changed") | ||
|
||
return ui.accordion( | ||
ui.disclosure(title="FAQ #1", panel="Answer", id="a"), | ||
ui.disclosure(title="FAQ #2", panel="Answer", id="b"), | ||
expanded_keys=expanded_keys, | ||
on_expanded_change=lambda k: set_expanded_keys(k), | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of printing to console, we should just show it underneath. e.g.
@ui.component | |
def ui_accordion_event(): | |
expanded_keys, set_expanded_keys = ui.use_state([]) | |
def handle_expanded_keys_change(e): | |
set_expanded_keys(e) | |
print("Expanded key changed") | |
return ui.accordion( | |
ui.disclosure(title="FAQ #1", panel="Answer", id="a"), | |
ui.disclosure(title="FAQ #2", panel="Answer", id="b"), | |
expanded_keys=expanded_keys, | |
on_expanded_change=lambda k: set_expanded_keys(k), | |
) | |
@ui.component | |
def ui_accordion_event(): | |
expanded_keys, set_expanded_keys = ui.use_state([]) | |
return ui.view( | |
ui.accordion( | |
ui.disclosure(title="FAQ #1", panel="Answer", id="a"), | |
ui.disclosure(title="FAQ #2", panel="Answer", id="b"), | |
expanded_keys=expanded_keys, | |
on_expanded_change=set_expanded_keys, | |
), | |
ui.heading("Currently expanded: ", expanded_keys) | |
) | |
Also we should have better/different content for each, and the id should match the disclosure titles.
) | ||
|
||
|
||
my_accordion_event = ui_accordion_event() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should an example with allows_multiple_expanded
as well.
Closes #18136
Wait for ui.disclosure to merge