SwipeUI

Expandable card

A square tile that opens into a full-width card, in a grid whose other tiles reflow around it and return when it closes.

npx @swipeui/cli add expandable-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 dashboard of short summaries, such as health, budget or device stats, where each tile opens into its breakdown in place.
  • A grid of topics or settings groups where people peek at the details without leaving the screen.
  • One summary tile next to other content that can grow into a full-width panel (standalone).

When not to use it

  • Stacked text sections where only one is open at a time. Accordion is lighter and reads as a list.
  • Truncating a single paragraph. Expandable text adds a Read more to the text itself.
  • A tile that goes to another screen. Info card is one button with a chevron and keeps its size.
  • Details that need a whole screen or a form. Open a sheet or a new screen instead.
  • Content people must always see, such as prices or warnings. Don't hide it behind a tile.

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 expandable-card
  • Adds components/swipeui/card/expandable-card.tsx, components/swipeui/card/use-expandable-grid.ts and 6 shared helpers.
  • Installs class-variance-authority, 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/health.tsx
import { ExpandableCard, ExpandableCardGroup } from '@/components/swipeui/card/expandable-card';

<ExpandableCardGroup>
  <ExpandableCard id="sleep" title="Sleep" description="7 h 40 min" leading={<MoonIcon />}>
    <SleepStages />
  </ExpandableCard>
  <ExpandableCard id="heart" title="Heart rate" description="62 bpm resting" leading={<HeartIcon />}>
    <HeartRateRows />
  </ExpandableCard>
  <ExpandableCard id="energy" title="Active energy" description="420 of 600 kcal">
    <EnergyRows />
  </ExpandableCard>
  <ExpandableCard id="water" title="Water" description="1.6 of 2 L">
    <WaterRows />
  </ExpandableCard>
</ExpandableCardGroup>;

Examples

app/settings.tsx
import { ExpandableCard, ExpandableCardGroup } from '@/components/swipeui/card/expandable-card';

const [open, setOpen] = useState<readonly string[]>([]);

<ExpandableCardGroup columns={3} single={false} value={open} onValueChange={setOpen}>
  <ExpandableCard id="focus" title="Focus" description="Work">
    <Text>Silences everyone except your team until 18:00.</Text>
  </ExpandableCard>
  <ExpandableCard id="battery" title="Battery" description="82%">
    <Text>About 9 hours left at your usual use.</Text>
  </ExpandableCard>
  <ExpandableCard id="storage" title="Storage" description="41 GB free">
    <Text>Offload old videos to free space.</Text>
  </ExpandableCard>
</ExpandableCardGroup>;
app/route.tsx
import { ExpandableCard } from '@/components/swipeui/card/expandable-card';

// On its own, the card is a half-width tile that grows to the full width.
<ExpandableCard title="Route details" description="A gentle trail beside the river.">
  <Text>Carry water for the final climb.</Text>
</ExpandableCard>;

Glass appearance

In the preview, choose Glass in the Preset picker. Pass the Pro Glass material into surfaceBackground to style the card fill.

API reference

ExpandableCardProps

PropTypeDefaultDescription
id?stringthe key or index

Identity inside a group, reported by onValueChange. Falls back to the element's key, then its position.

titlestring—

The topic. Shown on the tile and at the top of the open card, and read first.

description?string—

Supporting text under the title: two lines on the tile, three when open.

leading?ReactNodeundefined

Icon or artwork at the top start, on the tile and on the open card.

tile?ReactNodeundefined

Replaces the tile's built-in leading, title and description layout. The title still labels the card for screen readers.

children?ReactNode—

The details, shown under the title once the card is open. Unmounted while closed.

expanded?boolean—

Controlled open state.

defaultExpanded?booleanfalse

Initial open state when uncontrolled. In a single-mode group only the first one opens.

onExpandedChange?((expanded: boolean) => void)—

Called with the new open state, also when a single-mode group closes this card.

chevron?booleantrue

Show the chevron at the top end, which turns over as the card opens.

surface?ExpandableCardSurface'raised'

Surface treatment. raised adds the deep layered shadow and a hairline.

surfaceBackground?objectundefined

Decorative replacement for the card fill. It receives the card’s bounds.

disabled?booleanfalse

Prevent opening and closing, and dim the card.

