Motion for your own parts

A list, a fold, chips and a glyph that move as the theme's parts do

5 min readWritten for your agentMarkdown

The theme's parts move with seven helpers, and your own parts take the same ones from @/lib/goop/trail/motion-recipes: the same timings, and the same rule under reduced motion (the fades stay, the movement is cut). Write none of these motions by hand.

A gliding hover wash (useRowGlide): one wash travels from row to row of a list you draw yourself. The list is relative and takes ROW_GLIDE; its rows draw no hover fill of their own. Rows that are the theme's Item glide in ItemGroup already.

Show the code18 lines
TSX
import { ROW_GLIDE, useRowGlide } from '@/lib/goop/trail/motion-recipes';

export function NotebookNav() {
  const glide = useRowGlide({ rows: 'a' });
  return (
    <nav ref={glide} aria-label="Notebook" className={`relative flex flex-col ${ROW_GLIDE}`}>
      <a href="#interviews" className="rounded-lg px-2 py-1 text-sm">
        Interviews
      </a>
      <a href="#themes" className="rounded-lg px-2 py-1 text-sm">
        Themes
      </a>
      <a href="#quotes" className="rounded-lg px-2 py-1 text-sm">
        Quotes
      </a>
    </nav>
  );
}

A sliding chosen fill (usePickGlide): in a column where the chosen row is one fill, the fill slides to the next chosen row. The column takes PICK_GLIDE, and hides the chosen row's own fill while its shape shows.

Show the code27 lines
TSX
import { useState } from 'react';
import { PICK_GLIDE, usePickGlide } from '@/lib/goop/trail/motion-recipes';

const VIEWS = ['All interviews', 'Tagged', 'Not yet tagged'];

export function InterviewViews() {
  const [view, setView] = useState(VIEWS[0]);
  const pick = usePickGlide({ rows: 'button', picked: '[aria-current]' });
  return (
    <div
      ref={pick}
      className={`relative flex flex-col ${PICK_GLIDE} [&[data-pick]:not([data-pick=off])_[aria-current]]:bg-transparent!`}
    >
      {VIEWS.map((name) => (
        <button
          key={name}
          type="button"
          aria-current={name === view ? 'true' : undefined}
          onClick={() => setView(name)}
          className="rounded-lg px-2 py-1 text-start text-sm aria-[current]:bg-accent-strong"
        >
          {name}
        </button>
      ))}
    </div>
  );
}

A fold (useFold): a section of your own opens and shuts its height instead of jumping. The theme's Collapsible and Accordion fold already.

Show the code20 lines
TSX
import { useState } from 'react';
import { Button } from '@/components/ui/goop/button';
import { foldBodyClass, foldClass, useFold } from '@/lib/goop/trail/motion-recipes';

export function InterviewNotes() {
  const [open, setOpen] = useState(false);
  const fold = useFold(open);
  return (
    <section>
      <Button variant="ghost" aria-expanded={open} aria-controls="interview-notes" onClick={() => setOpen(!open)}>
        Notes from the session
      </Button>
      <div id="interview-notes" hidden={!fold.shown} inert={!open} className={foldClass(fold)}>
        <div ref={fold.body} className={foldBodyClass(fold)}>
          <p className="text-sm">Pages two and three of the consent form were missing.</p>
        </div>
      </div>
    </section>
  );
}

A box that folds away when it empties (useContainerFold): a row of your own chips that leaves the page with its last chip folds its height and the gap the layout keeps round it, so the line under it slides up the whole way; its first chip opens it the same way. Draw the box while kept, out of reach while closing; chips that fade themselves (a useFlip row) are named by items, and the fold is called after useFlip.

Show the code43 lines
TSX
import { useRef, useState } from 'react';
import { Badge, BadgeLabel } from '@/components/ui/goop/badge';
import { Button } from '@/components/ui/goop/button';
import { IconButton, IconButtonIcon } from '@/components/ui/goop/icon-button';
import { Presence, useContainerFold, useFlip, useFlipLeave } from '@/lib/goop/trail/motion-recipes';

const FIELD_TEAM = ['Mira Okafor', 'Omar Haddad'];

function Invitee({ name, onRemove }: { name: string; onRemove: () => void }) {
  const { leaving, ref } = useFlipLeave<HTMLSpanElement>();
  return (
    <Badge ref={ref} data-chip="" data-leaving={leaving ? '' : undefined} inert={leaving} variant="outline">
      <BadgeLabel>{name}</BadgeLabel>
      <IconButton variant="ghost" size="sm" aria-label={`Remove ${name}`} onClick={onRemove}>
        <IconButtonIcon icon="x" />
      </IconButton>
    </Badge>
  );
}

