Skip to content
animorio
IT
All components

Date range with presets

Calendars, Transitions, HoverGSAP, CSS onlyAdvancedCompressed weight: Demo 14 KBGSAP 28 KBFreeDownload the zip

The date range picker of an analytics dashboard, Halcyon Analytics, on white like a Dribbble shot. The ‘Last 30 days’ button opens on a spring into a panel with the presets on the left (Today, Last 7 days, This quarter…) and two months side by side. Choosing a preset, the band of the period brushes across the days with a brighter wet head, the numbers light up as it passes and the two ends land with a pixel of bounce; the summary rolls letter by letter and below it the sessions and the two comparison bars against the previous period update. Days can also be picked by hand.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Date range with presets" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>The dashboard date range picker with presets and comparison</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage" data-stage>
    <!-- the date range picker of an analytics dashboard (Halcyon Analytics). A button says the period; it opens on a
         spring into a panel with the presets on the left and two months side by side. Picking a preset, the band of the
         range brushes across the days and lights their numbers, the summary rolls and the bars of the comparison with
         the period before grow or shrink -->
    <div class="picker" data-picker>
      <button class="trigger" type="button" data-trigger aria-haspopup="dialog" aria-expanded="false" aria-controls="range-panel">
        <span class="trigger__body" data-trigger-body>
          <svg class="trigger__cal" viewBox="0 0 20 20" aria-hidden="true">
            <rect x="3" y="4.2" width="14" height="12.6" rx="2.6"/>
            <path d="M3 8.2h14M7 2.6v3M13 2.6v3"/>
            <path class="trigger__cal-fill" d="M6.4 11h2.2v2.2H6.4z"/>
          </svg>
          <span class="roll trigger__label" data-trig-label>Last 30 days</span>
          <span class="trigger__sep" aria-hidden="true"></span>
          <span class="roll trigger__range" data-trig-range>Oct 7 &ndash; Nov 5</span>
          <svg class="trigger__chev" data-chev viewBox="0 0 20 20" aria-hidden="true"><path d="M6 8l4 4 4-4"/></svg>
        </span>
      </button>

      <section class="panel" id="range-panel" data-panel role="dialog" aria-label="Choose a date range" aria-hidden="true">
        <div class="panel__grain" aria-hidden="true"></div>
        <ul class="presets" data-presets>
          <li class="presets__item"><button type="button" class="preset" data-preset="today"><span class="preset__long">Today</span><span class="preset__short">Today</span></button></li>
          <li class="presets__item presets__item--wide"><button type="button" class="preset" data-preset="yesterday"><span class="preset__long">Yesterday</span><span class="preset__short">Yesterday</span></button></li>
          <li class="presets__item"><button type="button" class="preset" data-preset="last7"><span class="preset__long">Last 7 days</span><span class="preset__short">7D</span></button></li>
          <li class="presets__item"><button type="button" class="preset" data-preset="last30"><span class="preset__long">Last 30 days</span><span class="preset__short">30D</span></button></li>
          <li class="presets__item presets__item--wide"><button type="button" class="preset" data-preset="month"><span class="preset__long">This month</span><span class="preset__short">Month</span></button></li>
          <li class="presets__item"><button type="button" class="preset" data-preset="quarter"><span class="preset__long">This quarter</span><span class="preset__short">QTD</span></button></li>
          <li class="presets__item"><button type="button" class="preset" data-preset="last90"><span class="preset__long">Last 90 days</span><span class="preset__short">90D</span></button></li>
          <li class="presets__item presets__item--custom"><span class="preset preset--custom" data-custom><span class="preset__long">Custom</span><span class="preset__short">Custom</span></span></li>
          <li class="presets__pill" data-pill aria-hidden="true"></li>
        </ul>

        <div class="months" data-months>
          <div class="month" data-month>
            <div class="month__head">
              <button type="button" class="month__nav" data-nav="-1" aria-label="Previous month"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M12 5.5L7.5 10l4.5 4.5"/></svg></button>
              <span class="month__name" data-month-name></span>
            </div>
            <div class="month__week" aria-hidden="true"><span>Mo</span><span>Tu</span><span>We</span><span>Th</span><span>Fr</span><span>Sa</span><span>Su</span></div>
            <div class="grid" data-grid></div>
          </div>
          <div class="month" data-month>
            <div class="month__head">
              <span class="month__name" data-month-name></span>
              <button type="button" class="month__nav month__nav--next" data-nav="1" aria-label="Next month"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M8 5.5l4.5 4.5L8 14.5"/></svg></button>
            </div>
            <div class="month__week" aria-hidden="true"><span>Mo</span><span>Tu</span><span>We</span><span>Th</span><span>Fr</span><span>Sa</span><span>Su</span></div>
            <div class="grid" data-grid></div>
          </div>
        </div>

        <footer class="foot">
          <div class="sum">
            <p class="sum__main"><span class="roll" data-sum-range>Oct 7 &ndash; Nov 5</span><span class="sum__dot">&middot;</span><span class="roll" data-sum-days>30 days</span></p>
            <p class="sum__vs">vs <span class="roll" data-sum-prev>Sep 7 &ndash; Oct 6</span></p>
          </div>
          <div class="cmp">
            <p class="cmp__top">
              <span class="cmp__label">Sessions</span>
              <span class="roll cmp__value" data-sessions>0</span>
              <span class="delta" data-delta>
                <svg class="delta__arrow" data-delta-arrow viewBox="0 0 12 12" aria-hidden="true"><path d="M6 9.4V2.8M3.2 5.4L6 2.6l2.8 2.8"/></svg>
                <span class="roll" data-delta-text>0%</span>
              </span>
            </p>
            <div class="bars" aria-hidden="true">
              <span class="bars__track"><i class="bars__fill bars__fill--now" data-bar-now></i></span>
              <span class="bars__track"><i class="bars__fill bars__fill--prev" data-bar-prev></i></span>
            </div>
          </div>
          <div class="acts">
            <button type="button" class="btn btn--ghost" data-cancel><span class="btn__face">Cancel</span></button>
            <button type="button" class="btn btn--main" data-apply><span class="btn__face"><span class="btn__shine" aria-hidden="true"></span>Apply</span></button>
          </div>
        </footer>
      </section>
    </div>

    <!-- the drawn pointer of the autopilot -->
    <svg class="hand" data-hand viewBox="0 0 24 24" aria-hidden="true">
      <path d="M5 2.8l13.4 9.6-6.1.9 3.6 7-2.6 1.3-3.6-7-4.7 4.2z"/>
    </svg>
    <p class="sr" aria-live="polite" data-live></p>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

