Skip to content

Terminal UIs (Bubble Tea + harmonica, Textual, tachyonfx) ​

How terminal UI frameworks animate on a grid of character cells: Bubble Tea keeps every animated value in the application's model and advances it with timer messages, harmonica's spring being a pure function the model calls; Textual runs a retained, CSS-styled widget tree with a 60 fps Animator that writes attributes directly; tachyonfx post-processes Ratatui's cell buffer after the widgets have drawn into it.

FieldValue
LanguageGo (Bubble Tea, Bubbles, harmonica) · Python (Textual) · Rust (tachyonfx)
LicenseMIT (all five repositories: harmonica, bubbletea, bubbles, textual, tachyonfx)
Repositorycharmbracelet/harmonica · charmbracelet/bubbletea · charmbracelet/bubbles · Textualize/textual · ratatui/tachyonfx (formerly junkdog/tachyonfx)
Documentationharmonica README.md and doc comments · Bubble Tea commands.go doc comments · Textual Animation guide (docs/guide/animation.md) · tachyonfx README.md
CategoryBubble Tea: Elm-architecture model/update/view, animation by self-rescheduling messages · Textual: retained DOM with CSS, attribute tweening by a central animator · tachyonfx: post-render cell-buffer shaders
Versions surveyedharmonica at 0ff76e4 (2026-08-13; Bubbles pins v0.2.0) · Bubble Tea v2 at bb45cb6 (2026-11-26) · Bubbles v2 at 0c1a491 (2026-11-20) · Textual 8.2.8 at 5e5b7ef (2026-10-09) · tachyonfx 0.25.2 at dac4d28 (2026-10-24)
Animation state lives inBubble Tea: fields of the application's model (progress.Model.percentShown, velocity, tag) · Textual: the animated attribute itself on the widget or Styles, plus Animator._animations keyed by (id(obj), attribute) · tachyonfx: Effect values in an EffectManager, optionally keyed

NOTE

The framework pages already cover the basics this page builds on: Bubble Tea (the Elm loop, tea.Tick, the 60 fps renderer, the Bubbles catalogue) and Textual (the DOM, CSS, the compositor). This page covers only how they animate. The immediate-mode GUI analogues (egui, Dear ImGui, Clay, Gio) are on the sibling page Immediate-mode GUIs; terms such as retarget and stepped integration are defined in Concepts. Ratatui itself has no animation support; tachyonfx is the notable effects crate for it. Every claim was read at the pinned revision.


Overview ​

What it solves ​

A terminal frame is a grid of cells re-emitted as escape sequences, so animation is coarse in space (whole cells) and bounded in time by how fast the terminal accepts output. The three subjects take three positions on where the animation runs:

  • In the model (Bubble Tea). The framework provides only a timer command. An animated widget stores its current value, its velocity and a generation tag in its model, schedules its own next frame, and renders whatever the model says. harmonica supplies the physics as a pure step function.
  • In the framework, on attributes (Textual). Any numeric or blendable attribute of any object, and any animatable CSS property, can be tweened by the app-wide Animator; CSS transition: makes style changes animate implicitly.
  • After rendering, on cells (tachyonfx). Widgets render normally into Ratatui's Buffer; effects then rewrite colours, symbols and positions of the cells in an area, with no knowledge of widgets.

Design philosophy ​

harmonica describes itself as framework-agnostic (README.md):

"Harmonica is framework-agnostic and works well in 2D and 3D contexts. Simply call NewSpring with your settings to initialize and Update on each frame to animate."

Bubble Tea's timer is deliberately a one-shot (commands.go):

"Beginners' note: Tick sends a single message and won't automatically dispatch messages at an interval. To do that, you'll want to return another Tick command after receiving your tick message."

Textual's guide describes its animator as a fixed-increment tweener (docs/guide/animation.md):

"Textual's animator can change an attribute from one value to another in fixed increments over a period of time. You can apply animations to styles such as offset to move widgets around the screen, and opacity to create fading effects."

tachyonfx positions itself as composable post-processing (README.md):

"An effects and animation library for Ratatui applications. Build complex animations by composing and layering simple effects, bringing smooth transitions and visual polish to the terminal."


How it works ​

harmonica: a spring as a pure step function ​

harmonica ports Ryan Juckett's closed-form damped harmonic oscillator (spring.go). NewSpring(deltaTime, angularFrequency, dampingRatio) precomputes four coefficients for one fixed time step, choosing the over-damped, under-damped or critically damped solution from dampingRatio (source); Update applies them (source):

