PineUiPhoenix.Components.Text (Pine UI v0.2.1)

Copy Markdown View Source

Animated text.

Ports the Pines typing effect and text animation.

<.typing_effect texts={["Fast", "Accessible", "Yours"]} />
<.text_animation text="Welcome to Pine UI" />

Summary

Animation

Renders text that animates in one character at a time.

Renders text that types itself out, character by character.

Animation

text_animation(assigns)

Renders text that animates in one character at a time.

No GSAP required

Pines drives this with GSAP loaded from a CDN. This port splits the text into spans on the server and animates them with CSS transitions and a per-character transition-delay, so there is no third-party JavaScript, nothing to load, and no flash of unstyled text.

The characters are aria-hidden and the whole string is exposed once to assistive technology — splitting a word into per-character spans otherwise makes screen readers spell it out.

Attributes

  • id (:string) - Defaults to nil.
  • text (:string) (required)
  • effect (:string) - Per-character entrance. Defaults to "fade". Must be one of "fade", "blow", or "slide".
  • stagger (:integer) - Milliseconds between characters. Defaults to 40.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

typing_effect(assigns)

Renders text that types itself out, character by character.

Accessibility

The animated text is aria-hidden and the full phrase list is rendered in a visually hidden element. A screen reader therefore reads the content once, calmly, instead of announcing every intermediate keystroke — which is what an aria-live region on the animated node would do.

The animation also honours prefers-reduced-motion: when the user has asked for less motion, the first phrase is shown statically and no timers run.

Attributes

  • id (:string) - Defaults to nil.
  • texts (:list) (required) - Phrases to cycle through.
  • type_speed (:integer) - Milliseconds per character while typing. Defaults to 110.
  • erase_speed (:integer) - Defaults to 50.
  • pause_end (:integer) - Pause once a phrase is complete. Defaults to 1500.
  • cursor (:boolean) - Defaults to true.
  • loop (:boolean) - Defaults to true.
  • class (:string) - Defaults to nil.
  • text_class (:string) - Defaults to nil.
  • Global attributes are accepted.