Modifier
Almost every composable has a modifier parameter. A Modifier changes how an element is sized, placed, drawn, and how it reacts to input, without the composable having a parameter for each.
Example
Text(
"Hello",
modifier = Modifier
.padding(16.dp) // space around it
.fillMaxWidth() // as wide as the parent
.clickable { /* ... */ } // react to clicks
)
What a Modifier is
A Modifier is an ordered list of instructions. Modifier on its own is the empty list. Each call like .padding(16.dp) returns a new, longer list; nothing is changed in place.
That is why every chain starts with Modifier and is passed as one value:
val cardModifier = Modifier.fillMaxWidth().padding(8.dp) // a value like any other
Card(modifier = cardModifier) { ... }
Modifier functions come from several libraries, but you use them the same way. Your editor imports them as you type.
Order matters
The chain is applied from left to right, outside to inside. Each modifier wraps everything after it.

Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
// Padding first: the background is drawn inside the padding.
Text(
"padding, then background",
Modifier.padding(16.dp).background(MaterialTheme.colorScheme.primaryContainer),
)
// Background first: the background also covers the padding.
Text(
"background, then padding",
Modifier.background(MaterialTheme.colorScheme.primaryContainer).padding(16.dp),
)
}
padding(16.dp).background(...): first make room, then paint the smaller area that is left.background(...).padding(16.dp): first paint the whole area, then make room inside it.
The same goes for clicks. Modifier.clickable { }.padding(16.dp) makes the padding clickable too; Modifier.padding(16.dp).clickable { } doesn't. A good rule: put clickable and clip before padding, so the click area and the ripple cover the whole element.
Size

