Layout, navigation, and content primitives
Petal Components provides composable building blocks for screens that need a clear frame, a known place in the application, and readable content. Applications combine layout containers with hierarchy, navigation paths, focused content surfaces, and action links so each page can guide a person from context to task.
Page composition
Page composition is the arrangement of a screen into a readable path. A container sets the content boundary, typography sets the heading and body order, cards group related information, and links or buttons move the user to the next action.
The parts are intentionally slot-based. This lets an application keep the same visual and semantic structure while supplying its own page content. The structural layout and navigation page covers the containers and journey controls in more detail. The content and identity primitives page covers the text, action, icon, and identity elements that fill those structures.
When an application assembles a page, the main relationships are:
| Page need | Primitive role |
|---|---|
| Content boundary | Keeps a page centered and limits its readable width. |
| Content hierarchy | Separates page titles, introductions, body text, lists, and supporting text. |
| Grouped information | Gives related content a shared surface with optional media, heading, action, and footer areas. |
| Optional detail | Keeps secondary information closed until a person asks for it. |
| Visual boundary | Separates nearby groups without adding layout spacing or content of its own. |
| Current location | Shows the path from a wider area to the current page. |
| Local choices | Presents views or stages without changing the surrounding page frame. |
| Next action | Uses a link or button according to whether the interaction navigates or acts. |
References: lib/…/container.ex• L4-27 lib/…/card.ex• L6-113 lib/…/accordion.ex• L7-39 lib/…/separator.ex• L47-70 lib/…/link.ex• L4-61
Content hierarchy
Content hierarchy gives each page a stable reading order. Heading levels express nested sections, while lead, muted, large, and small text styles mark the difference between an introduction, supporting detail, emphasis, and compact labels.
The typography primitives also cover prose, ordered and unordered lists, quotations, inline code, and separators. The separator primitive provides a hairline boundary for application chrome, with optional labels and horizontal or vertical orientation; it does not add spacing, so the surrounding layout controls its rhythm. A card can then use a header for its title and description, a content area for the main message, and a footer for related actions without changing the hierarchy.
Expandable sections support the same hierarchy when a page has optional detail. An accordion gives each section a heading and content region, and it can open one section or several sections at the same time. Applications choose this pattern when hiding secondary content improves scanning without removing access to it.
References: lib/…/typography.ex• L4-18 lib/…/typography.ex• L20-131 lib/…/typography.ex• L142-258 lib/…/card.ex• L45-113 lib/…/separator.ex• L72-133 lib/…/accordion.ex• L24-39 lib/…/accordion.ex• L92-169
Navigation journeys
Navigation journeys connect a person’s current context to a destination or a sequence of destinations. Links can represent a normal browser route, a LiveView patch, a LiveView navigation, or a button-like event control; disabled links become inert buttons because links do not support a native disabled state.
Breadcrumbs show a path of linked locations and mark the final item as the current page. Tabs keep related views together and expose the active choice. Steppers show progress through ordered stages and can mark completed and active steps. These patterns share the same navigation link model while serving different journey shapes.
The following diagram shows how a page can move from broad context to local view and then to an ordered task.
flowchart LR
A[Site or area navigation] --> B[Breadcrumb path]
B --> C[Page heading and introduction]
C --> D[Tabs for related views]
D --> E[Card or content group]
E --> F[Stepper for an ordered task]
F --> G[Link or action]
Navigation menus extend this model for larger site areas. They support direct links and flyout panels with plain links, descriptions, icons, and optional calls to action. The menu can open from hover or explicit click, while keyboard focus and Escape support keep the journey usable beyond pointer input.
References: lib/…/breadcrumbs.ex• L6-52 lib/…/tabs.ex• L7-123 lib/…/stepper.ex• L5-128 lib/…/navigation_menu.ex• L1-19 lib/…/navigation_menu.ex• L112-165
Content surfaces
Content surfaces give related material a visible unit without forcing one content shape. A basic card presents a bordered panel, a muted card provides a quieter well, and card media can show an image or a sized placeholder. Review cards add a consistent identity header and quotation body for user feedback.
Cards can also carry branded or interactive content. Spotlight cards provide a feature or pricing surface with a cursor-following glow, while carousels present a set of media-led slides with controls, indicators, optional thumbnails, and links. These surfaces remain composable because their meaningful content stays in slots or in simple slide data.
References: lib/…/card.ex• L18-113 lib/…/card.ex• L116-145 lib/…/spotlight_card.ex• L1-57 lib/…/carousel.ex• L48-139 lib/…/carousel.ex• L141-175
Branded content
Branded content connects product identity to familiar providers and people. Avatars represent a person, team, or workspace through an image, initials, generated color or art, and optional presence state. Icons provide a shared visual vocabulary, while brand icons provide provider marks for sign-in and other identity cues.
Social buttons combine a provider mark with a consistent action surface. They can behave as links for sign-in destinations or as buttons for an in-page event. Chat components extend the same content model to conversations by grouping messages, streamed text, prompt input, tool results, and status markers. Local-time content keeps an absolute time value meaningful while showing it in the reader’s locale.
References: lib/…/avatar.ex• L6-64 lib/…/brand_icon.ex• L46-76 lib/…/social_button.ex• L41-104 lib/…/chat.ex• L52-186 lib/…/local_time.ex• L1-91
Assembly flow
Applications normally assemble these primitives from the outside in. The page frame establishes width first, the page context follows, and content groups then contain the local journey and its actions.
- Place the page inside a bounded container.
- Add the page location with breadcrumbs when the route has a meaningful parent path.
- Establish the title and introduction with heading and text primitives.
- Choose tabs for parallel views or a stepper for ordered progress.
- Group related information in cards or other content surfaces.
- Use an accordion when secondary detail should stay closed until requested.
- Finish each task path with links or buttons that state the next action.
This order keeps structural choices separate from content choices. It also lets an application replace a card body, navigation item, or branded identity element without losing the page’s overall hierarchy. Persistent shells and long-form workspace views use the related application workspace layout primitives when a page must keep navigation or tools visible while content changes.
References: lib/…/container.ex• L15-27 lib/…/breadcrumbs.ex• L24-52 lib/…/tabs.ex• L23-45 lib/…/stepper.ex• L23-45 lib/…/card.ex• L18-113 lib/…/accordion.ex• L41-76 lib/…/link.ex• L16-61
Change checklist
When these files or sections are changed, remember to consider these:
- Keep link behavior aligned across links, breadcrumbs, tabs, navigation menu items, and buttons when route or LiveView navigation contracts change.
- Keep active-state semantics aligned between breadcrumbs, tabs, steppers, and navigation menus so visual state and assistive technology state identify the same current place.
- Preserve the content order and slot boundaries when changing card headers, content areas, footers, media, or review surfaces.
- Keep accordion headings, open-state rules, and content regions aligned when changing expandable page sections.
- Keep separator spacing ownership and decorative or semantic ARIA behavior aligned with the surrounding layout and content meaning.
- Keep provider names and brand icon choices aligned when adding or changing social sign-in options.
- Keep client-side behavior and accessible fallback content aligned for carousels, spotlight cards, chat streams, and local-time displays.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A disabled link is treated as a disabled anchor | The control still looks disabled but can be followed | Use the shared link primitive so the disabled case renders as an inert button. |
| A tab or stepper omits its active state | The user cannot tell the current view or stage, and assistive technology loses the same cue | Set the current tab or step explicitly and keep it in sync with the page state. |
| A breadcrumb path does not mark its last item as current | The page context is unclear in the navigation trail | Render the final breadcrumb as the current page. |
| An accordion heading is supplied in both the item slot and entry data | The component raises an argument error instead of rendering the section | Set the heading in one source only. |
| A semantic separator is used for a purely visual rule, or a decorative rule is used to divide meaningful groups | Assistive technology receives noise or misses a meaningful boundary | Set decorative from the content meaning and keep layout spacing outside the separator. |
| A provider mark is used without an accessible name when it stands alone | A sign-in or identity action has no useful label for assistive technology | Give icon-only branded controls an accessible label. |
| Interactive content is used without its required client behavior | Carousels, cursor effects, streamed chat, or local times lose part of their intended experience | Keep the related browser hook or semantic fallback available when the component is used. |
Key files
| File | Why to read it |
|---|---|
lib/petal_components/container.ex | Defines the page content boundary and width choices. |
lib/petal_components/breadcrumbs.ex | Shows how a route path becomes a current-location trail. |
lib/petal_components/link.ex | Defines the shared navigation and action contract. |
lib/petal_components/typography.ex | Defines the text hierarchy used inside pages and content surfaces. |
lib/petal_components/card.ex | Shows the main composable content surface and its media, header, content, footer, and review forms. |
lib/petal_components/tabs.ex | Defines local view navigation and active-tab semantics. |
lib/petal_components/stepper.ex | Defines ordered progress and completed or active stages. |
lib/petal_components/navigation_menu.ex | Shows larger-area navigation with direct links and flyout content. |
lib/petal_components/accordion.ex | Shows expandable grouped content with heading, open-state, and content-region semantics. |
lib/petal_components/separator.ex | Shows application dividers with label, orientation, spacing, and accessibility choices. |
lib/petal_components/carousel.ex | Shows linked, media-led content with controls and current-slide state. |
lib/petal_components/avatar.ex | Defines person and workspace identity presentation. |
lib/petal_components/brand_icon.ex | Defines provider identity marks and their accessible use. |
lib/petal_components/social_button.ex | Connects provider identity to sign-in actions. |
lib/petal_components/chat.ex | Shows composition of messages, streamed content, actions, and prompt input. |
lib/petal_components/local_time.ex | Defines reader-local time presentation with a semantic time value. |
lib/petal_components/spotlight_card.ex | Shows an enhanced feature-card surface that remains content-composable. |