go
// spring.go
func (s Spring) Update(pos, vel float64, equilibriumPos float64) (newPos, newVel float64) {
    oldPos := pos - equilibriumPos // update in equilibrium relative space
    oldVel := vel

    newPos = oldPos*s.posPosCoef + oldVel*s.posVelCoef + equilibriumPos
    newVel = oldPos*s.velPosCoef + oldVel*s.velVelCoef

    return newPos, newVel
}

Spring is a value holding only coefficients; position and velocity belong to the caller, and one Spring can step any number of values ("cache the result, then call Update to update position and velocity values for each spring that needs updating", source). The time step is fixed at construction: FPS(n) returns 1/n seconds, with the advice "game engines often provide the time delta as well, which you should use instead of this function, if possible" (source). The parameters are physical: angular frequency (speed) and damping ratio, with the three regimes documented on NewSpring ("An under-damped spring will reach equilibrium the fastest, but also overshoots it and continues to oscillate as its amplitude decays over time", source).

Projectile is the other primitive: a pointer type holding position, velocity, acceleration and deltaTime, whose Update() performs one explicit Euler step in place and returns the new position (projectile.go, Update). Unlike Spring, it owns its state.

Bubble Tea and Bubbles: self-rescheduling frame messages ​

Bubble Tea gives two timers. Tick(d, fn) fires once, d after the command runs; Every(d, fn) fires once at the next wall-clock multiple of d ("ticks in sync with the system clock", source, source). An animation is a loop the model closes itself: Update handles the frame message, steps the value, and returns the next Tick. Rendering is decoupled: the renderer redraws on its own ticker at WithFPS frames per second (default 60, capped at 120, renderer.go, options.go), and parks the ticker after "about half a second of frames with nothing to draw", resuming on the next change aligned to the old frame grid (tea.go).

The progress bubble is the canonical spring user (progress/progress.go):

go
// progress/progress.go (abridged)
const fps, defaultFrequency, defaultDamping = 60, 18.0, 1.0

type FrameMsg struct{ id, tag int }

func (m *Model) SetPercent(p float64) tea.Cmd {
    m.targetPercent = clampPercent(p)
    m.tag++
    return m.nextFrame()
}

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
    switch msg := msg.(type) {
    case FrameMsg:
        if msg.id != m.id || msg.tag != m.tag {
            return m, nil
        }
        if !m.IsAnimating() {
            return m, nil
        }
        m.percentShown, m.velocity = m.spring.Update(m.percentShown, m.velocity, m.targetPercent)
        return m, m.nextFrame()
    }
    return m, nil
}

func (m *Model) nextFrame() tea.Cmd {
    done := FrameMsg{id: m.id, tag: m.tag}
    return tea.Tick(time.Second/time.Duration(fps), func(time.Time) tea.Msg { return done })
}

The pieces and their sources: the constants (critically damped, ω = 18, source); FrameMsg and the id/tag fields ("An identifier to keep us from receiving frame messages too quickly", source); Update (source); SetPercent bumps tag, which orphans the frame chain already in flight so only one chain runs (source); nextFrame captures the tag by value to avoid a data race (source); IsAnimating stops the chain once |shown − target| < 0.001 and velocity < 0.01 (source). View() renders percentShown; ViewAs(p) renders a given percentage statically and bypasses the spring (source). The spring's dt is fixed at FPS(60) regardless of when the tick actually arrives (source).

The spinner bubble is a frame counter: each Spinner is a list of strings and an FPS duration (Line is 10 frames per second); Update on a matching TickMsg increments frame modulo the list length and schedules the next tick with a new tag ("This prevents the spinner from receiving too many messages and thus spinning too fast") (spinner/spinner.go, update, tick).

Textual: the Animator ​

The app owns one Animator, a Timer at 1 / frames_per_second (60) that starts paused (_animator.py). Widget.animate, App.animate and Styles.animate all bind it to an object and call (widget.py):

python
widget.animate("attribute", value, duration=…, speed=…, delay=0.0,
               easing="in_out_cubic", on_complete=None, level="full")

_animate asserts exactly one of duration and speed (speed divides the distance, default 50 units/s), keys the animation by (id(obj), attribute), reads the current attribute as the start value, and builds either a SimpleAnimation (numbers, or any object with a blend(destination, factor) method — the Animatable protocol that Color satisfies) or, via the object's __textual_animation__ hook, a ScalarAnimation for CSS scalars (source, Animatable). Storing it in _animations replaces any running animation for the same key (whose on_complete is still called) and resumes the timer (source).

Each timer tick evaluates every animation at _get_time() (monotonic wall clock) and the app's animation level, writes the attribute with setattr, and removes finished ones; with nothing left the timer pauses (__call__, _get_time). SimpleAnimation.__call__ is closed form — factor = min(1, (time − start_time) / duration), eased, blended or lerped — and jumps straight to final_value when duration == 0 or the level forbids it (source).

