This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 57).
修饰符
用于 @expo/ui 组件的 Jetpack Compose 布局修饰符。
Jetpack Compose 修饰符允许你自定义 UI 组件的布局、外观和行为。修饰符相当于 Compose 中的样式属性——它们控制尺寸、内边距、背景、交互等等。
安装
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
用法
修饰符通过使用带有数组语法的 modifiers prop 应用于组件。你可以组合多个修饰符来创建复杂的样式和行为。修饰符会按照它们在数组中出现的顺序应用,这可能会影响最终结果(例如,先应用 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 }}> {/* 基本样式修饰符 */} <Button modifiers={[paddingAll(16), fillMaxWidth(), background('#FF6B6B')]}> 全宽带内边距按钮 </Button> {/* 带边框和阴影的复杂组合 */} <Button modifiers={[paddingAll(12), background('#4ECDC4'), border(2, '#2C3E50'), shadow(4)]}> 使用边框和阴影进行样式设置 </Button> </Host> ); }
内边距
控制组件内容周围的间距。
paddingAll(all)
在四边应用相等的内边距。
| 参数 | 类型 | 描述 |
|---|---|---|
all | number | 内边距值,单位为 dp。 |
import { paddingAll } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[paddingAll(16)]}>带内边距的按钮</Button>;
padding(start, top, end, bottom)
分别为每一边应用内边距。
| 参数 | 类型 | 描述 |
|---|---|---|
start | number | 左/起始内边距,单位为 dp。 |
top | number | 顶部内边距,单位为 dp。 |
end | number | 右/结束内边距,单位为 dp。 |
bottom | number | 底部内边距,单位为 dp。 |
import { padding } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[padding(16, 8, 16, 8)]}>自定义内边距</Button>;
尺寸
控制组件的尺寸。
size(width, height)
为组件设置精确尺寸。
| 参数 | 类型 | 描述 |
|---|---|---|
width | number | 宽度,单位为 dp。 |
height | number | 高度,单位为 dp。 |
import { size } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[size(200, 48)]}>固定尺寸</Button>;
fillMaxSize(fraction?)
在两个维度上填充所有可用空间。
| 参数 | 类型 | 描述 |
|---|---|---|
fraction | number | 可用空间所占比例(0.0–1.0)。默认值为 1.0。 |
import { fillMaxSize } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[fillMaxSize()]}>填充全部空间</Button> <Button modifiers={[fillMaxSize(0.5)]}>填充一半</Button>
fillMaxWidth(fraction?)
填充可用宽度。
| 参数 | 类型 | 描述 |
|---|---|---|
fraction | number | 可用宽度所占比例(0.0–1.0)。默认值为 1.0。 |
import { fillMaxWidth } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[fillMaxWidth()]}>全宽</Button>;
fillMaxHeight(fraction?)
填充可用高度。
| 参数 | 类型 | 描述 |
|---|---|---|
fraction | number | 可用高度所占比例(0.0–1.0)。默认值为 1.0。 |
width(value)
设置精确宽度。
| 参数 | 类型 | 描述 |
|---|---|---|
value | number | 宽度,单位为 dp。 |
height(value)
设置精确高度。
| 参数 | 类型 | 描述 |
|---|---|---|
value | number | 高度,单位为 dp。 |
wrapContentWidth(alignment?)
将组件尺寸调整为包裹其内容宽度。
| 参数 | 类型 | 描述 |
|---|---|---|
alignment | string | 内容的水平对齐方式。 |
wrapContentHeight(alignment?)
将组件尺寸调整为包裹其内容高度。
| 参数 | 类型 | 描述 |
|---|---|---|
alignment | string | 内容的垂直对齐方式。 |
位置
控制组件相对于其自然位置的位置。
offset(x, y)
在不影响周围组件布局的情况下,将组件相对于其自然位置偏移。
| 参数 | 类型 | 描述 |
|---|---|---|
x | number | 水平偏移,单位为 dp。 |
y | number | 垂直偏移,单位为 dp。 |
import { offset } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[offset(10, 5)]}>偏移按钮</Button>;
外观
控制组件的视觉外观。
background(color)
设置背景颜色。
| 参数 | 类型 | 描述 |
|---|---|---|
color | string | 背景颜色(十六进制字符串)。 |
import { background } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[background('#3498DB')]}>蓝色背景</Button>;
border(borderWidth, borderColor)
为组件添加边框。
| 参数 | 类型 | 描述 |
|---|---|---|
borderWidth | number | 边框宽度,单位为 dp。 |
borderColor | string | 边框颜色(十六进制字符串)。 |
import { border } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[border(2, '#E74C3C')]}>带边框的按钮</Button>;
shadow(elevation)
在组件下方添加一个海拔阴影。
| 参数 | 类型 | 描述 |
|---|---|---|
elevation | number | 阴影海拔高度,单位为 dp。 |
import { shadow } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[shadow(8)]}>有阴影的按钮</Button>;
dropShadow(shape, config?)
在组件后方绘制阴影,并可控制模糊半径、扩展量、偏移和颜色。与 shadow 不同,它不需要海拔值。
| 参数 | 类型 | 描述 |
|---|---|---|
shape | Shape | 阴影的形状(见下方形状表)。 |
config.radius | number | 模糊半径,单位为 dp。 |
config.spread | number | 扩展(正值)或收缩(负值)的量,单位为 dp。 |
config.color | string | 阴影颜色(十六进制字符串)。默认为黑色。 |
config.offsetX | number | 水平偏移,单位为 dp。 |
config.offsetY | number | 垂直偏移,单位为 dp。 |
config.alpha | number | 阴影不透明度(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,这样阴影才会渲染出来。
| 参数 | 类型 | 描述 |
|---|---|---|
shape | Shape | 阴影的形状(见下方形状表)。 |
config.radius | number | 模糊半径,单位为 dp。 |
config.spread | number | 扩展(正值)或收缩(负值)的量,单位为 dp。 |
config.color | string | 阴影颜色(十六进制字符串)。默认为黑色。 |
config.offsetX | number | 水平偏移,单位为 dp。 |
config.offsetY | number | 垂直偏移,单位为 dp。 |
config.alpha | number | 阴影不透明度(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)
控制组件的不透明度。
| 参数 | 类型 | 描述 |
|---|---|---|
alpha | number | 不透明度值(0.0–1.0)。 |
import { alpha } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[alpha(0.5)]}>半透明</Button>;
blur(radius)
为组件应用模糊效果。
| 参数 | 类型 | 描述 |
|---|---|---|
radius | number | 模糊半径,单位为 dp。 |
import { blur } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[blur(4)]}>模糊按钮</Button>;
阴影配方
常见的阴影样式通常是 dropShadow 和 innerShadow 修饰符的组合,而不是单独的 API。由于 modifiers prop 接受一个数组,因此你可以叠加并微调阴影修饰符来构建每种样式。
新野兽派阴影
新野兽派阴影是一种边缘硬朗、无模糊且边框较粗的投影。将 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)
旋转组件。
| 参数 | 类型 | 描述 |
|---|---|---|
degrees | number | 旋转角度,单位为度。 |
import { rotate } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[rotate(45)]}>已旋转</Button>;
zIndex(index)
控制重叠组件的绘制顺序。
| 参数 | 类型 | 描述 |
|---|---|---|
index | number | 层级索引。 |
import { zIndex } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[zIndex(10)]}>位于顶层</Button>;
动画
为组件内部的布局变化添加动画。
animateContentSize(dampingRatio?, stiffness?)
使用弹簧动画为组件内容尺寸变化添加动画。
| 参数 | 类型 | 描述 |
|---|---|---|
dampingRatio | number | 弹簧阻尼比。控制弹性。 |
stiffness | number | 弹簧刚度。控制动画速度。 |
import { animateContentSize } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[animateContentSize()]}>带动画的尺寸</Button> <Button modifiers={[animateContentSize(0.5, 200)]}>自定义弹簧</Button>
布局
控制组件在其父容器中的尺寸和位置。
weight(weight)
在 Row 或 Column 内为组件分配一个灵活的权重,在带权重的子项之间按比例分配可用空间。
| 参数 | 类型 | 描述 |
|---|---|---|
weight | number | 权重因子。 |
import { weight } from '@expo/ui/jetpack-compose/modifiers'; // 在 Row 中,第一个按钮占 2/3,第二个占 1/3 <Button modifiers={[weight(2)]}>更宽</Button> <Button modifiers={[weight(1)]}>更窄</Button>
align(alignment)
设置组件在其父容器中的对齐方式。
| 参数 | 类型 | 描述 |
|---|---|---|
alignment | string | 容器内的对齐方式。 |
matchParentSize()
将组件尺寸设置为与其父级 Box 的尺寸一致。与 fillMaxSize 不同,这不会影响父级的测量。
import { matchParentSize } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[matchParentSize()]}>匹配父容器</Button>;
交互
为组件添加用户交互处理器。
clickable(handler)
使组件响应点击事件。
| 参数 | 类型 | 描述 |
|---|---|---|
handler | () => void | 点击时调用的回调。 |
import { clickable } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[clickable(() => console.log('Clicked!'))]}>可点击</Button>;
combinedClickable(handlers, options?)
使组件同时响应短按和长按手势。封装了 Compose 的 Modifier.combinedClickable。适用于在长按时打开 DropdownMenu,同时在同一视图上保留单独的短按操作。
| 参数 | 类型 | 描述 |
|---|---|---|
handlers.onClick | () => void | 可选回调,在短按时触发。 |
handlers.onLongClick | () => void | 可选回调,在长按时触发。 |
options.indication | boolean | 是否显示波纹效果。默认值为 true。 |
import { combinedClickable } from '@expo/ui/jetpack-compose/modifiers'; <Text modifiers={[ combinedClickable({ onClick: () => console.log('Tapped'), onLongClick: () => setMenuExpanded(true), }), ]}> 长按我 </Text>;
selectable(selected, handler)
使组件可选择,类似于单选按钮。
| 参数 | 类型 | 描述 |
|---|---|---|
selected | boolean | 该组件当前是否被选中。 |
handler | () => void | 选择状态变化时调用的回调。 |
import { selectable } from '@expo/ui/jetpack-compose/modifiers'; <Button modifiers={[selectable(isSelected, () => setIsSelected(!isSelected))]}> 可选择选项 </Button>;
裁剪
将组件的内容裁剪为特定形状。
clip(shape)
将组件裁剪为给定形状。形状边界之外的内容不会被绘制。
| 参数 | 类型 | 描述 |
|---|---|---|
shape | Shape | 要裁剪到的形状。 |
可用形状
| 形状 | 描述 |
|---|---|
Shapes.Rectangle | 一个没有圆角的矩形。 |
Shapes.Circle | 一个完美的圆。 |
Shapes.RoundedCorner(radius) | 一个具有统一圆角的矩形。传入 number 表示所有圆角半径相同,或传入对象 { topStart, topEnd, bottomStart, bottomEnd } 为每个角分别设置圆角半径。 |
Shapes.CutCorner(radius) | 一个具有切角(倒角)的矩形。接受与 RoundedCorner 相同的半径选项。 |
Shapes.Material.Cookie4Sided | Material Design 的四边 cookie 形状。 |
Shapes.Material.Cookie6Sided | Material Design 的六边 cookie 形状。 |
import { clip } from '@expo/ui/jetpack-compose/modifiers'; import { Shapes } from '@expo/ui/jetpack-compose/modifiers'; // 圆形裁剪 <Button modifiers={[clip(Shapes.Circle)]}>圆形</Button> // 统一半径的圆角 <Button modifiers={[clip(Shapes.RoundedCorner(12))]}>圆角</Button> // 各角半径不同的圆角 <Button modifiers={[ clip(Shapes.RoundedCorner({ topStart: 16, topEnd: 16, bottomStart: 0, bottomEnd: 0 })), ]}> 仅顶部圆角 </Button> // 切角 <Button modifiers={[clip(Shapes.CutCorner(8))]}>切角</Button>
工具
testID(tag)
为组件分配一个测试标识符,用于 UI 测试。
| 参数 | 类型 | 描述 |
|---|---|---|
tag | string | 测试 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
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
| Parameter | Type | Description |
|---|---|---|
| alpha | number | Opacity value (0.0 to 1.0). |
Sets the opacity/alpha of the view.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| dampingRatio(optional) | number | Spring damping ratio. Default is |
| stiffness(optional) | number | Spring stiffness. Default is |
Animates size changes with spring animation.
ModifierConfig| Parameter | Type |
|---|---|
| targetValue | number |
| spec(optional) | AnimationSpec |
{
$animated: true,
animationSpec: AnimationSpec,
targetValue: number
}| Parameter | Type | Description |
|---|---|---|
| color | ColorValue | A color string (hex, e.g., |
| options(optional) | {
animationSpec: AnimationSpec
} | - |
Sets the background color.
Pass an animationSpec to smoothly animate between colors when the prop changes (backed by animateColorAsState).
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| radius | number | Blur radius in dp. |
Applies a blur effect.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| borderWidth | number | Border width in dp. |
| borderColor | ColorValue | Border color string (hex). |
Adds a border around the view.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| handler | () => void | Function to call when clicked. |
| options(optional) | {
indication: boolean
} | Optional configuration. |
Makes the view clickable.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| shape | BuiltinShape | A shape from |
Clips the view to a built-in Jetpack Compose shape.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| 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.
ModifierConfig| Parameter | Type |
|---|---|
| type | string |
| params(optional) | Record<string, any> |
Factory function to create modifier configuration objects.
ModifierConfig| Parameter | Type |
|---|---|
| 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.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| shape | BuiltinShape | The shape of the shadow, for example |
| 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.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| fraction(optional) | number | Fraction of max height (0.0 to 1.0). Default is 1.0. |
Fills the maximum available height.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| fraction(optional) | number | Fraction of max size (0.0 to 1.0). Default is 1.0. |
Fills the maximum available size.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| fraction(optional) | number | Fraction of max width (0.0 to 1.0). Default is 1.0. |
Fills the maximum available width.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| 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.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| value | number | Height in dp. |
Sets the exact height of the view.
ModifierConfigMakes the view horizontally scrollable.
Wraps Modifier.horizontalScroll(rememberScrollState()).
Use on a Row to create a non-lazy scrollable container.
ModifierConfigAdds padding to avoid the software keyboard (IME). When the keyboard is visible, padding is added to keep content above it.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| shape | BuiltinShape | The shape of the shadow, for example |
| 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.
ModifierConfig| Parameter | Type |
|---|---|
| params | {
delayMillis: number,
durationMillis: number,
keyframes: Record<number, number>
} |
{
$type: 'keyframes',
delayMillis: number,
durationMillis: number,
keyframes: Record<number, number>
}Makes the view match the parent Box size. Only works when used inside Box.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| type(optional) | 'primaryNotEditable' | Anchor type. Currently only |
| enabled(optional) | boolean | Whether the anchor is enabled. Defaults to |
Marks a composable as the anchor for an ExposedDropdownMenuBox.
Only works when used inside ExposedDropdownMenuBox.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| x | number | Horizontal offset in dp. |
| y | number | Vertical offset in dp. |
Offsets the view from its natural position.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| 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.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| 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.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| handler | (isVisible: boolean) => void | Function called with |
| 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).
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| start | number | Left padding in dp (or right in RTL). |
| top | number | Top padding in dp. |
| end | number | Right padding in dp (or left in RTL). |
| bottom | number | Bottom padding in dp. |
Applies padding with individual values for each side.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| all | number | Padding value in dp. |
Applies equal padding on all sides.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| degrees | number | Rotation angle in degrees. |
Rotates the view.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| selected | boolean | 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.
ModifierConfigMarks a column/row as a selectable group for accessibility. Screen readers will treat the children as a group of selectable items.
ModifierConfig| Parameter | Type |
|---|---|
| params | {
contentType: string
} |
Applies semantic properties. Wraps Modifier.semantics { ... }.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| elevation | number | Shadow elevation in dp. |
Adds a shadow/elevation effect.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| width | number | Width in dp. |
| height | number | Height in dp. |
Sets exact width and height.
ModifierConfig| Parameter | Type |
|---|---|
| params(optional) | {
delayMillis: number
} |
{
$type: 'snap',
delayMillis: number
}| Parameter | Type |
|---|---|
| params(optional) | {
dampingRatio: number,
stiffness: number,
visibilityThreshold: number
} |
{
$type: 'spring',
dampingRatio: number,
stiffness: number,
visibilityThreshold: number
}| Parameter | Type | Description |
|---|---|---|
| tag | string | Test ID string. |
Sets the test ID for testing frameworks.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| value | boolean | 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.
ModifierConfig| Parameter | Type |
|---|---|
| params(optional) | {
delayMillis: number,
durationMillis: number,
easing: 'linear' | 'ease' | 'fastOutSlowIn' | 'fastOutLinearIn' | 'linearOutSlowIn'
} |
{
$type: 'tween',
delayMillis: number,
durationMillis: number,
easing: 'linear' | 'ease' | 'fastOutSlowIn' | 'fastOutLinearIn' | 'linearOutSlowIn'
}Makes the view vertically scrollable.
Wraps Modifier.verticalScroll(rememberScrollState()).
Use on a Column to create a non-lazy scrollable container.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| weight | number | Weight value (relative to siblings). |
Sets the weight for flexible sizing in Row or Column. Only works when used inside Row or Column.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| value | number | Width in dp. |
Sets the exact width of the view.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| alignment(optional) | 'top' | 'bottom' | 'centerVertically' | Optional vertical alignment ('top', 'centerVertically', 'bottom'). |
Wraps the height to the content size.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| alignment(optional) | 'start' | 'end' | 'centerHorizontally' | Optional horizontal alignment ('start', 'centerHorizontally', 'end'). |
Wraps the width to the content size.
ModifierConfig| Parameter | Type | Description |
|---|---|---|
| index | number | Z-index value. |
Sets the z-index for layering.
ModifierConfigEvent subscriptions
| Parameter | Type |
|---|---|
| type | string |
| eventListener | (args: any) => void |
| params(optional) | Record<string, any> |
Creates a modifier with an event listener.
ModifierConfig| Parameter | Type |
|---|---|
| modifiers | ModifierConfig[] |
Create an event listener for a view modifier.
GlobalEventInterfaces
Modifier configuration for native views. This is the JSON Config pattern used by both iOS (SwiftUI) and Android (Jetpack Compose).
| Property | Type | Description |
|---|---|---|
| $scope(optional) | string | - |
| $type | string | - |
Types
Literal type: string
Acceptable values are: 'topStart' | 'topCenter' | 'topEnd' | 'centerStart' | 'center' | 'centerEnd' | 'bottomStart' | 'bottomCenter' | 'bottomEnd' | 'top' | 'centerVertically' | 'bottom' | 'start' | 'centerHorizontally' | 'end'
Built-in Jetpack Compose shape for the clip modifier.
Type: object shaped as below:
| Property | Type | Description |
|---|---|---|
| type | 'rectangle' | - |
Or object shaped as below:
| Property | Type | Description |
|---|---|---|
| type | 'circle' | - |
Or object shaped as below:
| Property | Type | Description |
|---|---|---|
| bottomEnd(optional) | number | - |
| bottomStart(optional) | number | - |
| radius(optional) | number | - |
| topEnd(optional) | number | - |
| topStart(optional) | number | - |
| type | 'roundedCorner' | - |
Or object shaped as below:
| Property | Type | Description |
|---|---|---|
| bottomEnd(optional) | number | - |
| bottomStart(optional) | number | - |
| radius(optional) | number | - |
| topEnd(optional) | number | - |
| topStart(optional) | number | - |
| type | 'cutCorner' | - |
Or object shaped as below:
| Property | Type | Description |
|---|---|---|
| name | MaterialShapeName | - |
| type | 'material' | - |
Deprecated: Use ModifierConfig instead. ExpoModifier (SharedRef pattern) has been replaced with JSON Config pattern for better DX and platform consistency.
Type: ModifierConfig
Options for the dropShadow and innerShadow modifiers.
| Property | Type | Description |
|---|---|---|
| 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. |