@protonagency/commerce-blocks-widget) provides pre-built Preact components for common commerce use cases. Built on top of the SDK, these widgets handle UI rendering, loading states, and user interactions out of the box.
Installation
Quick Start
Available Widgets
The library provides five main widgets as web components:| Widget | Description | Key Attributes |
|---|---|---|
<browse-widget> | Collection browsing with pagination | data-collection, data-sort, data-limit |
<search-widget> | Semantic search results | data-query, data-limit |
<similar-widget> | Similar products | data-product-id, data-limit |
<predictive-widget> | Autocomplete suggestions | data-query, data-limit |
<image-search-widget> | Image-based product search | data-limit |
Browse Widget
Display products from a merchandised collection with sorting and pagination:Attributes
The collection handle to browse.
The sort order code to apply.
Number of products to display.
Search Widget
Display semantic search results:Attributes
The search query string.
Number of products to display.
Similar Products Widget
Display products similar to a reference product:Attributes
The product ID to find similar products for.
Number of similar products to display.
Predictive Search Widget
Display autocomplete suggestions:Attributes
The partial search query for suggestions.
Number of suggestions to display.
Image Search Widget
Allow users to search by uploading an image:Attributes
Number of products to display in results.
Tree-Shakeable Imports
Import only the widgets you need for smaller bundles:Shared Components
The widget library exports shared components that you can use to build custom UIs:ProductCard
A reusable product card component:Grid
A responsive grid layout for product cards:Styling
Import the default styles or customize with CSS custom properties:CSS Custom Properties
Override the default styles using CSS custom properties:Dependencies
The widget library has the following dependencies:@protonagency/commerce-blocks-sdk- Core SDK (dependency)preact- UI framework (peer dependency)@preact/signals- Reactive state (peer dependency)