suiss/ui ยท Block
Price Care
A device protection plan picker with device chips, payment options, an optional theft add-on, and a live total.
Price Care 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 protection plan picker: choose a device, pick a payment option for it and, for some devices, add theft and loss cover, with a live total and an Add to Bag button. A photo of the selected device sits beside the options on desktop and above them on mobile. Use it for warranties, insurance add-ons or any per-product plan.
Edit devices; each has a name, photo, alt text and payment options with a label, price and optional theft surcharge. The theft switch only appears for Phone Pro, so change that check if other devices offer it. Give Add to Bag a handler.
The total is announced when it changes. 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, Switch, Toggle Group.
-
Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Web preview
A product screen with a hero photo per device, a ToggleGroup to pick the device, and a RadioGroup of payment options. For the phone, a Switch adds theft and loss protection. A BottomBar shows the total, which updates with each choice, and an Add to Bag Button.
Replace DEVICES with your products, options and prices. Wire onAddToBag, which receives the device, option, theft add-on and total. The photos are Unsplash placeholders.
Installation
The CLI also adds what it builds on: Bottom Bar, Button, Radio Group, Screen, Switch, 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, Radio Group, Screen, Switch, Text, Toggle Group.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/price-care.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Bottom Bar, Button, Radio Group, Screen, Switch, Text, Toggle Group.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/price-care.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Bottom Bar, Button, Radio Group, Screen, Switch, Text, Toggle Group.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/price-care.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- 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.