Reference version

This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

修饰符

用于 @expo/ui 组件的 Jetpack Compose 布局修饰符

Android
Included in Expo Go
Recommended version:
~58.0.1

Jetpack Compose 修饰符可用于自定义 UI 组件的布局、外观和行为。修饰符相当于 Compose 中的样式属性,可控制尺寸、内边距、背景、交互等。

安装

Terminal
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

用法

使用 modifiers 属性和数组语法将修饰符应用于组件。你可以组合多个修饰符,创建复杂的样式和行为。修饰符按照它们在数组中出现的顺序应用,这可能会影响最终结果(例如,先应用 padding 再应用 background,与反过来应用会产生不同的效果)。

import { Button, Host } from '@expo/ui/jetpack-compose'; import { paddingAll, fillMaxWidth, background, border, shadow, clickable, } from '@expo/ui/jetpack-compose/modifiers'; function ModifiersExample() { return ( <Host style={{ flex: 1 }}> {/* Basic styling modifiers */} <Button modifiers={[ paddingAll(16), fillMaxWidth(), background('#FF6B6B'), ]}> Full-width padded button </Button> {/* Complex combination with border and shadow */} <Button modifiers={[ paddingAll(12), background('#4ECDC4'), border(2, '#2C3E50'), shadow(4), ]}> Styled with border and shadow </Button> </Host> ); }

内边距

控制组件内容周围的间距。

paddingAll(all)

在四边应用相同的内边距。

参数类型描述
allnumber内边距值,单位为 dp。
import { paddingAll } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[paddingAll(16)]}>Padded button</Button>;

padding(start, top, end, bottom)

为每一侧分别设置内边距。

参数类型描述
startnumber左侧/起始内边距,单位为 dp。
topnumber顶部内边距,单位为 dp。
endnumber右侧/结束内边距,单位为 dp。
bottomnumber底部内边距,单位为 dp。
import { padding } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[padding(16, 8, 16, 8)]}>Custom padding</Button>;

尺寸

控制组件的尺寸。

size(width, height)

设置组件的精确尺寸。

参数类型描述
widthnumber宽度,单位为 dp。
heightnumber高度,单位为 dp。
import { size } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[size(200, 48)]}>Fixed size</Button>;

fillMaxSize(fraction?)

填满两个方向上的所有可用空间。

参数类型描述
fractionnumber可用空间的占比(0.0–1.0)。默认值为 1.0。
import { fillMaxSize } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[fillMaxSize()]}>Fill all space</Button> <Button modifiers={[fillMaxSize(0.5)]}>Fill half</Button>

fillMaxWidth(fraction?)

填满可用宽度。

参数类型描述
fractionnumber可用宽度的占比(0.0–1.0)。默认值为 1.0。
import { fillMaxWidth } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[fillMaxWidth()]}>Full width</Button>;

fillMaxHeight(fraction?)

填满可用高度。

参数类型描述
fractionnumber可用高度的占比(0.0–1.0)。默认值为 1.0。

width(value)

设置精确宽度。

参数类型描述
valuenumber宽度,单位为 dp。

height(value)

设置精确高度。

参数类型描述
valuenumber高度,单位为 dp。

wrapContentWidth(alignment?)

将组件尺寸设置为适应其内容宽度。

参数类型描述
alignmentstring内容的水平对齐方式。

wrapContentHeight(alignment?)

将组件尺寸设置为适应其内容高度。

参数类型描述
alignmentstring内容的垂直对齐方式。

位置

控制组件相对于其自然位置的定位。

offset(x, y)

将组件从其自然位置偏移,且不影响周围组件的布局。

参数类型描述
xnumber水平偏移量,单位为 dp。
ynumber垂直偏移量,单位为 dp。
import { offset } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[offset(10, 5)]}>Offset button</Button>;

外观

控制组件的视觉外观。

background(color)

设置背景颜色。

参数类型描述
colorstring背景颜色(十六进制字符串)。
import { background } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[background('#3498DB')]}> Blue background </Button>;

border(borderWidth, borderColor)

为组件添加边框。

参数类型描述
borderWidthnumber边框宽度,单位为 dp。
borderColorstring边框颜色(十六进制字符串)。
import { border } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[border(2, '#E74C3C')]}>Bordered button</Button>;

shadow(elevation)

