Reference version

卡片

一个用于在样式化容器中显示内容的 Jetpack Compose 卡片组件。

Android
Bundled version:
~55.0.0-beta.0

For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.

Expo UI Card 与官方 Jetpack Compose Card API 保持一致,并在带有样式的 surface 容器中显示内容,可选支持阴影和轮廓。

安装

Terminal
npx expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

使用

基础卡片

BasicCardExample.tsx
import { Host, Card, Text } from '@expo/ui/jetpack-compose'; import { paddingAll } from '@expo/ui/jetpack-compose/modifiers'; export default function BasicCardExample() { return ( <Host matchContents> <Card> <Text modifiers={[paddingAll(16)]}>这是一个带有默认样式的基础卡片。</Text> </Card> </Host> ); }

卡片类型

使用 CardElevatedCardOutlinedCard 来呈现不同样式。

CardTypesExample.tsx
import { Host, Card, ElevatedCard, OutlinedCard, Text, Column } from '@expo/ui/jetpack-compose'; import { paddingAll } from '@expo/ui/jetpack-compose/modifiers'; export default function CardTypesExample() { return ( <Host matchContents> <Column verticalArrangement={{ spacedBy: 12 }}> <Card> <Text modifiers={[paddingAll(16)]}>默认卡片</Text> </Card> <ElevatedCard> <Text modifiers={[paddingAll(16)]}>带阴影的卡片</Text> </ElevatedCard> <OutlinedCard> <Text modifiers={[paddingAll(16)]}>带轮廓的卡片</Text> </OutlinedCard> </Column> </Host> ); }

API

import { Card, ElevatedCard, OutlinedCard } from '@expo/ui/jetpack-compose';

Components

Card

Android

Type: React.Element<ComponentType<CardProps>>

A card component that renders a filled card surface for content.

CardProps

border

Android
Optional • Type: CardBorder

Border configuration for the card.

children

Android
Optional • Type: React.ReactNode

The content to display inside the card.

colors

Android
Optional • Type: CardColors

Colors for card's core elements.

elevation

Android
Optional • Type: number

Default elevation in dp.

modifiers

Android
Optional • Type: ModifierConfig[]

Modifiers for the component.

ElevatedCard

Android

Type: React.Element<ComponentType<ElevatedCardProps>>

An elevated card component that provides a raised surface for content.

ElevatedCardProps

children

Android
Optional • Type: React.ReactNode

The content to display inside the card.

colors

Android
Optional • Type: CardColors

Colors for card's core elements.

elevation

Android
Optional • Type: number

Default elevation in dp. Material 3 default is 1dp.

modifiers

Android
Optional • Type: ModifierConfig[]

Modifiers for the component.

OutlinedCard

Android

Type: React.Element<ComponentType<OutlinedCardProps>>

An outlined card component that provides a bordered surface for content.

OutlinedCardProps

border

Android
Optional • Type: CardBorder

Border configuration for the outlined card.

children

Android
Optional • Type: React.ReactNode

The content to display inside the card.

colors

Android
Optional • Type: CardColors

Colors for card's core elements.

elevation

Android
Optional • Type: number

Default elevation in dp.

modifiers

Android
Optional • Type: ModifierConfig[]

Modifiers for the component.

Types

CardBorder

Android

Border configuration for cards.

PropertyTypeDescription
color(optional)ColorValue

Border color.

width(optional)number

Border width in dp.

Default:1

CardColors

Android

Colors for card's core elements.

PropertyTypeDescription
containerColor(optional)ColorValue
-
contentColor(optional)ColorValue
-