60 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Date range with presets” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On a white page sits the period button of an analytics dashboard: the calendar icon, ‘Last 30 days’ and next to it, lighter, ‘Oct 7 – Nov 5’ with a small chevron. Pressed, it gives a little and a white panel opens below it on a spring, with a one pixel edge, soft layered shadows and a very fine grain. On the left, on a very light grey column, the presets: Today, Yesterday, Last 7 days, Last 30 days, This month, This quarter, Last 90 days and at the bottom Custom; under the chosen one a raised white pill with an iris thread. On the right October and November side by side, the days arriving in a light wave, today marked by a thin ring and the days still to come dimmed. As soon as it opens, the band of the period spreads across the days like a brushstroke: it starts on the first day, runs from week to week with a brighter head, and every number turns iris and a little wider as it covers it; the first and last days land as two solid tiles with a small bounce. At the bottom the summary ‘Oct 7 – Nov 5 · 30 days’ and ‘vs Sep 7 – Oct 6’, the sessions of the period, the change in green (or coral if they drop, with the arrow turning) and two thin bars, this period and the one before. Choosing another preset the pill slides on a spring, the old band lifts and the new one is painted, the letters of the summary and the digits roll only where they change, the bars grow or shrink and a light crosses Apply. A day can be tapped and then another: the band follows the pointer from the first day and Custom lights up. Apply folds the panel back into the button, whose label rolls to the new period. Until someone touches it, a drawn pointer opens the panel, picks This quarter, paints 12 to 24 October by hand, presses Apply, opens again and goes back to Last 30 days.

How it works

Days as numbers

Every date is a number of days since 1970 (Date.UTC divided by 86400000): the presets are pairs of numbers worked out from today (the last 30 days end yesterday, the quarter starts on the first of its first month) and the previous period is the same number of days right before. The sessions of each day come from a fixed rule (busier weekdays, a slow growth, a seeded wobble), so the comparison is the same on every loop.

The band in six strips

Under the numbers of each month there is a layer with six strips, one per week. The band is an interval [start, end) in fractional days: on every frame each strip takes its part and rounds only the real ends, not those cut by the end of the week. GSAP moves the end from the start to the last day with power3.inOut, takes it a tenth of a day past and settles it back: that is the brushstroke, with the bright head (a gradient) following the growing edge.

Numbers that light up

A number turns iris, bolder and a little wider (Mona Sans wdth axis) as soon as the band covers its middle: the classes change every frame and CSS transitions do the rest, so they light up one after another as it passes. The two ends are separate tiles born with a back.out when the stroke reaches them.

Words that roll only where they change

Every label that changes (the summary, the previous period, the sessions, the percentage, the button's label) is split into letters: the old ones rise away, the new ones come in from below with a stagger and a back.out, and the width grows or shrinks on a spring. Letters that are equal at the same place, counted from the right, stay still.

The pill and the panel

The presets pill measures the chosen button and slides onto it with a back.out (vertically on desktop, horizontally among the five short labels on the phone). The panel opens with scale, drop and fade on a spring from the button's corner; the layout changes with a container query on the picker's width.

Values to change

NameFileDefaultWhat it changes
SWEEPscript.js0.8How many seconds the band takes to brush across the days of a new period.
SPRINGscript.js1How springy the panel, the pill and the ends are: 0.5 calm, 2 very bouncy.
SESSIONSscript.js1640The dashboard's average sessions per day, behind the comparison.
SPEEDscript.js12 = the drawn pointer twice as fast, 0.5 = half.
AUTOscript.jstrueThe drawn pointer uses the picker by itself until someone touches it.

Try them in the Playground

When to use it

For the top bar of an analytics, sales or marketing dashboard, the admin panel of a SaaS app, the reports of an online shop or a booking service: wherever people pick the period of the data and need to see straight away how it compares with before.

On phones

On the phone the presets become a row of five short labels (Today, 7D, 30D, QTD, 90D) with the pill sliding sideways, the two months stay side by side with smaller cells, the summary sits next to the buttons and the bars below. Tap the first day and then the last. The rest is the same.

With reduced motion

Nothing moves: the panel fades in, the band appears whole with a fade instead of brushing across, the labels change with a fade and the bars are already at their size; the drawn pointer is not shown.

Pitfalls

  • With real dates the time zone shifts days by one at midnight: everything is done in whole UTC days, never with a local new Date.
  • Rounding every strip made the band look like a row of separate pills: only the real ends of the period are rounded, those cut by the end of the week stay almost square.
  • Hidden with display: none the panel does not let the cells and the pill be measured: it stays in place with visibility: hidden, so the picker keeps its height and the sizes are always there.
  • Mona Sans tabular-nums gives a slashed zero: the rolling digits are separate letters, without tabular-nums.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 14 KB; the libraries: GSAP 28 KB.

Testing

Tested on 6 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All components