Complete Jetpack Compose Modifiers Reference

Jetpack Compose Modifiers

This comprehensive guide covers all Jetpack Compose modifiers, as detailed in the official Android documentation. Modifiers are organized by category, with each including its Kotlin signature, applicable scope, description, and, for selected modifiers, a detailed breakdown of parameters with their types and usage. Navigate to each category using the chips below.


Actions

Modifier SignatureScopeDescription
Modifier.anchoredDraggable(
    state: AnchoredDraggableState<T>,
    orientation: Orientation,
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource? = null,
    overscrollEffect: OverscrollEffect? = null,
    flingBehavior: FlingBehavior? = null
)
ParameterTypeUsage
stateAnchoredDraggableState<T>Manages the state of the draggable item, including current and target anchor points.
orientationOrientationSpecifies whether dragging is horizontal or vertical.
enabledBooleanDetermines if the dragging is enabled (default: true).
interactionSourceMutableInteractionSource?Optional source for collecting interaction events like drag start/end.
overscrollEffectOverscrollEffect?Optional effect for overscrolling behavior, like bounce or stretch.
flingBehaviorFlingBehavior?Optional behavior for fling animations after dragging.
Any Enable drag gestures between a set of predefined values.
Modifier.anchoredDraggable(
    state: AnchoredDraggableState<T>,
    reverseDirection: Boolean,
    orientation: Orientation,
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource? = null,
    overscrollEffect: OverscrollEffect? = null,
    flingBehavior: FlingBehavior? = null
)
Any Enable drag gestures between a set of predefined values, with option to reverse direction.
Modifier.clickable(
    enabled: Boolean = true,
    onClickLabel: String? = null,
    role: Role? = null,
    interactionSource: MutableInteractionSource? = null,
    onClick: () -> Unit
)
Any Configure component to receive clicks via input or accessibility "click" event.
Modifier.combinedClickable(
    enabled: Boolean = true,
    onClickLabel: String? = null,
    role: Role? = null,
    interactionSource: MutableInteractionSource? = null,
    onLongClickLabel: String? = null,
    onLongClick: (() -> Unit)? = null,
    onDoubleClick: (() -> Unit)? = null,
    onClick: () -> Unit
)
Any Configure component to receive click, double click, and long click events.

Alignment

Modifier SignatureScopeDescription
Modifier.align(
    alignment: Alignment.Vertical
)
ParameterTypeUsage
alignmentAlignment.VerticalSpecifies the vertical alignment (e.g., Top, Center, Bottom) within the Row.
RowScope Align the element vertically within the Row.
Modifier.align(
    alignment: Alignment
)
BoxScope Pull the content element to a specific Alignment within the Box.
Modifier.alignBy(
    alignmentLineBlock: (Measured) -> Int
)
RowScope, ColumnScope Position the element such that its alignment line, determined by alignmentLineBlock, aligns with sibling elements.
Modifier.alignByBaseline()
RowScope Align the element vertically by its baseline within the Row.

Animation

Modifier SignatureScopeDescription
@ExperimentalSharedTransitionApi
Modifier.animateBounds(
    lookaheadScope: LookaheadScope,
    modifier: Modifier,
    boundsTransform: BoundsTransform,
    animateMotionFrameOfReference: Boolean = false
)
ParameterTypeUsage
lookaheadScopeLookaheadScopeScope for predictive layout calculations to optimize animations.
modifierModifierThe modifier to apply within the animation context.
boundsTransformBoundsTransformDefines how bounds (size/position) transition during animation.
animateMotionFrameOfReferenceBooleanControls whether motion is relative to the frame of reference (default: false).
Any Modifier to animate layout changes (position and/or size) that occur within a LookaheadScope.
Modifier.animateItem(
    fadeInSpec: FiniteAnimationSpec<Float>? = null,
    placementSpec: FiniteAnimationSpec<IntOffset>? = null,
    fadeOutSpec: FiniteAnimationSpec<Float>? = null
)
LazyItemScope Animates item appearance (fade in), disappearance (fade out), and placement changes in lazy layouts.
Modifier.animateContentSize(
    animationSpec: FiniteAnimationSpec<IntSize> = spring(),
    alignment: Alignment = Alignment.TopStart
)
Any Animates changes to the content size with the specified animation spec and alignment.

Border

Modifier SignatureScopeDescription
Modifier.border(
    border: BorderStroke,
    shape: Shape
)
ParameterTypeUsage
borderBorderStrokeDefines the border's width and style (e.g., solid, dashed).
shapeShapeSpecifies the shape of the border (e.g., RectangleShape, RoundedCornerShape).
Any Modify element to add border with appearance specified with a border and a shape and clip it.
Modifier.border(
    width: Dp,
    color: Color,
    shape: Shape
)
Any Add border with specified width, color, and shape, and clip the content.
Modifier.border(
    width: Dp,
    brush: Brush,
    shape: Shape
)
Any Add border with specified width, brush (gradient or pattern), and shape, and clip the content.