haptics?booleanthe group's setting, then true

Impact feedback on toggle.

motion?MotionOverridethe group's, then the app's feel

Layout, chevron and press character.

accessibilityLabel?stringthe title and description, joined

What a screen reader announces for the toggle.

accessibilityHint?string—

Describes the result of toggling, such as "Shows the sleep breakdown".

className?string—

Classes merged over the card surface.

style?StyleProp<ViewStyle>—

Native style escape hatch for the card surface.

testID?string—

Surface identifier; the tile, header and details get -tile, -header and -details.

ExpandableCardGroupProps

PropTypeDefaultDescription
childrenReactNode—

ExpandableCard elements, in reading order.

columns?number2

Tiles per row.

gap?number12

Space between tiles and rows, in points.

single?booleantrue

One card open at a time: opening a card closes the others.

value?readonly string[]—

Controlled ids of the open cards. A card's own expanded prop wins over this.

defaultValue?readonly string[]the cards with `defaultExpanded`

Initial open ids when uncontrolled.

onValueChange?((value: readonly string[]) => void)—

Called with the open ids, in reading order, after each toggle.

haptics?booleantrue

Impact feedback on toggle, for every card that doesn't set its own.

motion?MotionOverridethe app's feel

Layout character for every card that doesn't set its own.

className?string—

Classes merged over the grid container.

style?StyleProp<ViewStyle>—

Native style escape hatch for the grid container.

testID?string—

Container identifier.

Composition and behavior

  • ExpandableCardGroup lays cards out as square tiles, columns per row with gap points between them. An open card moves to the start of its row and spans the full width; its row-mates reflow under it, in order, and the rows below slide down. Closing puts every tile back in its slot.
  • single (the default) keeps one card open: opening a tile closes the other. Set it to false to let several stay open; they stack in reading order.
  • title and description sit at the bottom of the tile and at the top of the open card, with leading at the top start of both. children are the details, mounted only while the card is open or closing. Pass tile to replace the tile's layout.
  • The open card's height is measured from its details, so it fits any content. Tiles size themselves from the group's width.
  • Control one card with expanded and onExpandedChange, or the whole group with value, defaultValue and onValueChange (open ids, in reading order).
  • Upgrading from 1.x: the Read more button and summary are gone. For a paragraph with Read more, use Expandable text; for stacked sections, use Accordion.

Behavior and gestures

  • Use surfaceBackground for one material that follows the tile as it expands.
  • Tap a tile to open it. It moves to the start of its row and grows to the full width while its row-mates slide under it and the rows below glide down.
  • Tap the open card's title row to close it. Every tile springs back to its slot.
  • In single mode, the default, opening a tile closes the one that was open; set single to false to keep several open.
  • The chevron at the top end turns over as the card opens and back as it closes.
  • A closed tile presses in slightly and gives a light haptic; a disabled card dims and ignores touches.

Accessibility

  • The tile and the open card's title row are buttons named by the title and description, for example "Sleep, 7 h 40 min", and report expanded or collapsed.
  • Closed details are unmounted, so screen readers and keyboards never land on hidden content; the faded-out tile is hidden while the card is open.
  • Cards keep reading order in the grid, whatever their position on screen; the chevron is decorative and hidden.
  • Tiles are far larger than 44 points, and the open card's title row is at least 44 points tall.
  • Right-to-left layouts mirror the grid: tiles start at the right and the open card grows from the right edge.

Motion

  • Uses the press, layout and toggle motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • Position, size and the group's height spring together on the layout role, so the tiles and the content under the group move as one.
  • The tile fades out in the first half of the move and the details fade in at the end, so the two layouts never overlap.
  • The chevron turns on the toggle role. Under Reduce Motion, or with the none feel, cards open and close instantly.

Performance

  • Frames are a few sums per card and animate on the UI thread; details mount only while a card is open or closing.
  • Content is laid out at its final size, so text doesn't re-wrap while a card grows.

Notes for AI

  • Wrap cards in ExpandableCardGroup to get the grid; give each an id so value and onValueChange can name them.
  • Put the summary in title and description and the breakdown in children; pass leading for an icon.
  • Use columns={3} only for very short titles; on phones two columns keep tiles readable.
  • Control one card with expanded and onExpandedChange, or the whole group with value and onValueChange.

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