Aris Guimerá
Aris Guimerá

Reputation: 1017

Whats the difference between Surface and Card in Jetpack Compose?

It's basically the same right? They have the same properties. I really don't know when I have to use each.

Technically Cards is for a Card view but Surface have the same properties like elevation and border

Upvotes: 17

Views: 7558

Answers (2)

RaBaKa 78
RaBaKa 78

Reputation: 1445

It's all about Material Design Guidelines

When you read the Material Design documentation, you will understand that these two components are used for different purposes.

Surface is used when you want a surface for your UI, you can set the background color, shape etc.

Card on the other hand, have default elevation(Material Design Standard) and pretty much have every property as the surface.

It's All about following Material Design Guidelines

Upvotes: 5

Mobin Yardim
Mobin Yardim

Reputation: 1004

If you look at Card composable source you will understand that card is a surface with default elevation and, the background shape is MaterialTheme.shapes.medium

as the documentation "Cards are Surfaces that display content and actions on a single topic."

Upvotes: 18

Related Questions