在组件下方添加仰角阴影。

参数类型描述
elevationnumber阴影仰角,单位为 dp。
import { shadow } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[shadow(8)]}>Elevated button</Button>;

dropShadow(shape, config?)

在组件后方绘制阴影,并可控制模糊半径、扩散范围、偏移量和颜色。与 shadow 不同,它不需要仰角值。

参数类型描述
shapeShape阴影形状(参见下方的形状表)。
config.radiusnumber模糊半径,单位为 dp。
config.spreadnumber扩展(正值)或收缩(负值)的幅度,单位为 dp。
config.colorstring阴影颜色(十六进制字符串)。默认为黑色。
config.offsetXnumber水平偏移量,单位为 dp。
config.offsetYnumber垂直偏移量,单位为 dp。
config.alphanumber阴影不透明度(0.0–1.0)。
import { dropShadow, Shapes, } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[ dropShadow(Shapes.RoundedCorner(24), { radius: 16, spread: 4, color: '#6200EE', offsetY: 8, }), ]}> Drop shadow </Button>;

innerShadow(shape, config?)

在组件内部绘制阴影,以创建内嵌效果。先应用 background 修饰符,再应用 innerShadow,以确保阴影能够渲染。

参数类型描述
shapeShape阴影形状(参见下方的形状表)。
config.radiusnumber模糊半径,单位为 dp。
config.spreadnumber扩展(正值)或收缩(负值)的幅度,单位为 dp。
config.colorstring阴影颜色(十六进制字符串)。默认为黑色。
config.offsetXnumber水平偏移量,单位为 dp。
config.offsetYnumber垂直偏移量,单位为 dp。
config.alphanumber阴影不透明度(0.0–1.0)。
import { innerShadow, background, Shapes, } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[ background('#FFFFFF'), innerShadow(Shapes.RoundedCorner(24), { radius: 16, spread: 2, offsetY: 6, }), ]}> Inner shadow </Button>;

alpha(alpha)

控制组件的不透明度。

参数类型描述
alphanumber不透明度值(0.0–1.0)。
import { alpha } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[alpha(0.5)]}>Semi-transparent</Button>;

blur(radius)

为组件应用模糊效果。

参数类型描述
radiusnumber模糊半径,单位为 dp。
import { blur } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[blur(4)]}>Blurred button</Button>;

阴影样式

常见阴影样式由 dropShadow 和 innerShadow 修饰符组合而成,而不是单独的 API。由于 modifiers 属性接受数组,你可以叠加并调整阴影修饰符,以构建各种样式。

新粗野主义阴影

新粗野主义阴影是一种边缘清晰、无模糊且带有粗边框的投影。将 radius 和 spread 设为 0,然后偏移阴影。

import { dropShadow, border, background, Shapes, } from '@expo/ui/jetpack-compose/modifiers'; <Box modifiers={[ dropShadow(Shapes.Rectangle, { radius: 0, spread: 0, offsetX: 8, offsetY: 8, color: '#000000', }), border(8, '#000000'), background('#FFFFFF'), ]} />;

新拟态阴影

新拟态阴影会在与背景颜色相同的表面上叠加两个投影:一个朝向光源的浅色阴影,以及一个位于相反方向的深色阴影。在 background 之前应用这两个阴影。

import { dropShadow, background, Shapes, } from '@expo/ui/jetpack-compose/modifiers'; const shape = Shapes.RoundedCorner(24); <Box modifiers={[ dropShadow(shape, { radius: 15, offsetX: -10, offsetY: -10, color: '#FFFFFF', }), dropShadow(shape, { radius: 15, offsetX: 10, offsetY: 10, color: '#B1B1B1', }), background('#E0E0E0'), ]} />;

要创建按下时的凹陷变体,请改用两个 innerShadow 修饰符,并将它们放在 background 之后。

变换

对组件应用视觉变换。

rotate(degrees)

旋转组件。

参数类型描述
degreesnumber旋转角度,单位为度。
import { rotate } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[rotate(45)]}>Rotated</Button>;

zIndex(index)

控制重叠组件的绘制顺序。

参数类型描述
indexnumber图层索引。
import { zIndex } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[zIndex(10)]}>On top</Button>;

动画

为组件内的布局变化添加动画。

animateContentSize(dampingRatio?, stiffness?)

