suiss/uim · React Native Component

Card

A container that groups related content and actions with a header, body and footer.

Card is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Card on iOS in light mode

Card is a rounded View that stacks a CardHeader, CardContent and CardFooter with consistent spacing. The default variant is a raised surface with a hairline border and a shadow; the filled variant is a flat secondary surface.

The sm size reduces the padding and gaps for dense layouts. All parts read the size from context, so their horizontal padding stays aligned.

Installation

$ pnpm dlx @esuiss/uim@latest add card

The CLI also adds what it builds on: Text.

Manual

  1. Install the dependencies:
npx expo install cn
  1. Add the pieces it builds on: Text.

  2. Copy the source into components/ui/card.tsx:

uniwind/components/ui/card.tsx
import { cn } from "cn"
import * as React from "react"
import { View } from "react-native"
import { Text, TextClassContext } from "@/components/ui/text"

type CardSize = "default" | "sm"

type CardVariant = "default" | "filled"

const CardSizeContext = React.createContext<CardSize>("default")

const SPACING_X: Record<CardSize, string> = { default: "px-6", sm: "px-4" }

function Card({
  className,
  size = "default",
  1. Update the import paths to match your project.

Usage

import { Card, CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter } from "@/components/ui/card"
<Card className="w-full">
  <CardHeader>
    <CardTitle>Login to your account</CardTitle>
    <CardDescription>
      Enter your email below to login to your account
    </CardDescription>
  </CardHeader>
  <CardContent className="gap-4">
    <View className="gap-2">
      <Label nativeID="card-email">Email</Label>
      <Input
        accessibilityLabelledBy="card-email"
        placeholder="[email protected]"
        keyboardType="email-address"
        autoCapitalize="none"
      />
    </View>
    <View className="gap-2">
      <Label nativeID="card-password">Password</Label>
      <Input accessibilityLabelledBy="card-password" secureTextEntry />
    </View>
  </CardContent>
  <CardFooter className="flex-col gap-2">
    <Button block>
      <Text>Login</Text>
    </Button>
    <Button block variant="secondary">
      <Text>Login with Google</Text>
    </Button>
  </CardFooter>
</Card>

Put a CardTitle and CardDescription in CardHeader. Add a CardAction anywhere in the header and it is placed in the top-end corner beside the title.

To show an image edge to edge, place it directly in the card before the header and add pt-0 to the card; only the header, content and footer are padded horizontally.

Examples

Small

The compact sm size.

iOS
Card (small) on iOS in light mode

With action

A CardAction button beside the title.

iOS
Card (with action) on iOS in light mode

With image

An edge-to-edge image above the header.

iOS
Card (with image) on iOS in light mode

Filled

The flat filled variant.

iOS
Card (filled) on iOS in light mode

API Reference

Card

Outer container that sets the size and variant.

ExtendsReact.ComponentProps<typeof View>React.RefAttributes<View>
PropType
About
default or sm.
Type
CardSize
Default
"default"
About
default (raised) or filled.
Type
CardVariant
Default
"default"

CardHeader

Title area; places a CardAction beside the text.

ExtendsReact.ComponentProps<typeof View>React.RefAttributes<View>

CardTitle

Bold heading.

ExtendsReact.ComponentProps<typeof Text>React.RefAttributes<typeof Text>

CardDescription

Secondary text below the title.

ExtendsReact.ComponentProps<typeof Text>React.RefAttributes<typeof Text>

CardAction

Slot for a button in the header.

ExtendsReact.ComponentProps<typeof View>React.RefAttributes<View>

CardContent

Padded body.

ExtendsReact.ComponentProps<typeof View>React.RefAttributes<View>

CardFooter

Padded row for actions.

ExtendsReact.ComponentProps<typeof View>React.RefAttributes<View>

Accessibility

  • CardTitle has the heading role.
  • The card itself adds no role; actions inside provide their own.

Notes

  • Uses bg-surface-raised with a shadow, or bg-surface-secondary for filled; the border is stronger in dark mode.
  • Light and dark follow the system appearance.