Writing the attribute is the whole mechanism: animating scroll_y sets the reactive scroll offset; animating a style sets a CSS property whose descriptor triggers a refresh. width, height and offset descriptors call refresh(layout=True) (_style_properties.py); ScalarAnimation resolves start and destination against the widget's outer size and the app size once, at creation, then sets the style each tick (scalar_animation.py, step). The animatable style set is fixed: offset, padding, margin, width, height, the min/max sizes, colours, opacity, text_opacity, tint, scrollbar colours, link colours and a few more (styles.py).

Textual: CSS transition: ​

Textual CSS parses transition: <property> <duration> <easing> <delay> (comma-separated groups) into a dict[str, Transition] on the styles (_styles_builder.py, transition.py, test: transition: offset-x 1 in_out_cubic;, test_parse.py). When a class or pseudo-class changes ("For example, when you hover over a button, the :hover pseudo class will be added", app.py), Stylesheet.replace_rules(node, rules, animate=True) diffs old and new render rules; for each animatable key that changed (or is still being animated) and has a transition, it calls animator.animate(base, key, new_value, duration, delay, easing) instead of assigning (stylesheet.py). Focus changes also restyle with animate=True (screen.py).

Textual: animation levels ​

AnimationLevel = Literal["none", "basic", "full"] (_types.py). App.animation_level defaults to constants.TEXTUAL_ANIMATIONS, read from the TEXTUAL_ANIMATIONS environment variable (default "full", invalid values fall back to "full") (app.py, constants.py). Each animation carries a minimum level; at "none" everything jumps to its final value, at "basic" only animations declared level="basic" run. Scrolling defaults to level="basic" (widget.py), as do the Switch slider and the Tabs underline (_switch.py); generic animate calls default to "full". Both arrived in Textual 0.52.0 (2024-02-19, CHANGELOG.md).

tachyonfx: shaders over the cell buffer ​

tachyonfx runs after the widgets have drawn (README.md):

rust
// README.md — quick start (abridged)
let mut effects: EffectManager<()> = EffectManager::default();
effects.add_effect(fx::fade_to(Color::Cyan, Color::Gray, (1_000, Interpolation::SineIn)));
let mut last_frame = Instant::now();
loop {
    let elapsed = last_frame.elapsed();
    last_frame = Instant::now();
    terminal.draw(|frame| {
        frame.render_widget(Paragraph::new("Hello, TachyonFX!"), frame.area());
        effects.process_effects(elapsed.into(), frame.buffer_mut(), frame.area());
    })?;
}

An effect is a Shader: process(duration, buf, area) advances its EffectTimer by the caller's duration and calls execute to rewrite cells, returning overflow time once done (shader.rs). EffectTimer is { remaining, total, interpolation, reverse } (effect_timer.rs); Interpolation is the easing enum (interpolation.rs). EffectManager::process_effects runs every effect and drops finished ones (source). unique(key, fx) / add_unique_effect make an effect cancel any running effect with the same key — "When a new unique effect is created with a key that matches an existing effect, the existing effect will be marked as complete on the next processing cycle" (effect_manager.rs). Effects compose (sequence, parallel, delay, ping_pong, never_complete), and include colour fades, dissolve/coalesce, sweep_in, slide_in, translate and translate_buf, which moves "pre-rendered content without re-rendering it on every frame" from an auxiliary buffer (fx/mod.rs). RefRect is a shared mutable Rect so an effect can follow an area that layout moves ("useful for effects that need to operate on the same dynamically changing area", ref_rect.rs).


Analysis ​

Where animation state lives ​

  • Bubble Tea: in the application's model, as plain fields of the bubble's value type (percentShown, targetPercent, velocity, tag, source). harmonica holds none of it. The model is replaced by Update's return value, so the state is immutable data threaded through the loop.
  • Textual: the animated value is the attribute on the widget or its Styles; the in-flight animation records sit in Animator._animations: dict[(id(obj), attribute), Animation] (source). The key is Python object identity, not a stable application key.
  • tachyonfx: effects are owned values in the caller's EffectManager (optionally keyed by any K: Ord); the animated output exists only in the cell buffer for one frame.

Declaring an animation ​

Bubble Tea is explicit and imperative: the widget changes its target and returns the first frame command (SetPercent returns a tea.Cmd, source); there is no framework notion of "this value animates". Textual offers both: explicit animate(attr, value, …) and implicit CSS transition: on style changes driven by classes and pseudo-classes (source). tachyonfx is explicit: an effect is constructed and added, and runs on whatever the buffer holds.