使用弹簧动画,为组件内容的尺寸变化添加动画。

参数类型描述
dampingRationumber弹簧阻尼比。控制弹跳程度。
stiffnessnumber弹簧刚度。控制动画速度。
import { animateContentSize } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[animateContentSize()]}>Animated size</Button> <Button modifiers={[animateContentSize(0.5, 200)]}>Custom spring</Button>

布局

控制组件在父容器中的尺寸和位置。

weight(weight)

在 Row 或 Column 中为组件分配弹性权重,并按比例在具有权重的子项之间分配可用空间。

参数类型描述
weightnumber权重因子。
import { weight } from '@expo/ui/jetpack-compose/modifiers'; // In a Row, the first button takes 2/3 and the second takes 1/3 <Button modifiers={[weight(2)]}>Wider</Button> <Button modifiers={[weight(1)]}>Narrower</Button>

align(alignment)

设置组件在父容器中的对齐方式。

参数类型描述
alignmentstring组件在容器中的对齐方式。

matchParentSize()

将组件尺寸设置为与其父级 Box 相同。与 fillMaxSize 不同,它不会影响父级的测量结果。

import { matchParentSize } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[matchParentSize()]}>Match parent</Button>;

交互

为组件添加用户交互处理程序。

clickable(handler)

使组件能够响应点击事件。

参数类型描述
handler() => void点击时调用的回调。
import { clickable } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[clickable(() => console.log('Clicked!'))]}> Clickable </Button>;

combinedClickable(handlers, options?)

使组件能够响应短按和长按手势。它封装了 Compose 的 Modifier.combinedClickable。适用于长按时打开 DropdownMenu,同时在同一视图上保留单独的短按操作。

参数类型描述
handlers.onClick() => void短按时调用的可选回调。
handlers.onLongClick() => void长按时调用的可选回调。
options.indicationboolean是否显示涟漪反馈。默认为 true。
import { Text } from '@expo/ui/jetpack-compose'; import { combinedClickable } from '@expo/ui/jetpack-compose/modifiers'; <Text modifiers={[ combinedClickable({ onClick: () => console.log('Tapped'), onLongClick: () => setMenuExpanded(true), }), ]}> Long-press me </Text>;

selectable(selected, handler)

使组件可被选中,类似单选按钮。

参数类型描述
selectedboolean组件当前是否已选中。
handler() => void选择状态改变时调用的回调。
import { selectable } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[ selectable(isSelected, () => setIsSelected(!isSelected)), ]}> Selectable option </Button>;

裁剪

将组件内容裁剪为指定形状。

clip(shape)

将组件裁剪为指定形状。形状边界之外的内容不会绘制。

参数类型描述
shapeShape要裁剪成的形状。

可用形状

形状描述
Shapes.Rectangle没有圆角的矩形。
Shapes.Circle完美圆形。
Shapes.RoundedCorner(radius)圆角统一的矩形。传入 number 可使用相同半径,或传入对象 { topStart, topEnd, bottomStart, bottomEnd } 为各个角设置不同半径。
Shapes.CutCorner(radius)带切角(斜切角)的矩形。接受与 RoundedCorner 相同的半径选项。
Shapes.Material.Cookie4Sided有 4 条边的 Material Design 饼干形状。
Shapes.Material.Cookie6Sided有 6 条边的 Material Design 饼干形状。
import { clip } from '@expo/ui/jetpack-compose/modifiers'; import { Shapes } from '@expo/ui/jetpack-compose/modifiers'; // Circular clipping <Button modifiers={[clip(Shapes.Circle)]}>Circle</Button> // Rounded corners with uniform radius <Button modifiers={[clip(Shapes.RoundedCorner(12))]}>Rounded</Button> // Rounded corners with individual radii <Button modifiers={[ clip(Shapes.RoundedCorner({ topStart: 16, topEnd: 16, bottomStart: 0, bottomEnd: 0 })), ]}> Top rounded only </Button> // Cut corners <Button modifiers={[clip(Shapes.CutCorner(8))]}>Cut corners</Button>

实用工具

testID(tag)

为组件分配测试标识符,以便在 UI 测试中使用。

参数类型描述
tagstring测试 ID。
import { testID } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[testID('submit-button')]}>Submit</Button>;

API