Drawing

Modifier SignatureScopeDescription
Modifier.background(
    color: Color,
    shape: Shape
)
ParameterTypeUsage
colorColorSets the solid color for the background.
shapeShapeDefines the shape of the background (e.g., RectangleShape, CircleShape).
Any Draws shape with a solid color behind the content.
Modifier.background(
    brush: Brush,
    shape: Shape
)
Any Draws shape with a gradient or pattern brush behind the content.
Modifier.clip(
    shape: Shape
)
Any Clip the content to the specified shape.
Modifier.clipToBounds()
Any Clip the content to the bounds of the composable.
Modifier.drawBehind(
    onDraw: DrawScope.() -> Unit
)
Any Draw behind the content using a custom drawing block.
Modifier.drawWithCache(
    onBuildDrawCache: CacheDrawScope.() -> DrawResult
)
Any Draw content with cached drawing operations for performance.
Modifier.drawWithContent(
    onDraw: DrawScope.() -> Unit
)
Any Draw over the content using a custom drawing block.
Modifier.paint(
    painter: Painter,
    sizeToIntrinsics: Boolean = true,
    alignment: Alignment = Alignment.Center,
    contentScale: ContentScale = ContentScale.Fit,
    alpha: Float = 1.0f,
    colorFilter: ColorFilter? = null
)
Any Draw a painter (e.g., image or vector) behind the content.
Modifier.shadow(
    elevation: Dp,
    shape: Shape = RectangleShape,
    clip: Boolean = elevation > 0.dp,
    ambientColor: Color = Color.Black,
    spotColor: Color = Color.Black
)
Any Creates a graphicsLayer that draws a shadow.

Focus

Modifier SignatureScopeDescription
Modifier.focusable(
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource? = null
)
ParameterTypeUsage
enabledBooleanDetermines if the component can receive focus (default: true).
interactionSourceMutableInteractionSource?Optional source for collecting focus interaction events.
Any Make the component focusable for accessibility and keyboard navigation.
Modifier.focusGroup()
Any Group multiple focusable components to be navigated as a single unit.
Modifier.focusProperties(
    block: FocusProperties.() -> Unit
)
Any Customize focus behavior, such as focus order or traversal.
Modifier.focusRequester(
    focusRequester: FocusRequester
)
Any Associate a focus requester to programmatically control focus.
Modifier.focusTarget()
Any Make the component focusable without additional configuration.
Modifier.onFocusChanged(
    onFocusChanged: (FocusState) -> Unit
)
Any Observe focus state changes (e.g., focused or unfocused).
Modifier.onFocusEvent(
    onFocusEvent: (FocusState) -> Unit
)
Any Observe focus events for the component and its children.

Graphics

Modifier SignatureScopeDescription
Modifier.graphicsLayer(
    block: GraphicsLayerScope.() -> Unit
)
ParameterTypeUsage
blockGraphicsLayerScope.() -> UnitConfigures properties like scale, rotation, or alpha for the graphics layer.
Any A Modifier.Node that makes content draw into a draw layer.

Keyboard

Modifier SignatureScopeDescription
Modifier.onKeyEvent(
    onKeyEvent: (KeyEvent) -> Boolean
)
ParameterTypeUsage
onKeyEvent(KeyEvent) -> BooleanCallback to handle hardware key events, returning true if consumed.
Any Intercept hardware key events when the component or its children are focused.
Modifier.onPreviewKeyEvent(
    onPreviewKeyEvent: (KeyEvent) -> Boolean
)
Any Intercept hardware key events before they are processed by children.

Layout

Modifier SignatureScopeDescription
Modifier.layoutId(
    layoutId: Any
)
ParameterTypeUsage
layoutIdAnyUnique identifier for the element within its parent for layout purposes.
Any Tag the element with layoutId to identify the element within its parent.
Modifier.layout(
    measure: MeasureScope.(Measurable, Constraints) -> MeasureResult
)
Any Customize the layout measurement and placement of the composable.
Modifier.onGloballyPositioned(
    onGloballyPositioned: (LayoutCoordinates) -> Unit
)
Any Invoke a callback with the LayoutCoordinates when the global position changes.
Modifier.onPlaced(
    onPlaced: (LayoutCoordinates) -> Unit
)
Any Invoke a callback with the LayoutCoordinates when the composable is placed.
Modifier.onSizeChanged(
    onSizeChanged: (IntSize) -> Unit
)
Any Invoke a callback when the size of the composable changes.

Padding

