Cart Flight
NewInstallation
npx shadcn@latest add https://uibrik.com/r/cart-flight.jsonInstall the packages
npm install @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/cart-flight/cart-flight.tsx"use client"; import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from "react"; import { AnimatePresence, LayoutGroup, MotionConfig, animate, motion, useMotionValue, useReducedMotion, useTransform, useVelocity, type MotionValue, } from "motion/react"; import { IconCheck, IconMinus, IconPlus, IconShoppingBag, IconX } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; // Cart flight. A small shop where adding something sends a copy of its photo // on a curved flight into the cart, and the cart only counts it once it has // landed, so the number changing is the end of the motion rather than a // separate event. The cart opens by growing into a drawer, and taking // something out flies it back to its card. //
Adds the files to
components/uibrik/cart-flight and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/cart-flight.Props
CartFlight- duration
- Type number
- 0.7
- Seconds a photo spends in the air.
- arc
- Type number
- 96
- How far the flight bows upward. It flattens on its own if it would leave the shop.
- tilt
- Type number
- 14
- Most the photo leans into its turn.
- trail
- Type number
- 1
- Fading copies that follow the photo.
- shape
- Type "circle" | "square"
- "circle"
- Shape the photo arrives in.
- anticipation
- Type boolean
- true
- Lift the photo off its card before it flies.
- motionBlur
- Type boolean
- true
- Blur the photo slightly at its fastest.
- flyBack
- Type boolean
- true
- Fly removed items back to their card.
- filters
- Type boolean
- true
- Show filter chips built from the products' tags.
- radius
- Type number
- 14
- Corner radius of the product photos.
- currency
- Type "USD" | "EUR" | "GBP" | "INR" | "JPY"
- "USD"
- ISO 4217 code used to format prices.
- products
- Type { id: string; title: string; price: number; image: string; alt?: string; tag?: string }[]
- SAMPLE_PRODUCTS
- Products in the grid. Tags become the filter chips.
- locale
- Type string
- "en-US"
- Locale used to format prices.
- onCheckout
- Type (lines: { product, quantity }[]) => void
- –
- Called with every line when Checkout is pressed.
- className
- Type string
- –
- Classes for the wrapper. It fills its parent; the drawer opens inside it.