SwipeUI

Food card

A food category: a round cutout with a soft plate shadow and a centred label, plain or on an outline, filled or elevated surface.

npx @swipeui/cli add food-card
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • A horizontal row of food categories at the top of a delivery or restaurant screen, such as Burgers, Pizzas and Rolls.
  • A category picker where one dish type is selected at a time, the choice shown in the primary colour.
  • A grid of dishes on a menu, with a price or count as the subtitle.
  • Any small round cutout with a label, such as drinks, desserts or ingredients.

When not to use it

  • A featured product with a large tilted cutout. Product spotlight card is designed for that.
  • Restaurant listings with photos, price and rating. Listing card fits better.
  • Photos with a background; the plate shadow only reads on clear cutouts.
  • Text-only filters. Chip or Segmented control is lighter.

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 food-card
  • Adds components/swipeui/card/food-card.tsx, components/swipeui/card/food-card-palette.ts and 7 shared helpers.
  • Installs class-variance-authority, expo-image, react-native-reanimated, react-native-svg, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/home.tsx
import { useState } from 'react';
import { ScrollView } from 'react-native';
import { FoodCard } from '@/components/swipeui/card/food-card';

const categories = [
  { id: 'burgers', label: 'Burgers', image: require('./assets/burger.webp') },
  { id: 'pizzas', label: 'Pizzas', image: require('./assets/pizza.webp') },
  { id: 'rolls', label: 'Rolls', image: require('./assets/rolls.webp') },
];

const [selected, setSelected] = useState('burgers');

<ScrollView horizontal contentContainerClassName="gap-4 px-4">
  {categories.map((category) => (
    <FoodCard
      key={category.id}
      image={category.image}
      label={category.label}
      selected={selected === category.id}
      onSelectedChange={() => setSelected(category.id)}
    />
  ))}
</ScrollView>;

Examples

app/menu.tsx
import { View } from 'react-native';
import { FoodCard } from '@/components/swipeui/card/food-card';

// Menu tiles on a surface, with a price as the subtitle.
<View className="flex-row gap-3">
  {dishes.map((dish) => (
    <FoodCard
      key={dish.id}
      image={{ uri: dish.cutoutUrl }}
      label={dish.name}
      subtitle={dish.price}
      variant="elevated"
      onPress={() => openDish(dish.id)}
      className="flex-1"
    />
  ))}
</View>;
app/drinks.tsx
import { FoodCard } from '@/components/swipeui/card/food-card';

// A dense row: small size, no plate shadow.
<FoodCard image={latte} label="Latte" size="small" shadow={false} onPress={addLatte} />;

Glass appearance

Select Glass in the Preset picker. Outline, Filled and Elevated use Glass on the card; Plain keeps its bare plate.

API reference

FoodCardProps

PropTypeDefaultDescription
imageunion—

The dish: a bundled image, { uri }, or any node. Cutouts with a clear background (a plate or bowl seen from above) look best.

labelstring—

The category or dish name, centred under the image.

subtitle?string—

A second line, such as "120 places" or a price.

variant?FoodCardVariant'plain'

plain (no surface), outline, filled or elevated.

surfaceBackground?objectundefined

Optional material inside the outline, filled or elevated surface.

size?FoodCardSize'medium'

small for dense rows, medium for the usual category row.

shadow?booleantrue

The soft ellipse under the plate.

palette?Partial<FoodCardPalette>FOOD_CARD_PALETTE

The shadow's colour and depth.

selected?boolean—

Whether the card is selected, as in a category picker. Pair with onSelectedChange.

defaultSelected?booleanfalse

Whether it starts selected when uncontrolled.

onSelectedChange?((selected: boolean) => void)—

Called with the new selected state when the card is pressed.

selectable?booleantrue when any selection prop is set

Pressing toggles the selected state.

selectionRing?booleanfalse

Outline the selected card with a token-tinted ring (around the plate when plain, around the surface otherwise). Without it the selected label turns the primary colour.

onPress?(() => void)—

Runs on press, after any selection change.

disabled?booleanfalse

Prevents pressing and dims the card.

haptics?booleantrue

A light haptic tap when pressed.

motion?MotionOverridethe app's feel

Motion for the press and the selection ring.

accessibilityLabel?stringthe label and subtitle, joined

What a screen reader announces.

accessibilityHint?string—

Says what pressing does, such as "Shows burger places".

className?string—

Classes merged over the card.

style?StyleProp<ViewStyle>—

Native style escape hatch for the card.

testID?string—

Root identifier; parts add -plate, -image, -label, -shadow and -ring.

Composition and behavior

  • The image is a cutout fitted into a plate box that's wider than tall, like a plate seen at an angle, with a soft elliptical shadow just under it. The label and optional subtitle are centred below.
  • variant="plain" (the default) has no surface, as in a row of categories. outline, filled and elevated add a rounded-card surface for menu grids.
  • With selected and onSelectedChange the card is a selectable chip: pressing toggles it and the selected label turns the primary colour. selectionRing adds a token-tinted outline that fades in, around the plate when plain and around the surface otherwise. Control it from one piece of state for a single choice.
  • The card is read as one element ("Burgers, 120 places") and reports its selected state.
  • The shadow's colour lives in food-card-palette.ts; the surface and text use theme tokens, so presets and dark mode apply.

Food card settings

PropDoesDefault
surfaceBackgroundOptional decorative material behind non-plain cardsNone
variantplain, outline, filled or elevatedplain
sizesmall or mediummedium
shadowThe soft plate shadowtrue
paletteThe shadow's colour and depthFOOD_CARD_PALETTE
selected / defaultSelectedWhether it's selecteduncontrolled, false
onSelectedChangeCalled with the new selected statenone
selectablePressing toggles selectiontrue with any selection prop
selectionRingOutlines the selected card with a token-tinted ringfalse
onPressRuns on press, after any selection changenone
hapticsA light tap when pressedtrue

Behavior and gestures

  • With onPress or any selection prop the card is one button that presses in slightly with a light haptic.
  • selected with onSelectedChange (or defaultSelected) makes it a selectable chip: pressing toggles it and the selected label turns the primary colour. selectionRing adds a token-tinted outline that fades in on the select role (around the plate when plain, around the surface otherwise). selectable={false} keeps it a plain button.
  • variant is plain (no surface, as in a category row), outline, filled or elevated; size is small or medium.
  • shadow={false} removes the soft plate shadow; palette changes its colour and depth.
  • Without onPress or selection it's a static element. disabled dims the card and ignores presses; haptics={false} turns off the tap.

Accessibility

  • The card is read as one element: the label and subtitle, such as "Burgers, 120 places".
  • Selectable cards report their selected state, so a row works as a category picker for screen readers.
  • The image and shadow are decorative; pass accessibilityLabel if the label alone isn't enough.
  • Cards are at least 44pt; labels truncate to one line, so keep them short.
  • Under Reduce Motion the selection ring (when on) appears at once and the card doesn't scale.

Motion

  • Uses the press and select motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • Pressing scales the card on the press role.
  • With selectionRing, the ring fades in and out on the select role; under Reduce Motion it changes at once.

Performance

  • One image and one small vector shadow; safe in long horizontal lists. Size cutouts close to 2–3× the image box.

Notes for AI

  • Use cutouts with a clear background (PNG or WebP with alpha); the plate shadow is drawn under the image.
  • For a category picker, control selected from one piece of state so only one card is selected. Leave selectionRing off for the clean look; turn it on when the choice must stand out more.
  • Keep labels to one or two short words such as Burgers or Rolls; put counts or prices in subtitle.
  • Use variant="plain" for a category row and a surface variant for menu grids.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items