androidx.compose.material3
Surface
Composable function
A surface is a container with a background color, a shape, an optional shadow and an optional outline.
Most Material components, like Card and Button, are a Surface with some defaults. Use it when no component fits.
A surface also sets the content color: text and icons inside get the matching "on" color, like onPrimaryContainer on primaryContainer.

Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Surface(color = MaterialTheme.colorScheme.primaryContainer, shape = MaterialTheme.shapes.medium) {
Text("Colored", Modifier.padding(16.dp))
}
Surface(shadowElevation = 6.dp, shape = MaterialTheme.shapes.medium) {
Text("Shadow", Modifier.padding(16.dp))
}
Surface(border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline), shape = MaterialTheme.shapes.medium) {
Text("Outline", Modifier.padding(16.dp))
}
}
Basic
Not clickable.
@Composable
fun Surface(
modifier: Modifier = Modifier,
shape: Shape = RectangleShape,
color: Color = MaterialTheme.colorScheme.surface,
contentColor: Color = contentColorFor(color),
tonalElevation: Dp = 0.dp,
shadowElevation: Dp = 0.dp,
border: BorderStroke? = null,
content: @Composable () -> Unit,
)
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
shape: ShapeOptional
shape: ShapeOptionalDefault: RectangleShape
Sets the outline. Default: square corners. See the Shapes guide.
color: ColorOptional
color: ColorOptionalDefault: MaterialTheme.colorScheme.surface
The background color. Default: the theme's surface.
contentColor: ColorOptional
contentColor: ColorOptionalDefault: contentColorFor(color)
The default color for text and icons inside. Default: the matching "on" color for color.
tonalElevation: DpOptional
tonalElevation: DpOptionalDefault: 0.dp
Tints the background a little toward the primary color. Higher values give a stronger tint.
This only works when color is the theme's surface.
shadowElevation: DpOptional
shadowElevation: DpOptionalDefault: 0.dp
The size of the shadow under the surface.
border: BorderStroke?Optional
border: BorderStroke?OptionalDefault: null
Draws an outline. null means no outline.
content: @Composable () -> UnitRequired
content: @Composable () -> UnitRequiredClickable
Takes onClick.
@Composable
fun Surface(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
shape: Shape = RectangleShape,
color: Color = MaterialTheme.colorScheme.surface,
contentColor: Color = contentColorFor(color),
tonalElevation: Dp = 0.dp,
shadowElevation: Dp = 0.dp,
border: BorderStroke? = null,
interactionSource: MutableInteractionSource? = null,
content: @Composable () -> Unit,
)
onClick: () -> UnitRequired
onClick: () -> UnitRequiredCalled when the surface is clicked. Only on the clickable, selectable and toggleable forms.

Surface(
onClick = {},
color = MaterialTheme.colorScheme.secondaryContainer,
shape = CircleShape,
) {
Text("Tap me", Modifier.padding(horizontal = 20.dp, vertical = 10.dp))
}
enabled: BooleanOptional
enabled: BooleanOptionalDefault: true
Set to false to make it not clickable. The surface does not turn gray by itself.
interactionSource: MutableInteractionSource?Optional
interactionSource: MutableInteractionSource?OptionalDefault: null
Lets you observe or control press, hover and focus states. Leave it null unless your code must react to them. See InteractionSource.
Same as above: modifier, shape, color, contentColor, tonalElevation, shadowElevation, border, content.
Selectable
Takes selected and onClick, like a tab or a radio button.
@Composable
fun Surface(
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
shape: Shape = RectangleShape,
color: Color = MaterialTheme.colorScheme.surface,
contentColor: Color = contentColorFor(color),
tonalElevation: Dp = 0.dp,
shadowElevation: Dp = 0.dp,
border: BorderStroke? = null,
interactionSource: MutableInteractionSource? = null,
content: @Composable () -> Unit,
)
selected: BooleanRequired
selected: BooleanRequiredWhether the surface is selected. Screen readers announce it.
Same as above: onClick, modifier, enabled, shape, color, contentColor, tonalElevation, shadowElevation, border, interactionSource, content.
Toggleable
Takes checked and onCheckedChange, like a switch.
@Composable
fun Surface(
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
shape: Shape = RectangleShape,
color: Color = MaterialTheme.colorScheme.surface,
contentColor: Color = contentColorFor(color),
tonalElevation: Dp = 0.dp,
shadowElevation: Dp = 0.dp,
border: BorderStroke? = null,
interactionSource: MutableInteractionSource? = null,
content: @Composable () -> Unit,
)
checked: BooleanRequired
checked: BooleanRequiredWhether the surface is checked. Screen readers announce it as on or off.
onCheckedChange: (Boolean) -> UnitRequired
onCheckedChange: (Boolean) -> UnitRequiredCalled with the new value when the surface is clicked.
Same as above: modifier, enabled, shape, color, contentColor, tonalElevation, shadowElevation, border, interactionSource, content.