Modifier SignatureScopeDescription
Modifier.padding(
    all: Dp
)
ParameterTypeUsage
allDpSets equal padding (in density-independent pixels) for all edges.
Any Apply equal padding to all edges of the content.
Modifier.padding(
    horizontal: Dp,
    vertical: Dp
)
Any Apply padding to horizontal and vertical edges separately.
Modifier.padding(
    start: Dp,
    top: Dp,
    end: Dp,
    bottom: Dp
)
Any Apply padding to each edge individually.
Modifier.padding(
    paddingValues: PaddingValues
)
Any Apply padding using a PaddingValues object.
Modifier.absolutePadding(
    left: Dp,
    top: Dp,
    right: Dp,
    bottom: Dp
)
Any Apply padding ignoring layout direction (e.g., left is always left).
Modifier.statusBarsPadding()
Any Add padding to accommodate status bar insets.
Modifier.navigationBarsPadding()
Any Add padding to accommodate navigation bar insets.
Modifier.systemBarsPadding()
Any Add padding to accommodate system bar insets (status and navigation).
Modifier.imePadding()
Any Add padding to accommodate the on-screen keyboard.

Pointer

Modifier SignatureScopeDescription
Modifier.pointerInput(
    key1: Any?,
    block: PointerInputEventHandler
)
ParameterTypeUsage
key1Any?Optional key to trigger recomposition when changed.
blockPointerInputEventHandlerHandles pointer input events like taps or drags within the element.
Any Create a modifier for processing pointer input within the region of the modified element.
Modifier.draggable(
    state: DraggableState,
    orientation: Orientation,
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource? = null,
    reverseDirection: Boolean = false,
    canDrag: ((Offset) -> Boolean)? = null,
    startDragImmediately: Boolean = false
)
Any Enable drag gestures in a single orientation.
Modifier.swipeable(
    state: SwipeableState<T>,
    anchors: Map<Float, T>,
    orientation: Orientation,
    enabled: Boolean = true,
    reverseDirection: Boolean = false,
    interactionSource: MutableInteractionSource? = null,
    thresholds: (T, T) -> ThresholdConfig = { _, _ -> FixedThreshold(56.dp) },
    resistance: ResistanceConfig? = null
)
Any Enable swipe gestures between anchored values.

Position

Modifier SignatureScopeDescription
Modifier.offset(
    x: Dp,
    y: Dp
)
ParameterTypeUsage
xDpHorizontal offset in density-independent pixels.
yDpVertical offset in density-independent pixels.
Any Offset the content by (x dp, y dp).
Modifier.offset(
    offset: (density: Density) -> IntOffset
)
Any Offset the content using a lambda that calculates the offset based on density.
Modifier.absoluteOffset(
    x: Dp,
    y: Dp
)
Any Offset the content ignoring layout direction.
Modifier.absoluteOffset(
    offset: (density: Density) -> IntOffset
)
Any Offset the content using a lambda, ignoring layout direction.

Semantics

Modifier SignatureScopeDescription
Modifier.semantics(
    mergeDescendants: Boolean = false,
    properties: SemanticsPropertyReceiver.() -> Unit
)
ParameterTypeUsage
mergeDescendantsBooleanIf true, merges descendant semantics into a single node (default: false).
propertiesSemanticsPropertyReceiver.() -> UnitConfigures accessibility properties like label or role.
Any Add custom semantics for accessibility purposes.
Modifier.clearAndSetSemantics(
    properties: SemanticsPropertyReceiver.() -> Unit
)
Any Replace all existing semantics with new properties.
Modifier.progressSemantics(
    value: Float,
    valueRange: ClosedFloatingPointRange<Float>,
    steps: Int = 0
)
Any Add semantics for a determinate progress indicator.
Modifier.progressSemantics()
Any Add semantics for an indeterminate progress indicator.

Scroll

Modifier SignatureScopeDescription
Modifier.scrollable(
    state: ScrollableState,
    orientation: Orientation,
    enabled: Boolean = true,
    reverseDirection: Boolean = false,
    flingBehavior: FlingBehavior? = null,
    interactionSource: MutableInteractionSource? = null
)
ParameterTypeUsage
stateScrollableStateManages the scroll state, including position and velocity.
orientationOrientationDefines scroll direction (horizontal or vertical).
enabledBooleanEnables or disables scrolling (default: true).
reverseDirectionBooleanReverses the scroll direction (default: false).
flingBehaviorFlingBehavior?Optional behavior for fling animations after scrolling.
interactionSourceMutableInteractionSource?Optional source for collecting scroll interaction events.
Any Configure touch scrolling and flinging for the UI element in a single Orientation.
Modifier.nestedScroll(
    connection: NestedScrollConnection,
    dispatcher: NestedScrollDispatcher? = null
)
Any Enable nested scrolling for the composable.

Size

