Raxol.UI.Components.Patterns.Compound (Raxol v2.0.1)
View SourceCompound Components pattern for Raxol UI.
Components designed to work together with shared implicit state and flexible composition. Parent manages shared state, children handle individual concerns.
Usage
# Accordion example
%{
type: :accordion,
children: [
%{
type: :accordion_item,
children: [
%{type: :accordion_trigger, children: [text("Section 1")]},
%{type: :accordion_content, children: [text("Content 1")]}
]
}
]
}
Summary
Functions
Accordion root component that manages expanded state and provides context to children.
Accordion content that is shown/hidden based on the item's expanded state.
Accordion item that represents a single collapsible section.
Accordion trigger that toggles the item's expanded state when clicked.
Dropdown root component that manages open state and provides context.
Dropdown content that contains the dropdown menu items.
Dropdown item that represents a single menu option.
Dropdown separator that visually separates groups of menu items.
Dropdown trigger that opens/closes the dropdown when clicked.
Tabs root component that manages active tab state.
Tab content panel that displays content for a specific tab.
Tabs list that contains the tab triggers.
Tab trigger that switches to a specific tab when clicked.
Functions
Accordion root component that manages expanded state and provides context to children.
Props
:type- :single (only one item open) or :multiple (multiple items can be open):default_value- Default expanded item(s):collapsible- Whether items can be collapsed (for :single type):on_value_change- Callback when expanded items change
Context Provided
:expanded_items- Set of currently expanded item values:toggle_item- Function to toggle an item's expanded state:accordion_type- The accordion type (:single or :multiple)
Accordion content that is shown/hidden based on the item's expanded state.
Accordion item that represents a single collapsible section.
Props
:value- Unique identifier for this item (required):disabled- Whether this item is disabled
Accordion trigger that toggles the item's expanded state when clicked.
Dropdown root component that manages open state and provides context.
Props
:open- Controlled open state:default_open- Default open state (uncontrolled):on_open_change- Callback when open state changes:placement- Dropdown placement (:bottom, :top, :left, :right)
Dropdown content that contains the dropdown menu items.
Dropdown item that represents a single menu option.
Props
:value- Value associated with this item:disabled- Whether this item is disabled:on_select- Callback when this item is selected
Dropdown separator that visually separates groups of menu items.
Dropdown trigger that opens/closes the dropdown when clicked.
Tabs root component that manages active tab state.
Props
:value- Controlled active tab value:default_value- Default active tab (uncontrolled):on_value_change- Callback when active tab changes:orientation- :horizontal or :vertical
Tab content panel that displays content for a specific tab.
Props
:value- The tab value this content is associated with (required)
Tabs list that contains the tab triggers.
Tab trigger that switches to a specific tab when clicked.
Props
:value- The tab value this trigger activates (required):disabled- Whether this tab is disabled