export function SessionInvitees() {
  const [people, setPeople] = useState(FIELD_TEAM);
  const row = useRef<HTMLDivElement>(null);
  useFlip(row, '[data-chip]');
  const { kept, closing } = useContainerFold(row, people.length > 0, { items: '[data-chip]' });
  return (
    <div className="flex flex-col gap-3">
      <Button variant="outline" onClick={() => setPeople(FIELD_TEAM)}>
        Invite the field team
      </Button>
      {kept ? (
        <div ref={row} inert={closing} className="relative flex flex-wrap gap-2">
          <Presence>
            {people.map((name) => (
              <Invitee key={name} name={name} onRemove={() => setPeople((all) => all.filter((one) => one !== name))} />
            ))}
          </Presence>
        </div>
      ) : null}
      <p className="text-sm">Sessions run on Tuesday and Thursday.</p>
    </div>
  );
}

A row that leaves where it stood (Presence): a removed row folds shut while its words fade, and the rows below close the gap.

Show the code34 lines
TSX
import { useState } from 'react';
import { Button } from '@/components/ui/goop/button';
import { LEAVE_BODY, LEAVE_FOLD, Presence, useLeave, useLeaving } from '@/lib/goop/trail/motion-recipes';

function Reminder({ text, onDone }: { text: string; onDone: () => void }) {
  const drop = useLeaving();
  const leaving = drop !== null;
  const fold = useLeave<HTMLLIElement>(leaving, () => drop?.());
  return (
    <li ref={fold} data-leaving={leaving ? '' : undefined} inert={leaving} className={LEAVE_FOLD}>
      <div className={LEAVE_BODY}>
        <div className="flex items-center gap-2 py-1">
          <span className="min-w-0 flex-1 text-sm">{text}</span>
          <Button size="sm" variant="ghost" onClick={onDone}>
            Done
          </Button>
        </div>
      </div>
    </li>
  );
}

export function Reminders() {
  const [items, setItems] = useState(['Send the consent form', 'Tag the Tuesday sessions', 'Book the room']);
  return (
    <ul aria-label="Reminders">
      <Presence>
        {items.map((text) => (
          <Reminder key={text} text={text} onDone={() => setItems((all) => all.filter((one) => one !== text))} />
        ))}
      </Presence>
    </ul>
  );
}

Chips that slide into place (useFlip): in a wrapping row of your own chips, a chip added pops in, a chip removed fades where it stood and the chips after it slide to their new places.

Show the code31 lines
TSX
import { useRef, useState } from 'react';
import { Badge, BadgeLabel } from '@/components/ui/goop/badge';
import { IconButton, IconButtonIcon } from '@/components/ui/goop/icon-button';
import { Presence, useFlip, useFlipLeave } from '@/lib/goop/trail/motion-recipes';

function TopicChip({ name, onRemove }: { name: string; onRemove: () => void }) {
  const { leaving, ref } = useFlipLeave<HTMLSpanElement>();
  return (
    <Badge ref={ref} data-chip="" data-leaving={leaving ? '' : undefined} inert={leaving} variant="outline">
      <BadgeLabel>{name}</BadgeLabel>
      <IconButton variant="ghost" size="sm" aria-label={`Remove ${name}`} onClick={onRemove}>
        <IconButtonIcon icon="x" />
      </IconButton>
    </Badge>
  );
}

export function SessionTopics() {
  const [topics, setTopics] = useState(['Onboarding', 'Pricing', 'Exports', 'Search']);
  const row = useRef<HTMLDivElement>(null);
  useFlip(row, '[data-chip]');
  return (
    <div ref={row} className="relative flex flex-wrap gap-2">
      <Presence>
        {topics.map((name) => (
          <TopicChip key={name} name={name} onRemove={() => setTopics((all) => all.filter((one) => one !== name))} />
        ))}
      </Presence>
    </div>
  );
}

A glyph crossfade (useGlyphSwap): an icon of your own control that trades for another crossfades in place. Draw each glyph it gives under its icon name as its key, with its props.

Show the code16 lines
TSX
import { useState } from 'react';
import { Button, ButtonIcon } from '@/components/ui/goop/button';
import { useGlyphSwap } from '@/lib/goop/trail/motion-recipes';

export function FollowButton() {
  const [following, setFollowing] = useState(false);
  const glyphs = useGlyphSwap(following ? 'check' : 'plus');
  return (
    <Button variant="outline" aria-pressed={following} onClick={() => setFollowing(!following)}>
      {glyphs.map(({ icon, props }) => (
        <ButtonIcon key={icon} icon={icon} {...props} />
      ))}
      Follow the study
    </Button>
  );
}

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.