Column(
Modifier.width(320.dp).border(1.dp, MaterialTheme.colorScheme.outlineVariant).padding(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Block("size(64.dp)", Modifier.size(64.dp))
Block("width(200.dp).height(40.dp)", Modifier.width(200.dp).height(40.dp))
Block("fillMaxWidth().height(40.dp)", Modifier.fillMaxWidth().height(40.dp))
Block("fillMaxWidth(0.5f).height(40.dp)", Modifier.fillMaxWidth(0.5f).height(40.dp))
}
/** A colored box with a label, to show sizes. */
@Composable
fun Block(label: String, modifier: Modifier) {
Box(modifier.background(MaterialTheme.colorScheme.secondaryContainer), contentAlignment = Alignment.Center) {
Text(label, style = MaterialTheme.typography.labelMedium)
}
}
| Modifier | Does |
|---|---|
Modifier.size, Modifier.width, Modifier.height |
A fixed size, in dp |
Modifier.fillMaxWidth, Modifier.fillMaxHeight, Modifier.fillMaxSize |
As big as the parent allows. Pass a fraction, like 0.5f, for part of it |
Modifier.widthIn, Modifier.heightIn, Modifier.sizeIn |
A smallest and largest size: widthIn(min = 120.dp, max = 400.dp) |
Modifier.defaultMinSize |
A smallest size, only if nothing else sets one |
Modifier.wrapContentSize |
As small as the content, even if the parent asks for more |
Modifier.aspectRatio |
Height follows width: aspectRatio(16f / 9f) |
Modifier.requiredSize |
A size even if the parent says it doesn't fit. Rarely needed |
The parent always has the last word. A size(500.dp) inside a 300 dp wide Column gets 300 dp, unless you use requiredSize.
Space inside rows and columns
Some modifiers only exist inside a certain parent. They come from its scope, the this inside its content lambda:

Row(Modifier.width(320.dp).height(48.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Block("72 dp", Modifier.width(72.dp).fillMaxHeight())
Block("weight(1f)", Modifier.weight(1f).fillMaxHeight())
Block("weight(2f)", Modifier.weight(2f).fillMaxHeight())
}
/** A colored box with a label, to show sizes. */
@Composable
fun Block(label: String, modifier: Modifier) {
Box(modifier.background(MaterialTheme.colorScheme.secondaryContainer), contentAlignment = Alignment.Center) {
Text(label, style = MaterialTheme.typography.labelMedium)
}
}
RowScope.weightandColumnScope.weightshare the free space:weight(2f)gets twice as much asweight(1f).RowScope.align,ColumnScope.alignandBoxScope.alignmove one child, likeModifier.align(Alignment.End).BoxScope.matchParentSizemakes a child as big as theBox, without making theBoxbigger.
If your editor doesn't offer weight, you are not directly inside a Row or Column.
Padding and position
Modifier.padding: space around the content.padding(16.dp),padding(horizontal = 16.dp), orpadding(start = 8.dp, top = 4.dp).Modifier.offset: moves the element without moving anything else. Its old space stays empty.Modifier.systemBarsPadding,Modifier.safeDrawingPadding,Modifier.imePadding: keep clear of the status bar, the navigation bar, a notch, or the on-screen keyboard. On desktop they are zero.
Padding takes no colors. For space between children, prefer Arrangement.spacedBy(8.dp) on the Row or Column over padding on each child.
Looks

val shape = RoundedCornerShape(16.dp)
Row(horizontalArrangement = Arrangement.spacedBy(16.dp), verticalAlignment = Alignment.CenterVertically) {
Box(Modifier.size(64.dp).background(MaterialTheme.colorScheme.primary, shape))
Box(Modifier.size(64.dp).border(3.dp, MaterialTheme.colorScheme.primary, shape))
Box(Modifier.size(64.dp).clip(CircleShape).background(MaterialTheme.colorScheme.tertiary))
Box(Modifier.size(64.dp).shadow(8.dp, shape).background(MaterialTheme.colorScheme.surface))
}
| Modifier | Does |
|---|---|
Modifier.background |
Fills with a color or Brush, optionally in a shape |
Modifier.border |
Draws an outline: border(1.dp, color, shape) |
Modifier.clip |
Cuts off everything outside a Shape. Content and clicks too |
Modifier.shadow |
A shadow in a shape, like elevation |
Modifier.alpha |
Makes it see-through: alpha(0.5f) |
Modifier.blur |
Blurs it |
Inside Material components, use their own parameters instead, like shape and colors on a Card. They also handle the disabled and pressed states.
Transformations

Row(Modifier.padding(8.dp), horizontalArrangement = Arrangement.spacedBy(24.dp)) {
listOf(
Modifier.offset(x = 8.dp, y = 8.dp),
Modifier.rotate(20f),
Modifier.scale(1.3f),
Modifier.alpha(0.4f),
).forEach { effect ->
Icon(
Icons.Filled.Favorite,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
modifier = Modifier.size(40.dp).then(effect),
)
}
}
Modifier.offset, Modifier.rotate, Modifier.scale and Modifier.alpha change how the element is drawn, not its size in the layout. Neighbors don't move.
For several at once, or values that animate every frame, use Modifier.graphicsLayer:
Modifier.graphicsLayer {
rotationZ = angle
scaleX = 1.2f
alpha = 0.8f
}
Drawing your own

val dot = MaterialTheme.colorScheme.tertiaryContainer
Text(
"Drawn behind",
Modifier
.padding(8.dp)
.drawBehind {
// size is the size of the element, in pixels.
drawCircle(dot, radius = size.height / 2, center = Offset(size.height / 2, size.height / 2))
}
.padding(horizontal = 24.dp, vertical = 12.dp),
)
Modifier.drawBehind: draw under the content.Modifier.drawWithContent: draw under and over it. CalldrawContent()where the content goes.Modifier.drawWithCache: like the others, but keeps objects like brushes between frames.
Inside, size is the size of the element in pixels, and you have drawCircle, drawRect, drawLine, drawPath and more.
Clicks and input
Modifier.clickable { open(item) }
Modifier.combinedClickable(onClick = { open(item) }, onLongClick = { select(item) })
Modifier.toggleable(value = checked, onValueChange = { checked = it })
Modifier.selectable(selected = isSelected, onClick = { pick(item) })
Modifier.clickable: a click, with a ripple and the right screen reader info.Modifier.combinedClickable: also long-click and double-click.Modifier.toggleableandModifier.selectable: for a whole row that works like a checkbox or radio button. UseModifier.selectableGroupon the parent of radio-like rows.Modifier.draggable,Modifier.pointerInput: drags and your own gestures.Modifier.hoverable,Modifier.focusable: hover and keyboard focus. Useful on desktop and web.
Buttons, cards and list items already have onClick. Use these modifiers for your own elements.
To know whether an element is pressed, hovered or focused, pass your own interactionSource and read it. See InteractionSource.
Scrolling
Column(Modifier.verticalScroll(rememberScrollState())) { ... }
Row(Modifier.horizontalScroll(rememberScrollState())) { ... }
Modifier.verticalScroll and Modifier.horizontalScroll make a Column or Row scroll. For long lists, use LazyColumn and LazyRow instead: they only create the items on screen.
Reading size and position
Modifier.onSizeChanged: called with the size in pixels when it changes.Modifier.onGloballyPositioned: called with the position on screen.Modifier.layout: measure and place the element yourself.
Screen readers and tests
Modifier.semantics: adds information for screen readers, likecontentDescriptionor a role.Modifier.clearAndSetSemantics: replaces what the children say with one description.Modifier.testTag: a name to find the element in UI tests.
Material's own modifiers
Modifier.minimumInteractiveComponentSize: makes small clickable elements at least 48 dp for touch. Material components already use it.Modifier.pullToRefresh: the gesture behindPullToRefreshBox.Modifier.animateFloatingActionButton: hides or shows a FAB with an animation.
Writing composables that take a Modifier
Give your own composables a modifier parameter too. The convention:
- Name it
modifier, typeModifier, defaultModifier. - Make it the first parameter with a default value.
- Apply it to the outermost element, first in the chain. Add your own modifiers after it.
- Apply it once only, not to children.

Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
Tag("Default")
// The caller adds size and color; Tag keeps its own padding and shape.
Tag("Wide and clickable", Modifier.width(240.dp).clickable { /* open */ })
}
/** Takes a Modifier and applies it first, to the outermost element. */
@Composable
fun Tag(text: String, modifier: Modifier = Modifier) {
Text(
text,
modifier = modifier
.clip(MaterialTheme.shapes.small)
.background(MaterialTheme.colorScheme.secondaryContainer)
.padding(horizontal = 12.dp, vertical = 6.dp),
style = MaterialTheme.typography.labelLarge,
)
}
Then callers can size, place and pad your composable from outside, like any Material component.
Modifiers that depend on a condition
Use then to add a modifier only sometimes:
Modifier
.padding(8.dp)
.then(if (isSelected) Modifier.border(2.dp, MaterialTheme.colorScheme.primary) else Modifier)
Modifier on its own adds nothing, so the else branch keeps the chain as it is.
Summary
| You want | Write |
|---|---|
| Space around | Modifier.padding(16.dp) |
| A fixed size | Modifier.size(48.dp) |
| Full width | Modifier.fillMaxWidth() |
| Share space in a Row | Modifier.weight(1f) |
| A colored, rounded box | Modifier.clip(RoundedCornerShape(8.dp)).background(color) |
| An outline | Modifier.border(1.dp, color, shape) |
| Clickable | Modifier.clickable { } |
| Scrolling | Modifier.verticalScroll(rememberScrollState()) |
| Only sometimes | .then(if (x) Modifier.border(...) else Modifier) |