import { paddingAll, padding, size, fillMaxWidth, background, clickable, clip, Shapes } from '@expo/ui/jetpack-compose/modifiers';

Constants

Shapes

Android

Type: { Circle: BuiltinShape, CutCorner: (params: number | CornerRadii) => BuiltinShape, Material: { Arch: BuiltinShape, Boom: BuiltinShape, Bun: BuiltinShape, Clover4Leaf: BuiltinShape, Clover8Leaf: BuiltinShape, Cookie12Sided: BuiltinShape, Cookie4Sided: BuiltinShape, Cookie6Sided: BuiltinShape, Cookie7Sided: BuiltinShape, Cookie9Sided: BuiltinShape, Diamond: BuiltinShape, Fan: BuiltinShape, Ghostish: BuiltinShape, Heart: BuiltinShape, Oval: BuiltinShape, Pentagon: BuiltinShape, Pill: BuiltinShape, PixelCircle: BuiltinShape, PixelTriangle: BuiltinShape, Puffy: BuiltinShape, PuffyDiamond: BuiltinShape, Slanted: BuiltinShape, SoftBurst: BuiltinShape, Sunny: BuiltinShape, Triangle: BuiltinShape, VerySunny: BuiltinShape }, Rectangle: BuiltinShape, RoundedCorner: (params: number | CornerRadii) => BuiltinShape }

Predefined shapes for use with the clip modifier.

Example

clip(Shapes.Circle) clip(Shapes.RoundedCorner(16)) clip(Shapes.RoundedCorner({ topStart: 8, bottomEnd: 16 })) clip(Shapes.Material.Heart)

Methods

align(alignment)

Android
ParameterType
alignmentAlignment

Aligns the view within its container.

Returns:
ModifierConfig

alpha(alpha)

Android
ParameterTypeDescription
alphanumber

Opacity value (0.0 to 1.0).


Sets the opacity/alpha of the view.

Returns:
ModifierConfig

animateContentSize(dampingRatio, stiffness)

Android
ParameterTypeDescription
dampingRatio(optional)number

Spring damping ratio. Default is DampingRatioNoBouncy.

stiffness(optional)number

Spring stiffness. Default is StiffnessMedium.


Animates size changes with spring animation.

Returns:
ModifierConfig

animated(targetValue, spec)

Android
ParameterType
targetValuenumber
spec(optional)AnimationSpec

Returns:
{ $animated: true, animationSpec: AnimationSpec, targetValue: number }

background(color, options)

Android
ParameterTypeDescription
colorColorValue

A color string (hex, e.g., '#FF0000').

options(optional){ animationSpec: AnimationSpec }
-

Sets the background color. Pass an animationSpec to smoothly animate between colors when the prop changes (backed by animateColorAsState).

Returns:
ModifierConfig

blur(radius)

Android
ParameterTypeDescription
radiusnumber

Blur radius in dp.


Applies a blur effect.

Returns:
ModifierConfig

border(borderWidth, borderColor)

Android
ParameterTypeDescription
borderWidthnumber

Border width in dp.

borderColorColorValue

Border color string (hex).


Adds a border around the view.

Returns:
ModifierConfig

clickable(handler, options)

Android
ParameterTypeDescription
handler() => void

Function to call when clicked.

options(optional){ indication: boolean }

Optional configuration.


Makes the view clickable.

Returns:
ModifierConfig

clip(shape)

Android
ParameterTypeDescription
shapeBuiltinShape

A shape from Shapes, e.g. Shapes.Circle or Shapes.Material.Heart.


Clips the view to a built-in Jetpack Compose shape.

Returns:
ModifierConfig

combinedClickable(handlers, options)

Android
ParameterTypeDescription
handlers{ onClick: () => void, onLongClick: () => void }
-
options(optional){ indication: boolean }

Optional configuration.


Makes the view respond to both click and long-click gestures. Wraps Compose's Modifier.combinedClickable. Useful for triggering a DropdownMenu on long-press while keeping a separate short-press action.

Returns:
ModifierConfig

createModifier(type, params)

Android
ParameterType
typestring
params(optional)Record<string, any>

Factory function to create modifier configuration objects.

Returns:
ModifierConfig

defaultMinSize(options)

Android
ParameterType
options{ minHeight: number, minWidth: number }