Time and the clock ​

  • Bubble Tea: the wall clock schedules frames (time.NewTimer inside Tick), but the progress spring integrates a fixed dt = 1/60 per message regardless of the actual interval, so the animation is frame-count-based and slows under load (source, source). Render cadence is a separate ticker (≤ 120 fps) owned by the program.
  • Textual: the animator owns a 60 fps timer and evaluates animations closed-form against the monotonic clock (time.monotonic, perf_counter on Windows, _time.py), so a dropped tick does not slow the animation.
  • tachyonfx: the caller passes elapsed to process_effects every frame; the library never reads a clock.

Interruption and retargeting ​

  • Bubble Tea + harmonica retargets with velocity preserved. SetPercent changes only targetPercent and the tag; the next frame calls spring.Update(percentShown, velocity, targetPercent) with the velocity carried in the model, so the bar bends smoothly towards the new target (source). This follows directly from the pure-function design: the spring has no notion of "an animation", only (pos, vel, target) → (pos, vel). The tag guarantees a single frame chain survives a retarget.
  • Textual restarts from the current value with zero velocity. A new animate for the same (obj, attribute) reads the current (mid-flight) value as start_value, starts a fresh duration and easing, and replaces the old record (source, source). With the default in_out_cubic the motion visibly slows to zero and accelerates again at the interruption point.
  • tachyonfx cancels: a unique effect with the same key marks the old one complete; there is no blending between effects (source).

Curves and springs ​

harmonica is the only spring here: critically/under/over-damped by dampingRatio, speed by angularFrequency, exact for the fixed dt it was built with (source). Its Projectile adds gravity-style ballistic motion with explicit Euler. Textual uses duration (or speed) plus a named easing (DEFAULT_EASING = "in_out_cubic", DEFAULT_SCROLL_EASING = "out_cubic", _easing.py) and CSS-style easing names. tachyonfx uses EffectTimer duration plus an Interpolation curve. Bubbles' spinner has no curve at all: it steps through a list of glyphs at a fixed rate.

