webdevpuneet.com

Scroll Stock Candlestick Crash — Free HTML CSS JS Snippet

Scroll Stock Candlestick Crash · Scroll · Plain HTML, CSS & JS · Live preview

Copy & paste

Source Code

<div class="hint">Scroll ↓ to watch the session play out</div>
<section class="terminal-stage">
  <div class="terminal">
    <div class="ticker">
      <span class="sym">FWD</span>
      <span class="price" id="price">100.00</span>
      <span class="pct" id="pct">+0.00%</span>
    </div>
    <svg viewBox="0 0 480 220" class="chart">
      <g class="gridlines">
        <line x1="0" y1="40" x2="480" y2="40" /><line x1="0" y1="90" x2="480" y2="90" />
        <line x1="0" y1="140" x2="480" y2="140" /><line x1="0" y1="190" x2="480" y2="190" />
      </g>
      <polyline id="trendLine" class="trend" points="" />
      <g id="candles"></g>
    </svg>
  </div>
</section>
<div class="spacer"></div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Real OHLC (open/high/low/close) candlestick rendering — wicks and bodies, not a single-value line chart
Each candle grows into place via a two-phase opacity + height/y scrubbed tween
Trend line extends point-by-point in sync with however many candles have drawn in
Live ticker price and percent-change readout updates at each candle's timeline position
pin: true keeps the trading terminal fixed on screen for the full scrubbed session
Fully reversible — scrolling up shrinks candles and rolls the ticker back down in reverse
Financial-terminal dark palette: near-black background, green up-candles, red down-candles
Candle geometry generated from a plain data array — easy to swap in a different price pattern

About this UI Snippet

Scroll Stock Candlestick Crash — Sequential Candle Growth, Live Ticker & Trend Line Draw

Screenshot of the Scroll Stock Candlestick Crash snippet rendered live

A financial-terminal-style candlestick chart where each candle grows into place as the section scrolls, building a scripted rise-then-crash price pattern while a ticker readout and trend line update live. This is a deliberately different chart type from a typical line-chart draw — candles carry open/high/low/close information, not just a single value per point. Pair with Scroll SVG Path Draw for a pure line-drawing technique, or Scroll Number Odometer for a focused counting-number pattern.

Candles built from real OHLC data

A small data array holds open/high/low/close values per candle. For each entry, a wick <line> spans the high-to-low range and a body <rect> spans the open-to-close range, colored green (.up) or red (.down) depending on whether the close beat the open — standard candlestick chart semantics, just rendered as plain SVG shapes instead of a charting library.

Two-phase reveal per candle

Each candle group starts at opacity: 0 and its body <rect> starts at height: 0 pinned to its close/open midpoint. A shared scrubbed timeline gives candle i a start position of i * 0.08: first a quick opacity fade-in, then a power1.out-eased height/y tween that grows the body to its real dimensions — reading as each candle "printing" onto the chart as the session plays out.

A trend line drawn point by point

Rather than a dash-offset reveal, the trend <polyline>'s points attribute is rebuilt on every scroll tick from a growing slice of the full coordinate array (trendPts.slice(0, count)), driven by the same shared timeline. This produces a line that visibly extends candle by candle, staying synced to however many candles have drawn in so far.

A live ticker synced to timeline position

At each candle's timeline position, a callback updates the price and percent-change readout to that candle's close value, and toggles a .down class for red styling once price falls below the session's opening value — turning the crash into a readable, live-feeling number alongside the visual chart.

Reversibility

Because every candle's opacity/height, the trend line's point count, and the ticker text are all driven by the same scrubbed timeline position, scrolling back up shrinks candles back to zero height in reverse order, retracts the trend line, and rolls the ticker price back down — the "crash" replays as a "recovery" in reverse.

Step by step

How to Use

  1. 1
    Scroll through the sessionScroll down slowly — candles print onto the chart one by one, the trend line extends to follow, and the ticker price/percentage updates live, ending in a sharp crash.
  2. 2
    Scroll back upCandles shrink back down in reverse order, the trend line retracts, and the ticker price rolls back up, confirming full reversibility.
  3. 3
    Change the price dataEdit the open/high/low/close values in the data array in the JS panel to script a different price pattern.
  4. 4
    Add more candlesAdd more { o, c, h, l } objects to the data array — candleW and the timeline stagger automatically adjust to however many entries exist.
  5. 5
    Adjust crash severityChange minP/maxP in the JS panel to rescale the y-axis, making price swings look larger or smaller relative to the chart height.
  6. 6
    Export in your formatClick "HTML" for a standalone file, "JSX" for React, or "Tailwind" for a React + Tailwind version.

Real-world uses

Common Use Cases

Fintech or trading platform landing page
Demonstrate live-feeling market data visualization for a trading app, brokerage, or financial analytics product hero section.
Dramatic "crisis" or volatility storytelling moment
Reuse the rising-then-crashing pattern as a visual metaphor for any narrative about risk, volatility, or a dramatic turning point.
Finance or trading educational content
Teach candlestick chart reading (wicks vs. bodies, up vs. down candles) with a chart that builds itself as students scroll through the explanation.
Learn sequential SVG shape reveal with real data
Study how a plain JS data array drives generated SVG elements and a synchronized, staggered scrubbed-timeline reveal.
Crypto or market-data dashboard demo
Adapt the candle-generation and ticker-sync pattern for a live crypto price chart, portfolio dashboard, or market-summary widget demo.

Got questions?

Frequently Asked Questions

It is hand-generated plain SVG — a JS data array of open/high/low/close values is looped over to create <line> wicks and <rect> bodies at build time, with GSAP tweening their opacity and dimensions during scroll. No charting library is used.

A line chart draws a single continuous value (like a stroke-dashoffset reveal on one path). This snippet renders full OHLC candlesticks — each candle has a wick (high/low range) and a body (open/close range) colored by direction — which is a fundamentally different data shape and visual grammar from a line chart.

Rather than a stroke-dashoffset reveal, the trend line's points attribute is rebuilt on every scroll tick from a growing slice of the full coordinate array, sized to match how many candles have appeared on the same shared timeline — so the line always ends exactly at the most recently drawn candle.

At each candle's timeline position, a callback compares that candle's close price to the very first candle's opening price. If the current price has fallen below the starting price, a .down CSS class is toggled on the percentage readout, switching its color to red.

Yes — the entire chart is generated from the data array of { o, c, h, l } objects. Replace the values with any open/high/low/close sequence you want, and the candle generation, trend line, and ticker will all reflect the new pattern automatically.