Skip to content

Commit aab3c5b

Browse files
Update collapsible component with Base UI transitions and styling
- Add proper Base UI transition classes to PANEL with data-[ending-style]:h-0 data-[starting-style]:h-0 - Update demo to match Base UI example with chevron icon and recovery keys styling - Component tested successfully in browser with smooth transitions and event handling - Follows official Base UI collapsible example pattern Co-Authored-By: Carlos Cutillas <[email protected]>
1 parent b392991 commit aab3c5b

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

demo/demo/demo.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,19 @@ def index() -> rx.Component:
5959
on_open_change=lambda value: rx.toast.success(f"Open: {value}"),
6060
),
6161
ui.collapsible(
62-
trigger=ui.button("Toggle Content", variant="outline"),
62+
trigger=ui.button(
63+
rx.el.span("▶", class_name="transition-all ease-out group-data-[panel-open]:rotate-90 inline-block mr-2"),
64+
"Recovery keys",
65+
variant="outline",
66+
class_name="group flex items-center gap-2 rounded-sm bg-gray-100 px-2 py-1 text-sm font-medium hover:bg-gray-200 focus-visible:outline focus-visible:outline-2 focus-visible:outline-blue-800 active:bg-gray-200",
67+
),
6368
content=rx.el.div(
64-
"This is the collapsible content! It can contain any components.",
65-
rx.el.p("Here's another paragraph inside the collapsible panel."),
66-
class_name="p-4 bg-secondary-2 rounded-md mt-2",
69+
rx.el.div("alien-bean-pasta", class_name="text-sm"),
70+
rx.el.div("wild-irish-burrito", class_name="text-sm"),
71+
rx.el.div("horse-battery-staple", class_name="text-sm"),
72+
class_name="mt-1 flex cursor-text flex-col gap-2 rounded-sm bg-gray-100 py-2 pl-7",
6773
),
74+
class_name="flex min-h-36 w-56 flex-col justify-center text-gray-900",
6875
on_open_change=lambda value: rx.toast.success(f"Collapsible open: {value}"),
6976
),
7077
ui.theme_switcher(class_name="absolute top-4 right-4"),

reflex_ui/components/base/collapsible.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ClassNames:
1313

1414
ROOT = ""
1515
TRIGGER = "cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-primary-4"
16-
PANEL = "overflow-hidden transition-all duration-200 data-[state=closed]:animate-collapse-up data-[state=open]:animate-collapse-down"
16+
PANEL = "flex h-[var(--collapsible-panel-height)] flex-col justify-end overflow-hidden transition-all ease-out data-[ending-style]:h-0 data-[starting-style]:h-0"
1717

1818

1919
class CollapsibleBaseComponent(BaseUIComponent):

0 commit comments

Comments
 (0)