Layout animation ​

  • Bubble Tea: not applicable as a framework feature, because Bubble Tea has no layout engine — View returns a string. A bubble that animates its size (the progress bar's filled width) does so in user code, inside View, from the model value.
  • Textual animates in the layout phase, re-run every frame. Animating width, height, margin, padding or offset writes the style on each tick, and the style descriptors request refresh(layout=True), so the compositor re-lays out the screen at the next refresh (source, source). The start and end are resolved once against the widget's size when the animation is created (source); there is no FLIP-style "animate from the previous layout position" — a widget moved by layout (a sibling removed) jumps.
  • tachyonfx animates in the paint phase, after layout. Effects rewrite cells in an area of a buffer that layout and widgets have already filled; translate/slide_in move cell content, translate_buf moves a pre-rendered auxiliary buffer (source). Layout never sees the animated geometry; RefRect lets an effect track the area layout assigned this frame (source). This is the closest terminal analogue to compositor-side animation, and it needs no previous-frame geometry.

Enter and exit ​

None of the three keeps a removed element painting on its own:

  • Bubble Tea: an element exists only while View emits it; an exit animation means keeping it in the model (with a "closing" phase) until the animation ends — the store-driven closing-state pattern, done by hand.
  • Textual: there is no exit hook — Toast, for one, calls remove() the moment its timer expires (_toast.py); an exit is animate("opacity", 0.0, on_complete=…) followed by removal in the callback, i.e. a closing state the application drives (guide § Completion callbacks). Enter is the reverse: mount with a start style, then animate.
  • tachyonfx: effects such as dissolve and fade_to act on whatever is in the buffer, so the widget must still be rendered underneath for the effect to have content to dissolve; translate_buf works from a retained auxiliary buffer, which is a snapshot-based exit if the caller renders the departing content into it (source).

Scheduling, reduced motion and testing ​

Frame requests. Bubble Tea animations schedule exactly as long as they run: IsAnimating() false means no further Tick (source), and the renderer parks after half a second with nothing to draw (source). Textual's animator timer pauses when _animations is empty and resumes on the next animate (source). tachyonfx relies on the caller's loop (the README polls every 16 ms, source).

Reduced motion. Textual is the only one with a policy: TEXTUAL_ANIMATIONS=none|basic|full and App.animation_level, with per-animation minimum levels separating functional motion (scrolling, toggles: "basic") from decorative motion ("full") (source, source). Bubble Tea and tachyonfx have none.

Testing.

  • Bubble Tea: the model is a value and frames are messages, so a test drives the animation by calling Update(FrameMsg{…}) in a loop with no clock at all — TestNaNAnimationRecovery steps up to 600 frames and asserts the chain stops and settles within 0.001 (progress_test.go).
  • Textual: tests freeze time by replacing animator._get_time and call the animator directly to "move to the next frame" (test_disabling_animations.py); Pilot.wait_for_animation() and wait_for_scheduled_animations() await the animator's idle and complete events (pilot.py); snapshot tests set app.animation_level = "none" (test_snapshots.py).
  • tachyonfx: fx::freeze_at(alpha, …) pins an effect at a fixed progress, and with_rng(SimpleRng::new(42)) makes randomised effects reproducible (fx/mod.rs, dissolve); time is the caller's Duration argument.

Lessons for sparkles:ui ​

  • harmonica is the shape a pure nothrow @nogc spring should have. (pos, vel, target, coeffs) → (pos, vel) holds no state, allocates nothing, and retargets with velocity for free. In sparkles the (pos, vel, target) triple would live in the element store keyed by identity, and the host would step it after commit. The cost is that velocity must be stored per animated value.
  • Fix the clock dependency harmonica leaves open. Coefficients are computed for one dt; a frame-paced host with variable frame times either recomputes coefficients per frame (cheap: a few exp/sin/cos) or sub-steps at a fixed rate. Bubbles' fixed FPS(60) dt with wall-clock ticks drifts under load.
  • Bubble Tea's tag is generation-based cancellation — the same problem sparkles' lifecycle-by-set-difference solves: a frame message (or an animation record) carries the generation it was issued for, and stale ones are ignored.
  • Textual's levels are a ready taxonomy for reduced motion: per-animation minimum level, functional (basic) vs decorative (full), one global switch, and "jump to final value" as the reduced behaviour. A test mode is then just level = none.
  • For UI-Q9, Textual and tachyonfx bracket the choice. Textual feeds animated geometry back into layout every frame (siblings reflow, layout re-runs); tachyonfx animates after layout on the painted output (siblings do not move, layout is not re-run). Neither reads previous-frame geometry; a sparkles FLIP-style move would need the store's last committed rect, which neither offers.
  • For UI-Q10, all three leave exit to the application (keep it in the model, animate-then-remove, or render it under the effect). tachyonfx's translate_buf is the only snapshot form, and it is caller-managed.

Strengths ​

  • harmonica's spring is exact, stateless and allocation-free, and gives velocity-preserving retargeting with no extra machinery.
  • Bubble Tea animations are fully deterministic in tests: no clock, just messages.
  • Textual animates any attribute with one call, makes CSS style changes animate implicitly, and has the only reduced-motion policy among terminal frameworks surveyed.
  • tachyonfx adds rich effects to any Ratatui app without touching its widgets, and its time input is entirely the caller's.

Weaknesses ​

  • Bubble Tea has no animation abstraction: each bubble reimplements the frame loop, tag and stop condition; springs integrate a fixed dt against wall-clock ticks.
  • harmonica's Spring is bound to the dt it was built for; variable frame times need new coefficients.
  • Textual restarts interrupted animations from zero velocity; geometry animation re-runs layout every frame; start and end scalars are resolved once and go stale if the container resizes mid-animation.
  • Textual has no exit animation for removed widgets.
  • tachyonfx cannot see widgets or layout: an effect is bound to an area, not to an element, and exit effects need the content still rendered.

Key design decisions and trade-offs ​

DecisionRationaleTrade-off
Spring as a pure (pos, vel, target) → (pos, vel) function (harmonica)framework-agnostic; caller owns state; velocity survives retargetscaller stores velocity; coefficients fixed to one dt
Animation as a self-rescheduling message chain (Bubble Tea)fits the Elm loop with no new concepts; testable by feeding messagesper-widget boilerplate; needs a generation tag to avoid duplicate chains
Separate render ticker that parks when idle (Bubble Tea)coalesces model updates into ≤ 120 fps output; no CPU when nothing changesanimation cadence and render cadence are independent clocks
Central animator tweening attributes by setattr (Textual)any attribute or style animates with one call; one timer for the appkeyed by Python object identity; restart-from-current with zero velocity
CSS transition: on rule diffs (Textual)hover/focus/class changes animate implicitly, as on the webonly properties in the fixed ANIMATABLE set; layout properties re-run layout per frame
Animation levels with per-animation minimums (Textual)one switch for reduced motion and for tests; functional motion can stayauthors must classify each animation
Post-render buffer shaders (tachyonfx)works on any widget; no layout cost; compositor-likeblind to widgets and layout; exit needs the content still drawn or a pre-rendered buffer

Sources ​