Skip to content
refs
16 lines · 729 BRaw
1/**
2 * Two icons in one slot that cross-fade when `active` changes, such as copy to check or pending to done. Both stay
3 * mounted, so the leaving icon animates out while the arriving one animates in.
4 */
5export function SwapIcon({ active, on, off, className = "" }: { active: boolean; on: React.ReactNode; off: React.ReactNode; className?: string }) {
6 return (
7 <span aria-hidden="true" className={`inline-grid shrink-0 place-items-center ${className}`}>
8 <span className="swap-icon col-start-1 row-start-1" data-hidden={active ? undefined : ""}>
9 {on}
10 </span>
11 <span className="swap-icon col-start-1 row-start-1" data-hidden={active ? "" : undefined}>
12 {off}
13 </span>
14 </span>
15 );
16}