Cart
Full-featured shopping cart with slide-out panel.Features
- Slide-out cart panel from right side
- Cart line items with quantity adjustment
- Remove items functionality
- Subtotal and total calculation
- Checkout button
- Error handling
- Overlay backdrop
Cart Line Items
Each line item displays:- Product image (links to product page)
- Product title and selected options
- Quantity controls (+/-)
- Remove button
- Line item price
Usage Example
src/components/Cart.client.jsx:20
ProductDetails
Complete product detail page with images, options, and actions.Product object containing:
storefront- Shopify product dataimages- Array of Sanity image objectsbody- Portable text contentsections- Array of collapsible sections
Encoded Shopify variant ID for the initially selected variant
Features
- Selected variant image display
- Image gallery
- Product body content (Portable Text)
- Product title and pricing
- Compare at price
- Product options selector
- Add to cart button
- Buy now button
- Collapsible sections (Details, Shipping, etc.)
- Responsive layout (2-3 columns)
Usage Example
src/components/ProductDetails.client.jsx:11
ProductGallery
Displays a grid of product images.Array of Sanity image objects with:
_key- Unique identifierasset._ref- Sanity image referencealtText- Alt text for accessibilitycrop- Crop datahotspot- Hotspot data
Features
- Responsive grid layout (1-2 columns)
- Sanity image optimization
- 4:3 aspect ratio containers
- Handles missing images gracefully
Usage Example
src/components/ProductGallery.client.jsx:4
ProductOptions
Interactive product variant selector (size, color, etc.).Features
- Displays all product options from Shopify
- Radio button selection
- Visual feedback for selected option
- Updates URL with selected variant
- Auto-hides for single-variant products
- Integrates with Hydrogen’s
useProducthook
Usage Example
src/components/ProductOptions.client.jsx:6
SanityImage
Optimized image component for Sanity CMS images.Alt text for the image
Sanity crop data (top, bottom, left, right)
Sanity dataset name
Original image height
Sanity hotspot data for focal point
Image layout:
"fill" or "responsive"CSS object-fit value (when layout is “fill”)
Sanity project ID
Image quality (1-100)
Responsive sizes for srcset
Sanity image reference ID
Original image width
Features
- Automatic srcset generation for responsive images
- Respects Sanity crop and hotspot
- Automatic format selection
- Lazy loading with async decoding
- Calculates aspect ratio from dimensions
- Supports fill and responsive layouts
Usage Example
src/components/SanityImage.client.jsx:54
Button
Basic button component with consistent styling.Button content
Features
- Full width display
- Black background with white text
- Disabled state styling
- Small text size
Usage Example
src/components/Button.client.jsx:1
CollectionCard
Displays a collection with image and title overlay.Collection object containing:
slug- Collection URL slugtitle- Collection nameimage- Sanity image object
Features
- Image with overlay effect on hover
- Centered title text
- 4:3 aspect ratio
- Links to collection page
- Responsive text sizing
Usage Example
src/components/CollectionCard.client.jsx:7
LinkProduct
Wrapper for product links with variant support.Product handle (slug) in Shopify
Unencoded variant ID to link to specific variant
CSS classes for styling
Click handler function
Link content
Features
- Builds product URLs with optional variant query param
- Updates Hydrogen server state with variant ID
- Graceful fallback if no handle provided
- Integrates with Hydrogen’s client-side navigation
Usage Example
src/components/LinkProduct.client.jsx:9
CartToggleButton
Button to open/close the cart panel.Features
- Uses CartUI context for state management
- Displays CartIcon component
- Cursor pointer on hover
Usage Example
src/components/CartToggleButton.client.jsx:4
Seo
Client component for managing page SEO metadata.Default Sanity image for OpenGraph
Default site title
Page-specific SEO data:
title- Page titledescription- Meta descriptionkeywords- Array of keywordsimage- Sanity image objecttype- OpenGraph typeprice- Product price objectproduct- Full product data for schema.org
Features
- OpenGraph tags
- Twitter card metadata
- Product schema.org JSON-LD
- Dynamic title templates
- Supports both global and page-specific SEO
Usage Example
src/components/Seo.client.jsx:21
ButtonSelectedVariantAddToCart
Wrapper around Hydrogen’s<Product.SelectedVariant.AddToCartButton /> that displays a disabled “Sold out” button when the variant is not available.
Whether to show the button when product is sold out
Use smaller button size (p-3 text-xs instead of p-4 text-sm)
Features
- Automatically checks variant availability
- Shows “Sold out” text when unavailable
- Can hide button completely when sold out (
showSoldOut={false}) - Styled with Tailwind CSS (dark background, white text)
- Disabled state with reduced opacity
Usage Example
src/components/ButtonSelectedVariantAddToCart.client.jsx
src/components/ButtonSelectedVariantAddToCart.client.jsx:7
ButtonSelectedVariantBuyNow
Similar toButtonSelectedVariantAddToCart but opens checkout immediately instead of adding to cart.
Whether to show the button when product is sold out
Use smaller button size
Features
- Opens Shopify checkout in new window
- Uses direct checkout link for selected variant
- Same sold-out handling as AddToCart button
- Styled consistently with other action buttons
Usage Example
src/components/ButtonSelectedVariantBuyNow.client.jsx
src/components/ButtonSelectedVariantBuyNow.client.jsx:7
Context Providers
CartUIProvider
Manages cart UI state (open/closed) and provides methods to control cart visibility.Exports
CartUIProvider- Provider componentuseCartUI()- Hook to access cart UI context
Context Value
Whether the cart panel is currently open
Function to open the cart panel
Function to close the cart panel
Function to toggle cart open/closed state
Usage Example
src/contexts/CartUIProvider.client.jsx
src/contexts/CartUIProvider.client.jsx:11