Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 952
Aris Guimerá Avatar asked Dec 06 '25 17:12

Aris Guimerá


2 Answers

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."

like image 152
Mobin Yardim Avatar answered Dec 09 '25 21:12

Mobin Yardim


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

like image 31
RaBaKa 78 Avatar answered Dec 09 '25 19:12

RaBaKa 78



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!