The title of a filtered view: each active filter is a word, and replacing one makes it leap in place while the words after it slide along.
Click meTap me
Store / Orders
Orders
2 of 9 orders
Orders matching the filters in the title
Order
Status
Region
Amount
#1048Customer 17
$1,240
#1044Customer 13
$3,020
Click a status or a region to filter by it, a word in the title to remove it.
leapfrog-title · , lively
leapfrog-title-demo.tsx
When to use
Use as the title of any filtered view: replacing a filter makes its word leap and the others slide, and each word removes its filter. Pair it with your own segments or cell buttons.
When not to use
It is the title, not the controls. For a search query pill use Query Wedge; for a bar of filter controls use Filter Bar.
Use Leapfrog Title as the title of any filtered view: orders, tickets, invoices, files. The line "Orders · Paid · Europe · This week" says what the person is looking at in one read, and every change has a visible cause: press a filter option and the word of its facet crouches; release on another value and the word leaps in place, its label turning over at the top of the hop while its width morphs and the words after it slide along. A new facet drops into its place, a removed one sinks away and the gap closes. Each word removes its filter.
It is the view's title, not its filter controls: pair it with your own controls (segments, menus, table cells that filter by their value) through LeapfrogFilterOption or useLeapfrogFilters. For a search query in a pill, use Query Wedge; for a bar of filter controls, use Filter Bar.
The original sort mode stays available as LeapfrogSort: "Sorted by [Date] [Status]", where the pressed column's pill leapfrogs over the others to first place.
LeapfrogFilters holds the filter set (value / defaultValue / onValueChange, filters { facet, value, label }, one per facet) and renders no element; facets sets the order of the words, so a new filter lands at its place. LeapfrogTitle draws the title (prefix, the view's name, and emptyLabel, "All" by default). LeapfrogFilterOption is a button for one value (facet, value, optional label, else its text): a press crouches the facet's word; the release replaces it, adds it or, on the active value, removes it; aria-pressed shows the active value. Style it as a segment, a menu item or a table cell with className. useLeapfrogFilters() returns value, get(facet), toggle(filter), remove(facet) and clear() for your own controls (a change made from them still leaps, without the crouch). The pure applyLeapfrogFilter and describeLeapfrogFilters helpers are exported for the server.
LeapfrogSort, LeapfrogSortHeader, useLeapfrogSort, applyLeapfrogSort and describeLeapfrogSort keep their API. Keys are { key, label, direction } in priority order; a header press sorts by that column first (or flips it), Shift adds it as the next key.
No props were removed or renamed. Visual changes: the pills use the soft dialect (1 px rim, tinted lift, lit top edge) instead of the 2 px outline and hard offset shadow, the header rank badge lost its outline, and LeapfrogTitle outside a provider now names both LeapfrogFilters and LeapfrogSort in its error.
Presets: stack (default, pills), top3 (pills, at most three sort keys; filters are capped by their facets) and tiles (tile chips). chip (any Shape) and, for a sort, max override them.
Set the character for the whole app with MotionKitProvider, or per instance with temperament (calm, lively, playful) on the provider. It changes motion intensity only, never the drawing.
The default demo: Store / Orders, filtered by status, region and period. The status and region cells filter by their value, the period segments replace each other, and the count follows. When the view scrolls into sight, Europe leaps in place and lands as Americas once.
Click meTap me
Store / Orders
Orders
2 of 9 orders
Orders matching the filters in the title
Order
Status
Region
Amount
#1048Customer 17
$1,240
#1044Customer 13
$3,020
Click a status or a region to filter by it, a word in the title to remove it.
The words are a group labelled by the prefix ("Orders"). Each word is a native button named "Paid, remove filter"; Backspace and Delete remove it too, and the arrow keys, Home and End move between the words.
Options are native buttons with aria-pressed; give table-cell options an aria-label such as "Filter by Paid".
A polite live region says what changed, then the whole set: "Refunded replaces Paid. Filtered by Refunded, Europe".
Removing a focused word moves focus to its neighbour without scrolling (to the group when it was the last). Focus rings sit 3 px outside the words.
The dots are decorative (aria-hidden); labels only cross-fade for about 100 ms at the top of the hop; at rest every word is full contrast.
In sort mode, headers are native buttons named "Amount, sort key 1, descending"; give the th its aria-sort with ariaSort(column).
No crouch, hop, arc, squash or nudge: a replaced word cross-fades its label and takes its new width halfway while its neighbours fade to their new places, an added word fades in and a removed one fades out. In sort mode the pills swap places with a fade and the arrow changes without turning.
One requestAnimationFrame loop, only while a word moves or crouches; positions are measured once per change (FLIP) and again only when the row resizes.
The squash and the width morph resize a background layer (real radius, constant 1 px rim); the label only translates and fades, never scales.
Your rows are yours: filter them from useLeapfrogFilters() (or sort them from useLeapfrogSort().value).
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom.
Dependencies
motion
Triggers
click, press, a value change
Reduced motion
No crouch, hop, arc, squash or nudge: a replaced word cross-fades its label and takes its new width halfway while its neighbours fade to their new places; an added word fades in and a removed one fades out.
Keyboard
Enter / Space
On a filter option: sets that value (the facet's word crouches, then leaps in place with the new label); on the active value it removes the filter
Enter / Space / Backspace / Delete
On a word in the title: removes that filter; focus moves to the neighbouring word
Arrow keys / Home / End
On a word in the title: moves focus between the words
Escape
On a held option or header: cancels the crouch, nothing changes
Enter / Space
Sort mode, on a column header: sorts by it first (the pill leapfrogs); Shift adds it as the next key
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)