Constrain the size of the wrapped layout only when it would be otherwise unconstrained: the minWidth and minHeight constraints are only applied when the incoming corresponding constraint is 0.

Returns:
ModifierConfig

dropShadow(shape, config)

Android
ParameterTypeDescription
shapeBuiltinShape

The shape of the shadow, for example Shapes.RoundedCorner(16) or Shapes.Circle.

config(optional)ShadowConfig

Options that control the shadow's appearance.

Default:{}

Draws a shadow behind the view with control over the blur radius, spread, offset, and color. Unlike shadow, it does not require an elevation value.

Returns:
ModifierConfig

fillMaxHeight(fraction)

Android
ParameterTypeDescription
fraction(optional)number

Fraction of max height (0.0 to 1.0). Default is 1.0.


Fills the maximum available height.

Returns:
ModifierConfig

fillMaxSize(fraction)

Android
ParameterTypeDescription
fraction(optional)number

Fraction of max size (0.0 to 1.0). Default is 1.0.


Fills the maximum available size.

Returns:
ModifierConfig

fillMaxWidth(fraction)

Android
ParameterTypeDescription
fraction(optional)number

Fraction of max width (0.0 to 1.0). Default is 1.0.


Fills the maximum available width.

Returns:
ModifierConfig

graphicsLayer(params)

Android
ParameterTypeDescription
params{ alpha: number | { $animated: true, animationSpec: AnimationSpec, targetValue: number }, ambientShadowColor: ColorValue, cameraDistance: number, clip: boolean, compositingStrategy: 'auto' | 'offscreen' | 'modulate', rotationX: number | { $animated: true, animationSpec: AnimationSpec, targetValue: number }, rotationY: number | { $animated: true, animationSpec: AnimationSpec, targetValue: number }, rotationZ: number | { $animated: true, animationSpec: AnimationSpec, targetValue: number }, scaleX: number | { $animated: true, animationSpec: AnimationSpec, targetValue: number }, scaleY: number | { $animated: true, animationSpec: AnimationSpec, targetValue: number }, shadowElevation: number | { $animated: true, animationSpec: AnimationSpec, targetValue: number }, shape: BuiltinShape, spotShadowColor: ColorValue, transformOriginX: number, transformOriginY: number, translationX: number | { $animated: true, animationSpec: AnimationSpec, targetValue: number }, translationY: number | { $animated: true, animationSpec: AnimationSpec, targetValue: number } }

Transform and visual effect parameters.


Applies a graphics layer transformation with animation support.

Returns:
ModifierConfig

height(value)

Android
ParameterTypeDescription
valuenumber

Height in dp.


Sets the exact height of the view.

Returns:
ModifierConfig

horizontalScroll()

Android

Makes the view horizontally scrollable. Wraps Modifier.horizontalScroll(rememberScrollState()). Use on a Row to create a non-lazy scrollable container.

Returns:
ModifierConfig

imePadding()

Android

Adds padding to avoid the software keyboard (IME). When the keyboard is visible, padding is added to keep content above it.

Returns:
ModifierConfig

innerShadow(shape, config)

Android
ParameterTypeDescription
shapeBuiltinShape

The shape of the shadow, for example Shapes.RoundedCorner(16) or Shapes.Circle.

config(optional)ShadowConfig

Options that control the shadow's appearance.

Default:{}

Draws a shadow inside the view to create an inset effect. The view's background must come before this modifier for the shadow to render.

Returns:
ModifierConfig

keyframes(params)

Android
ParameterType
params{ delayMillis: number, durationMillis: number, keyframes: Record<number, number> }

Returns:
{ $type: 'keyframes', delayMillis: number, durationMillis: number, keyframes: Record<number, number> }

maskClip(shape)

Android
ParameterType
shapeBuiltinShape

Clips a carousel item's mask to the given shape, so the item keeps its shape while the carousel masks it. Wraps Compose's CarouselItemScope.maskClip.

A carousel reveals each item through a mask, so a plain clip on the item loses its corners as the item squeezes into a peek. Clipping the mask itself keeps them.

Only works on a child of a Carousel component. Like clip, it only affects what is drawn after it in the modifier chain, so place it before background.

Returns:
ModifierConfig

Example

modifiers={[size(300, 200), maskClip(Shapes.RoundedCorner(28)), background('#6200EE')]}

