Introducing a new way to review your PRs.

Read the announcement

petalframework / petal_components

Phoenix + Live View HEEX Components

View on GitHub

24 documents · Updated Sep 2, 2026

docs / visual-feedback-effects

Visual feedback effects

Visual feedback effects add motion, light, or celebration to a Phoenix component without carrying the meaning of status on their own. They help a user notice an important moment, focus on a key surface, or read changing promotional text while keeping the main content available in the rendered page. For status messages and live announcements, see Notifications and alerts; this page is about decorative and attention-guiding effects.

Effect families

The effect set covers short event feedback, animated surfaces, background decoration, moving content, and animated text. Each component wraps content or mounts at a target location, so an application can add visual interest without changing the surrounding page structure.

EffectPrimary roleMotion modelBest fit
ConfettiCelebrate a completed actionTemporary full-screen burstSuccess moments such as onboarding or payment completion
Border beamDraw attention to a surfaceLight travels around the borderA key card, call to action, or sign-in panel
Border plasmaKeep a surface active and vividGlowing border field pulses or rotatesA hero panel or one high-value call to action
Shine borderAdd quiet activity to an edgeSlow shimmer around the borderCards, inputs, or low-priority calls to action
AuroraSet a soft backdrop behind contentBlurred light drifts across a sectionHero sections and landing-page content
MeteorsAdd depth to a dark surfaceStreaks cross the containing panelA hero or card background
MarqueeShow a repeated stream of contentContent loops in one directionLogos, reviews, or other repeated items
Text animationEmphasize or reveal wordsGradient, shimmer, word change, or typingHeadings and short promotional text

References: lib/…/confetti.ex• L1-28 lib/…/border_beam.ex• L1-7 lib/…/border_plasma.ex• L1-30 lib/…/shine_border.ex• L1-10 lib/…/aurora.ex• L8-30 lib/…/meteors.ex• L1-9 lib/…/marquee.ex• L1-30 lib/…/text_animation.ex• L1-14

Surface effects

Border beam, border plasma, and shine border all decorate a panel edge, but they signal different levels of attention. Border beam presents a distinct moving light. Border plasma presents a wider field of changing light. Shine border stays slow and quiet so the content remains the focus.

Border beam

PetalComponents.BorderBeam wraps a content panel and moves one or more colored beams around its border. It is a CSS-only effect, so it does not need a browser hook. The panel owns its background, border, and radius, while the beam remains a visual layer around the content.

The component supports linear motion, eased motion, and a spring-like lap. It can reverse direction or use a soft glow. Multiple beams are phased around the same path to create a chase rather than several beams starting together.

References: lib/…/border_beam.ex• L1-7 lib/…/border_beam.ex• L17-62 lib/…/border_beam.ex• L64-87

Border plasma

PetalComponents.BorderPlasma wraps content in a glowing border field. Its pulse mode makes the light breathe in place. Its rotate mode moves a light arc around the rim. Palettes and intensity levels let the effect fit a brand or remain neutral.

The glow can sit outside the panel, inside its edge, or in both places. Because this effect paints several blurred layers, it is intended for a small number of important surfaces rather than every card in a view.

References: lib/…/border_plasma.ex• L1-30 lib/…/border_plasma.ex• L38-87 lib/…/border_plasma.ex• L89-114

Shine border

PetalComponents.ShineBorder adds a slow ambient shimmer to a bordered panel. It is the quietest of the three border effects and works when a surface needs a hint of motion without competing with its content.

The shimmer accepts one color or a list of colors. It can wrap form controls while preserving a visible keyboard focus outline, so the decorative edge does not replace an interaction signal.

References: lib/…/shine_border.ex• L1-10 lib/…/shine_border.ex• L13-28 assets/default.css• L5981-6032

Background effects

Aurora and meteors provide motion behind content instead of on the content boundary. Both are non-interactive visual layers. The containing layout must leave the foreground content readable and must define the space in which the effect can render.

Aurora

PetalComponents.Aurora creates a soft color glow behind a section. It builds the glow from a supplied palette and can adapt its light or dark treatment to the page. The content stays above the backdrop, so the effect enriches a hero without replacing its text or controls.

The optional PetalAurora hook pauses the drift when the section is outside the viewport. Reduced-motion users see a still glow instead of the drift.

References: lib/…/aurora.ex• L8-30 lib/…/aurora.ex• L31-56 assets/…/petal_components.js• L2007-2020 assets/default.css• L6034-6123

Meteors

PetalComponents.Meteors fills the nearest relative container with colored streaks. It is suited to a dark hero or card background and does not receive pointer input. The parent container must provide the positioning context and clip the shower when needed.

The component derives a stable scatter pattern from its seed. LiveView re-renders therefore keep each meteor in the same place instead of making the background jump. The count, direction, color, and horizontal direction control the visual density and flow.

References: lib/…/meteors.ex• L1-9 lib/…/meteors.ex• L12-32 lib/…/meteors.ex• L34-44 assets/default.css• L6744-6764

Repeating content effects

