Knowledge Base updated: 2026-09-01
Petal Components knowledge base
Petal Components is a Phoenix component library. Its Elixir modules render reusable HEEx components, while the bundled browser hooks add LiveView-aware behavior for focus, overlays, sorting, uploads, and other DOM interactions.
The primary implementation surface is lib/petal_components/, organized by component. Client behavior is bundled from assets/js/, and visual defaults are supplied through CSS and SVG asset infrastructure. Form and overlay components are the principal boundary where server-rendered contracts coordinate with browser state.
Developer-facing design skill material packages Petal component guidance, patterns, tokens, and evaluation references alongside snapshot-oriented tooling.
flowchart TD
App[Phoenix application] --> PC[Petal Components API]
PC --> Forms[Form controls]
PC --> Overlays[Overlays and menus]
PC --> Data[Data presentation]
PC --> Layout[Layout and content]
PC --> Feedback[Feedback and live updates]
PC --> Assets[Styles and icon assets]
Forms --> LV[LiveView-rendered HEEx]
Overlays --> LV
Data --> LV
Layout --> LV
Feedback --> LV
LV --> Hooks[petal_components.js hooks]
Hooks --> DOM[Browser DOM and focus state]
Assets --> DOM
Skill[Design skill tooling] --> Guidance[Petal design skill]
Glossary
- Petal Components — the library's reusable Phoenix function components and associated browser assets.
- Hook bundle — assets/…/petal_components.js, the client-side LiveView hook entry point used by interactive components.
- Field contract — the form-field naming, value, error, and state conventions shared by form controls.
- Slide-over — a dismissible off-canvas overlay component coordinated with focus and visibility behavior.
- Design skill — packaged Petal guidance and reference material for selecting and evaluating component experiences.
Codebase-wide invariants
- Interactive component markup and browser behavior must agree on hook names and required DOM attributes; the shared hook bundle is assets/…/petal_components.js.
- Form controls must preserve Phoenix form/changeset-compatible field names, values, and validation errors; see the shared patterns in
lib/petal_components/field.ex. - Overlays must provide a usable dismissal and focus lifecycle rather than only toggling visibility; modal-like implementations include
lib/petal_components/slide_over.ex. - Component APIs remain server-rendered HEEx interfaces, with JavaScript used to augment rather than replace LiveView-rendered state; component modules live under
lib/petal_components/*.ex. - Styling and icon consumers must use the library's provided asset conventions rather than assuming application-specific generated markup; see
assets/css/**andpriv/static/**.
Routing table
lib/petal_components/field.ex,lib/petal_components/form.ex,lib/petal_components/input.ex,lib/petal_components/input_group.ex,lib/petal_components/otp_input.ex-> Form controls and validationlib/petal_components/input.ex,lib/petal_components/input_group.ex,lib/petal_components/otp_input.ex,lib/petal_components/combo_box.ex-> Text and structured inputslib/petal_components/toggle_group.ex,lib/petal_components/rating.ex,lib/petal_components/language_selector.ex,lib/petal_components/color_scheme_switch.ex-> Selection controlslib/petal_components/calendar.ex,lib/petal_components/date_picker.ex,lib/petal_components/number_input.ex,lib/petal_components/file_upload.ex,lib/petal_components/filter.ex,lib/petal_components/slider.ex-> Advanced form inputs and uploadslib/petal_components/modal.ex,lib/petal_components/slide_over.ex,lib/petal_components/popover.ex,lib/petal_components/dropdown.ex,lib/petal_components/menu.ex,lib/petal_components/command_dialog.ex,lib/petal_components/tooltip.ex,lib/petal_components/user_dropdown.ex, assets/…/petal_components.js -> Overlays, menus, and commandslib/petal_components/modal.ex,lib/petal_components/alert_dialog.ex,lib/petal_components/slide_over.ex,lib/petal_components/popover.ex,lib/petal_components/hover_card.ex,lib/petal_components/tooltip.ex,lib/petal_components/dropdown.ex,lib/petal_components/context_menu.ex-> Transient overlayslib/petal_components/menu.ex,lib/petal_components/navigation_menu.ex,lib/petal_components/command_dialog.ex,lib/petal_components/user_dropdown.ex-> Menus and command navigationlib/petal_components/data_table.ex,lib/petal_components/chart.ex,lib/petal_components/pagination.ex,lib/petal_components/sortable.ex,lib/petal_components/tree.ex-> Data presentation and browsinglib/petal_components/data_table.ex,lib/petal_components/table.ex, assets/…/petal_components.js -> Data tableslib/petal_components/chart.ex,lib/petal_components/sparkline.ex,lib/petal_components/pagination.ex,lib/petal_components/progress.ex,lib/petal_components/number_ticker.ex,lib/petal_components/skeleton.ex-> Charts, paging, and progresslib/petal_components/tree.ex,lib/petal_components/table.ex,lib/petal_components/sortable.ex,lib/petal_components/filter.ex-> Hierarchical data and manipulationlib/petal_components/alert.ex,lib/petal_components/toast.ex,lib/petal_components/loading.ex,lib/petal_components/live_region.ex,lib/petal_components/confetti.ex-> Feedback and live updateslib/petal_components/alert.ex,lib/petal_components/toast.ex,lib/petal_components/loading.ex,lib/petal_components/live_region.ex-> Notifications and alertslib/petal_components/confetti.ex,lib/petal_components/border_beam.ex,lib/petal_components/border_plasma.ex,lib/petal_components/shine_border.ex,lib/petal_components/aurora.ex,lib/petal_components/meteors.ex,lib/petal_components/marquee.ex,lib/petal_components/text_animation.ex-> Visual feedback effectslib/petal_components/container.ex,lib/petal_components/card.ex,lib/petal_components/accordion.ex,lib/petal_components/breadcrumbs.ex,lib/petal_components/tabs.ex,lib/petal_components/stepper.ex,lib/petal_components/link.ex,lib/petal_components/typography.ex-> Layout, navigation, and content primitiveslib/petal_components/container.ex,lib/petal_components/card.ex,lib/petal_components/accordion.ex,lib/petal_components/breadcrumbs.ex,lib/petal_components/tabs.ex,lib/petal_components/stepper.ex,lib/petal_components/carousel.ex-> Structural layout and navigationlib/petal_components/button.ex,lib/petal_components/link.ex,lib/petal_components/typography.ex,lib/petal_components/badge.ex,lib/petal_components/avatar.ex,lib/petal_components/icon.ex,lib/petal_components/brand_icon.ex,lib/petal_components/social_button.ex,lib/petal_components/chat.ex,lib/petal_components/local_time.ex-> Content and identity primitiveslib/petal_components/sidebar.ex,lib/petal_components/scroll_area.ex,lib/petal_components/resizable.ex,lib/petal_components/separator.ex,lib/petal_components/collapsible.ex,lib/petal_components/timeline.ex,lib/petal_components/scrollspy.ex-> Application workspace layoutlib/petal_components.ex,lib/petal_components/**/*.ex, assets/…/petal_components.js,assets/css/**-> Component runtime and assets- assets/…/petal_components.js,
assets/js/hooks/**-> Browser hooks assets/css/**,priv/static/**,lib/petal_components/icon.ex,lib/petal_components/brand_icon.ex-> Styling and icon assets.agents/skills/**,skills/**,scripts/**,test/**/snapshot*-> Design skill tooling.agents/skills/petal-design/**,skills/petal-design/**-> Petal design skill