matchParentSize()

Android

Makes the view match the parent Box size. Only works when used inside Box.

Returns:
ModifierConfig
Android
ParameterTypeDescription
type(optional)'primaryNotEditable'

Anchor type. Currently only 'primaryNotEditable' is supported.

enabled(optional)boolean

Whether the anchor is enabled. Defaults to true.


Marks a composable as the anchor for an ExposedDropdownMenuBox. Only works when used inside ExposedDropdownMenuBox.

Returns:
ModifierConfig

offset(x, y)

Android
ParameterTypeDescription
xnumber

Horizontal offset in dp.

ynumber

Vertical offset in dp.


Offsets the view from its natural position.

Returns:
ModifierConfig

onGloballyPositioned(handler)

Android
ParameterTypeDescription
handler(layout: { height: number, width: number, x: number, y: number }) => void

Function called with the new layout.


Calls the handler whenever the composable is positioned, with its position and size. x and y are relative to the window. All values are in dp.

Returns:
ModifierConfig

onSizeChanged(handler)

Android
ParameterTypeDescription
handler(size: { height: number, width: number }) => void

Function called with the new size.


Calls the handler whenever the composable's measured size changes. Sizes are in dp.

Returns:
ModifierConfig

onVisibilityChanged(handler, options)

Android
ParameterTypeDescription
handler(isVisible: boolean) => void

Function called with true when visible, false when not.

options(optional){ minDurationMs: number, minFractionVisible: number }

Optional configuration.


Calls the handler when the composable's visibility changes (for example, enters or leaves the viewport in a lazy list).

Returns:
ModifierConfig

padding(start, top, end, bottom)

Android
ParameterTypeDescription
startnumber

Left padding in dp (or right in RTL).

topnumber

Top padding in dp.

endnumber

Right padding in dp (or left in RTL).

bottomnumber

Bottom padding in dp.


Applies padding with individual values for each side.

Returns:
ModifierConfig

paddingAll(all)

Android
ParameterTypeDescription
allnumber

Padding value in dp.


Applies equal padding on all sides.

Returns:
ModifierConfig

rotate(degrees)

Android
ParameterTypeDescription
degreesnumber

Rotation angle in degrees.


Rotates the view.

Returns:
ModifierConfig

selectable(selected, handler, role)

Android
ParameterTypeDescription
selectedboolean

Whether the item is currently selected.

handler() => void

Function to call when the item is clicked.

role(optional)'switch' | 'checkbox' | 'tab' | 'radioButton'

Optional semantic role for accessibility: 'radioButton', 'checkbox', 'switch', or 'tab'.


Makes the view selectable, like a radio button row.

Returns:
ModifierConfig

selectableGroup()

Android

Marks a column/row as a selectable group for accessibility. Screen readers will treat the children as a group of selectable items.

Returns:
ModifierConfig

semantics(params)

Android
ParameterType
params{ contentType: string }

Applies semantic properties. Wraps Modifier.semantics { ... }.

Returns:
ModifierConfig

shadow(elevation)

Android
ParameterTypeDescription
elevationnumber

Shadow elevation in dp.


Adds a shadow/elevation effect.

Returns:
ModifierConfig

size(width, height)

Android
ParameterTypeDescription
widthnumber

Width in dp.

heightnumber

Height in dp.


Sets exact width and height.

Returns:
ModifierConfig

snap(params)

Android
ParameterType
params(optional){ delayMillis: number }

Returns:
{ $type: 'snap', delayMillis: number }

spring(params)

Android
ParameterType
params(optional){ dampingRatio: number, stiffness: number, visibilityThreshold: number }

Returns:
{ $type: 'spring', dampingRatio: number, stiffness: number, visibilityThreshold: number }

testID(tag)

Android
ParameterTypeDescription
tagstring

Test ID string.


Sets the test ID for testing frameworks.

Returns:
ModifierConfig

toggleable(value, handler, options)

Android
ParameterTypeDescription
valueboolean

The current toggle state.

handler() => void

Function to call when toggled.

options(optional){ role: 'switch' | 'checkbox' | 'tab' | 'radioButton' }

Optional configuration.


Makes the view toggleable with accessibility semantics. Use this to make a row containing a checkbox or switch tappable as a whole.

Returns:
ModifierConfig

