Minimal listing card
A minimal listing: a rounded photo that pages sideways with dots, a heart to save it, then the title, price line and a star rating.
npx @swipeui/cli add listing-cardWhen to use it
- Stays, homes or rooms people browse and compare by photo, price and rating.
- A two-column grid or a feed of places, each saved with a heart for later.
- Listings with several photos people flick through before opening one.
- Marketplace items where the photo leads and the details are a short line or two.
When not to use it
- A single featured product on a coloured card. Product spotlight card is designed for that.
- Campaign or collection heroes with words on the photo. Cover card puts the details in the photo's empty space.
- Dense lists where each row needs a thumbnail and several actions. Use List row with a leading image.
- Listings that need booking controls on the card; open a detail screen for dates and guests.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add listing-card- Adds
components/swipeui/card/listing-card.tsx,components/swipeui/card/use-listing-card.ts,components/swipeui/card/listing-card-palette.tsand 7 shared helpers. - Installs expo-image, react-native-reanimated, react-native-svg, clsx, tailwind-merge, react-native-worklets, uniwind, expo-haptics, class-variance-authority. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { router } from 'expo-router';
import { ListingCard } from '@/components/swipeui/card/listing-card';
<ListingCard
images={[{ uri: stay.photoUrl }]}
title="Home in Mexico City"
priceLine="£380 for 2 nights"
rating={4.95}
onPress={() => router.push(`/stays/${stay.id}`)}
/>;Examples
import { View } from 'react-native';
import { ListingCard } from '@/components/swipeui/card/listing-card';
// A two-column grid; saved state lives in your data so hearts survive scrolling.
<View className="flex-row gap-3">
{pair.map((stay) => (
<ListingCard
key={stay.id}
images={stay.photos}
title={stay.title}
priceLine={stay.priceLine}
rating={stay.rating}
saved={saved.has(stay.id)}
onSavedChange={(next) => toggleSaved(stay.id, next)}
onPress={() => openStay(stay.id)}
className="flex-1"
/>
))}
</View>;import { ListingCard } from '@/components/swipeui/card/listing-card';
// Several photos page sideways with dots; a badge sits at the top start.
<ListingCard
images={[{ uri: home.photo1 }, { uri: home.photo2 }, { uri: home.photo3 }]}
title="Home in Lisbon"
priceLine="£380 for 2 nights"
rating={4.95}
badge="Guest favourite"
imageAspectRatio={4 / 3}
/>;API reference
ListingCardProps
| Prop | Type | Default | Description |
|---|---|---|---|
images | | — | One photo, or several that page sideways with dots. Each fills the frame. |
title | | — | The listing's name, such as "Home in Mexico City". One line. |
priceLine? | | — | The price and stay, exactly as it should read, such as "£380 for 2 nights". |
rating? | | — | The average rating out of 5, shown as "★ 4.95" after the price line. |
ratingLabel? | | | How the rating is read by screen readers. |
badge? | | — | A badge at the photo's top start: a string makes a soft pill, or pass any node. |
saved? | | — | Whether the listing is saved. Pair with |
defaultSaved? | | | Whether it starts saved when uncontrolled. |
onSavedChange? | | — | Called with the new saved state when the heart is pressed. |
saveable? | | | Shows the heart button at the photo's top end. |
saveLabels? | | | The heart's label when not saved and when saved. |
page? | | — | The photo on show, zero based. Pair with |
defaultPage? | | | The first photo on show when uncontrolled. |
onPageChange? | | — | Called with the photo someone paged to, by swipe or screen-reader action. |
dots? | | | Page dots over the photo's bottom edge. |
photoLabel? | | | How the current photo is read. |
pageActionLabels? | | | Names of the screen-reader paging actions. |
imageAspectRatio? | | | The photo frame's width divided by its height. |
palette? | | | Colours for the heart and the dots, which sit on the photo. |
onPress? | | — | Opens the listing. The heart keeps its own press. |
disabled? | | | Stops the card, the heart and paging, and dims the card. |
haptics? | | | A light haptic tap when the card or the heart is pressed. |
motion? | | | Motion for the press, the heart fill (toggle role) and the dots (select role). |
accessibilityLabel? | | | What a screen reader announces. |
accessibilityHint? | | — | Says what pressing does, such as "Opens the listing". |
className? | | — | Classes merged over the root. |
style? | | — | Native style escape hatch for the root. |
testID? | | — | Root identifier; parts add |
Composition and behavior
- A rounded images frame (square by default) leads; the title (one line), then the priceLine and a rating shown as ★ 4.95 sit under it. The card has no outline.
- With onPress the whole card is one press target. The heart at the photo's top end is its own 44pt button, so saving never opens the card.
- Several images page sideways with snapping and dots. Screen readers hear "Photo 2 of 3" and get Next photo and Previous photo actions.
- saved and page work controlled or uncontrolled; keep saved state in your data so it survives lists and screens.
- badge sits at the photo's top start. The badge and heart row follows the reading direction, so they swap sides in right-to-left layouts.
Save settings
| Prop | Does | Default |
|---|---|---|
| saveable | Shows the heart button | true |
| saved / defaultSaved | Whether the listing is saved | uncontrolled, false |
| onSavedChange | Called with the new saved state | none |
| saveLabels | The heart's label before and after saving | Save, Saved |
| palette | Heart and dot colours on the photo | LISTING_CARD_PALETTE |
Photo settings
| Prop | Does | Default |
|---|---|---|
| images | One photo, or several that page | required |
| page / defaultPage | The photo on show | uncontrolled, 0 |
| onPageChange | Called with the photo someone paged to | none |
| dots | Page dots over the photo | true with several photos |
| photoLabel | How the current photo is read | Photo 1 of 3 |
| pageActionLabels | Names of the screen-reader paging actions | Next photo, Previous photo |
| imageAspectRatio | The photo frame's shape | 1 |
Behavior and gestures
- Tap the card to open the listing: it presses in slightly with a light haptic.
- Tap the heart at the photo's top end to save; it fills on the toggle role and has its own press, so it never opens the card. saved with onSavedChange controls it, defaultSaved sets the start, saveable={false} removes it.
- With several images, swipe the photo sideways to page; the dots follow on the select role. page with onPageChange controls the photo, defaultPage sets the first one, dots={false} hides the dots.
- badge puts a pill (for a string) or any node at the photo's top start.
- disabled dims the card and stops the card, the heart and paging; haptics={false} turns off the taps.
Accessibility
- The card is one element read as the title, price line and rating, such as "Home in Lisbon, £380 for 2 nights, rated 4.95"; ratingLabel changes how the rating is read.
- With several photos it also reads "Photo 2 of 3" and offers Next photo and Previous photo actions; photoLabel and pageActionLabels translate them.
- The heart is a separate 44pt button whose label switches between Save and Saved (saveLabels) and reports its selected state.
- Photos and dots are decorative. Under Reduce Motion the heart fills at once and paging by action jumps without scrolling.
- The badge and the heart sit in a row that follows the reading direction, so they swap sides in right-to-left layouts.
Motion
- Uses the
press,toggleandselectmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - The card and the heart scale on the press role.
- The heart's fill grows in and fades out on the toggle role; the current page dot brightens and grows on the select role.
- Under Reduce Motion the fill and dots change at once and programmatic paging doesn't animate.
Performance
- Photos load through expo-image; with several photos all are mounted in one paging scroll view, so keep the count small (three to five) and size images to the frame.
Notes for AI
- Never name the card after a rental site; it is the Minimal listing card.
- Pass priceLine already formatted, such as "£380 for 2 nights", and rating as a number.
- Store saved state in your own data with saved and onSavedChange so hearts survive scrolling and screens.
- Use badge for one short status such as "Guest favourite"; keep actions other than save off the card.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.