PetalComponents.Marquee turns repeated content into a continuous horizontal or vertical stream. It repeats the supplied slot so the moving track can cycle without an empty gap, and it can fade the track at its edges to soften the loop.

The marquee can reverse direction, pause while the user hovers, and limit its width or height. These options control how the stream fits the page; they do not change the meaning of the repeated content.

References: lib/…/marquee.ex• L1-30 lib/…/marquee.ex• L32-63 assets/default.css• L3866-3985

Text effects

PetalComponents.TextAnimation provides four ways to add motion to short text. Gradient text and shimmer text use CSS only. Word rotation and the typing effect use browser hooks, but both render useful text on the server first so the message remains present without JavaScript.

Text effectUser-visible behaviorRuntime requirement
Gradient textA color gradient sweeps through the textCSS
Shimmer textA bright band passes over muted textCSS
Word rotateA list of words changes with a roll-up transitionPetalWordRotate hook
Typing effectText appears one character at a time with an optional caret and loopPetalTypingEffect hook

These effects suit headings and short labels. The server-rendered first word and full typing text provide a readable fallback, while reduced-motion users keep static text and do not receive the timed animation.

References: lib/…/text_animation.ex• L1-14 lib/…/text_animation.ex• L17-73 lib/…/text_animation.ex• L75-151 assets/…/petal_components.js• L1176-1244 assets/default.css• L6766-6814 assets/default.css• L7661-7676

Motion and accessibility

The effects treat motion as optional decoration, not as the only way to convey information. CSS animation stops or becomes static under prefers-reduced-motion, and the browser-driven effects check the same preference before starting. Confetti skips the burst, while the text and background content remain available.

Decorative layers are marked as hidden from assistive technology where they do not carry content. Confetti also uses a pointer-free full-screen canvas for its temporary burst. Use an alert, toast, or live region when a user must receive a status message rather than only see a visual change.

The main behavior is:

flowchart TD
    A[Component renders content] --> B{Effect needs browser timing or events?}
    B -->|No| C[CSS animation decorates the content]
    B -->|Yes| D[Server-rendered fallback remains visible]
    D --> E[Browser hook adds motion or event response]
    C --> F{Reduced motion requested?}
    E --> F
    F -->|Yes| G[Keep content and remove or stop motion]
    F -->|No| H[Run the visual effect]

References: lib/…/confetti.ex• L7-28 lib/…/text_animation.ex• L12-14 assets/…/petal_components.js• L1047-1089 assets/…/petal_components.js• L1180-1192 assets/…/petal_components.js• L1217-1231 assets/default.css• L6114-6117 assets/default.css• L7661-7676

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the server event name and client event listener aligned for confetti. A mismatch makes a successful event produce no burst.
  • Keep hook names and rendered mount attributes aligned for confetti, aurora, word rotation, and typing. A renamed hook or missing data value can remove only the enhanced behavior while leaving the fallback visible.
  • Keep reduced-motion behavior aligned between CSS animation rules and hook start logic. Otherwise one part of an effect can continue after the rest becomes static.
  • Keep the parent positioning and clipping contract for meteors. Changing the container structure can move the shower over content or let it escape its intended area.
  • Treat border plasma paint cost and glow clearance as part of its layout contract. More instances or less room in a scrolling container can affect page performance or scroll range.

Important failure modes

TriggerConsequenceGuard
Confetti is fired without the matching mounted target or with a different target IDNo burst appears at the intended mountMount the required confetti component and use its ID when several mounts exist
A hook-based text effect receives no usable text or fewer than two wordsThe effect cannot animate, while its server-rendered fallback remainsSupply the required text or a list with at least two words
Meteors render outside a relative, clipped parentStreaks can cover unrelated content or escape the visual regionPlace the effect in the nearest relative container and clip that region when needed
Many border plasma instances run on one viewSeveral blurred animated layers can raise paint cost and reduce smoothnessReserve plasma for a hero panel or a small number of key calls to action
A user has reduced motion enabledConfetti and meteor motion are skipped, and other effects stay stillKeep the meaning in text or standard status components rather than in animation

Key files

FileWhy to read it
lib/petal_components/confetti.exDefines the celebration mount and the server and client ways to trigger a burst.
lib/petal_components/border_beam.exDefines the moving border treatment and its attention levels.
lib/petal_components/border_plasma.exDefines the richer pulsing or rotating border field and its usage limits.
lib/petal_components/shine_border.exDefines the low-attention border shimmer and its form-control focus behavior.
lib/petal_components/aurora.exDefines the hero backdrop and its palette and motion choices.
lib/petal_components/meteors.exDefines the container-bound streak field and stable scatter behavior.
lib/petal_components/marquee.exDefines the repeated horizontal or vertical content stream.
lib/petal_components/text_animation.exDefines the four text treatments and their fallback model.
assets/…/petal_components.jsShows the browser event, timing, viewport, and reduced-motion behavior for hook-backed effects.
assets/default.cssShows the shared visual rules, animation states, edge placement, and reduced-motion rules.