Modifier SignatureScopeDescription
Modifier.size(
    size: Dp
)
ParameterTypeUsage
sizeDpSets both width and height to the same density-independent pixel value.
Any Declare the preferred size of the content to be exactly size dp square.
Modifier.size(
    width: Dp,
    height: Dp
)
Any Declare the preferred width and height of the content.
Modifier.fillMaxWidth(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
)
Any Fill the maximum available width, optionally by a fraction.
Modifier.fillMaxHeight(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
)
Any Fill the maximum available height, optionally by a fraction.
Modifier.fillMaxSize(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
)
Any Fill the maximum available width and height, optionally by a fraction.
Modifier.requiredSize(
    size: Dp
)
Any Force the content to be exactly size dp square, ignoring constraints.
Modifier.requiredSize(
    width: Dp,
    height: Dp
)
Any Force the content to specific width and height, ignoring constraints.
Modifier.width(
    width: Dp
)
Any Declare the preferred width of the content.
Modifier.height(
    height: Dp
)
Any Declare the preferred height of the content.
Modifier.requiredWidth(
    width: Dp
)
Any Force the content to a specific width, ignoring constraints.
Modifier.requiredHeight(
    height: Dp
)
Any Force the content to a specific height, ignoring constraints.
Modifier.widthIn(
    min: Dp = Dp.Unspecified,
    max: Dp = Dp.Unspecified
)
Any Constrain the width between optional min and max values.
Modifier.heightIn(
    min: Dp = Dp.Unspecified,
    max: Dp = Dp.Unspecified
)
Any Constrain the height between optional min and max values.
Modifier.sizeIn(
    minWidth: Dp = Dp.Unspecified,
    maxWidth: Dp = Dp.Unspecified,
    minHeight: Dp = Dp.Unspecified,
    maxHeight: Dp = Dp.Unspecified
)
Any Constrain both width and height between optional min and max values.

Testing

Modifier SignatureScopeDescription
Modifier.testTag(
    tag: String
)
ParameterTypeUsage
tagStringUnique identifier for locating the element in UI tests.
Any Applies a tag to allow modified element to be found in tests.

Transformations

Modifier SignatureScopeDescription
Modifier.rotate(
    degrees: Float
)
ParameterTypeUsage
degreesFloatAngle in degrees to rotate the composable around its center.
Any Sets the degrees the view is rotated around the center of the composable.
Modifier.scale(
    scale: Float
)
Any Scale the content uniformly on both axes by the same scale factor.
Modifier.scale(
    scaleX: Float,
    scaleY: Float
)
Any Scale the content independently on the horizontal and vertical axes.
Modifier.transformable(
    state: TransformableState,
    lockRotationOnZoom: Boolean = false,
    enabled: Boolean = true
)
Any Enable pinch-to-zoom, rotate, and pan gestures.

Other

Modifier SignatureScopeDescription
Modifier.blur(
    radius: Dp,
    edgeTreatment: BlurredEdgeTreatment
)
ParameterTypeUsage
radiusDpBlur radius in density-independent pixels.
edgeTreatmentBlurredEdgeTreatmentDefines how edges are handled during blur (e.g., clipped or faded).
Any Draw content blurred with the specified radii.
Modifier.composed(
    inspectorInfo: InspectorInfo.() -> Unit = noInspectorInfo,
    factory: @Composable Modifier.() -> Modifier
)
Any Declare a just-in-time composition of a Modifier.
Modifier.then(
    other: Modifier
)
Any Chain another modifier to this modifier.
Modifier.zIndex(
    zIndex: Float
)
Any Set the z-order of the composable for layering.
Modifier.weight(
    weight: Float,
    fill: Boolean = true
)
RowScope, ColumnScope Assign a weight to distribute space in a Row or Column.
Modifier.wrapContentWidth(
    align: Alignment.Horizontal = Alignment.CenterHorizontally,
    unbounded: Boolean = false
)
Any Size the content to its intrinsic width, with optional alignment.
Modifier.wrapContentHeight(
    align: Alignment.Vertical = Alignment.CenterVertically,
    unbounded: Boolean = false
)
Any Size the content to its intrinsic height, with optional alignment.
Modifier.wrapContentSize(
    align: Alignment = Alignment.Center,
    unbounded: Boolean = false
)
Any Size the content to its intrinsic size, with optional alignment.
Modifier.defaultMinSize(
    minWidth: Dp = Dp.Unspecified,
    minHeight: Dp = Dp.Unspecified
)
Any Set default minimum size constraints for the content.
Modifier.aspectRatio(
    ratio: Float,
    matchHeightConstraintsFirst: Boolean = false
)
Any Maintain a specific aspect ratio for the content.
Modifier.alpha(
    alpha: Float
)
Any Set the opacity of the content.

Post a Comment

Previous Post Next Post