tween(params)

Android
ParameterType
params(optional){ delayMillis: number, durationMillis: number, easing: 'linear' | 'fastOutSlowIn' | 'fastOutLinearIn' | 'linearOutSlowIn' | 'ease' }

Returns:
{ $type: 'tween', delayMillis: number, durationMillis: number, easing: 'linear' | 'fastOutSlowIn' | 'fastOutLinearIn' | 'linearOutSlowIn' | 'ease' }

verticalScroll()

Android

Makes the view vertically scrollable. Wraps Modifier.verticalScroll(rememberScrollState()). Use on a Column to create a non-lazy scrollable container.

Returns:
ModifierConfig

weight(weight)

Android
ParameterTypeDescription
weightnumber

Weight value (relative to siblings).


Sets the weight for flexible sizing in Row or Column. Only works when used inside Row or Column.

Returns:
ModifierConfig

width(value)

Android
ParameterTypeDescription
valuenumber

Width in dp.


Sets the exact width of the view.

Returns:
ModifierConfig

wrapContentHeight(alignment)

Android
ParameterTypeDescription
alignment(optional)'top' | 'bottom' | 'centerVertically'

Optional vertical alignment ('top', 'centerVertically', 'bottom').


Wraps the height to the content size.

Returns:
ModifierConfig

wrapContentWidth(alignment)

Android
ParameterTypeDescription
alignment(optional)'start' | 'end' | 'centerHorizontally'

Optional horizontal alignment ('start', 'centerHorizontally', 'end').


Wraps the width to the content size.

Returns:
ModifierConfig

zIndex(index)

Android
ParameterTypeDescription
indexnumber

Z-index value.


Sets the z-index for layering.

Returns:
ModifierConfig

Event subscriptions

createModifierWithEventListener(type, eventListener, params)

Android
ParameterType
typestring
eventListener(args: any) => void
params(optional)Record<string, any>

Creates a modifier with an event listener.

Returns:
ModifierConfig

createViewModifierEventListener(modifiers)

Android
ParameterType
modifiersModifierConfig[]

Create an event listener for a view modifier.

Returns:
GlobalEvent

Interfaces

ModifierConfig

Android

Modifier configuration for native views. This is the JSON Config pattern used by both iOS (SwiftUI) and Android (Jetpack Compose).

PropertyTypeDescription
$scope(optional)string
-
$typestring
-

Types

Alignment

Android

Literal type: string

Acceptable values are: 'topStart' | 'topCenter' | 'topEnd' | 'centerStart' | 'center' | 'centerEnd' | 'bottomStart' | 'bottomCenter' | 'bottomEnd' | 'top' | 'centerVertically' | 'bottom' | 'start' | 'centerHorizontally' | 'end'

AnimatedValue

Android

Type: ReturnType<animated>

AnimationSpec

Android

Type: ReturnType<spring | tween | snap | keyframes>

BuiltinShape

Android

Built-in Jetpack Compose shape for the clip modifier.

Type: object shaped as below:

PropertyTypeDescription
type'rectangle'
-

Or object shaped as below:

PropertyTypeDescription
type'circle'
-

Or object shaped as below:

PropertyTypeDescription
bottomEnd(optional)number
-
bottomStart(optional)number
-
radius(optional)number
-
topEnd(optional)number
-
topStart(optional)number
-
type'roundedCorner'
-

Or object shaped as below:

PropertyTypeDescription
bottomEnd(optional)number
-
bottomStart(optional)number
-
radius(optional)number
-
topEnd(optional)number
-
topStart(optional)number
-
type'cutCorner'
-

Or object shaped as below:

PropertyTypeDescription
nameMaterialShapeName
-
type'material'
-

ExpoModifier

Android

Type: ModifierConfig

ShadowConfig

Android

Options for the dropShadow and innerShadow modifiers.

PropertyTypeDescription
alpha(optional)number

Shadow opacity, from 0.0 to 1.0.

color(optional)ColorValue

Shadow color string (hex). Defaults to black.

offsetX(optional)number

Horizontal offset of the shadow in dp.

offsetY(optional)number

Vertical offset of the shadow in dp.

radius(optional)number

Blur radius of the shadow in dp.

spread(optional)number

Amount to expand (positive) or contract (negative) the shadow geometry in dp.