suiss/ui ยท Block
Bag Configure
A product configurator for choosing a model, finish, and storage, with a live price and Add to Bag button.
Bag Configure is an open-source block from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
A buy page where shoppers pick a model, a finish and a storage size while the product photo and price update to match. On desktop the photo sits beside the options; on mobile it shrinks to a panel above them, and a sticky footer keeps the price and Add to Bag button in reach. Good for any configurable product, such as hardware, tiered subscriptions or made-to-order goods.
Edit the models, finishes and storage lists: models carry a base price, finishes a swatch color and photo, and storage options a surcharge. The price is the model price plus the storage surcharge, with a 12-month estimate below it. Replace the Add to Bag handler, which only flips a local flag, with your cart call, and update the heading copy.
Price changes are announced to screen readers, and each swatch is labeled with its finish name. Photos are Unsplash placeholders.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
-
Add the pieces it builds on: Button, Label, Radio Group, Toggle Group.
-
Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Web preview
Composes Screen, ToggleGroup color swatches, Button, Text and BottomBar. Model and storage are radio-style options, the finish swatches cross-fade the product photo, and the bottom bar shows the price and a monthly amount that update as you choose. Add to Bag switches its label to Added to Bag.
Replace MODELS, FINISHES and STORAGE with your catalog data. Pass onAddToBag to receive the selected model, finish, storage and price.
Installation
The CLI also adds what it builds on: Bottom Bar, Button, Screen, Text, Toggle Group. It also adds the animated view components/ui/animated-view.tsx.
- Install the following dependencies:
-
Add the pieces it builds on: Bottom Bar, Button, Screen, Text, Toggle Group.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/bag-configure.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Bottom Bar, Button, Screen, Text, Toggle Group.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/bag-configure.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Bottom Bar, Button, Screen, Text, Toggle Group.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/bag-configure.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.