docs/api/api-reference-elements.md
This document provides a comprehensive reference for all native template elements and their properties, methods, and types.
Note: Layout and positioning attributes are powered by Yoga (commit
0be0e9fc). See Style Attributes Reference for Yoga version details and flexbox behavior.
JSX Element: <layout>
Represents a node in the layout tree. Use a <layout> instead of <view> whenever possible, since these nodes will not be backed by a platform view when rendering, making them more performant.
onLayout: (frame: ElementFrame) => void
onVisibilityChanged: (isVisible: boolean, eventTime: EventTime) => void
onViewportChanged: (viewport: ElementFrame, frame: ElementFrame, eventTime: EventTime) => void
onLayoutComplete: () => void
onMeasure: OnMeasureFunc
(width: number, widthMode: MeasureMode, height: number, heightMode: MeasureMode) => MeasuredSizelazyLayout: boolean
falselimitToViewport: boolean
truelazy: boolean
falseestimatedWidth: number
estimatedHeight: number
id: string
key: string
ref: IRenderedElementHolder<this>
animationsEnabled: boolean
truezIndex: number
class: string
ignoreParentViewport: boolean
width: CSSValue (string | number)
auto (default): width for the element based on its content.height: CSSValue
auto (default): height for the element based on its content.minWidth: CSSValue
minHeight: CSSValue
maxWidth: CSSValue
maxHeight: CSSValue
aspectRatio: number
position: 'relative' | 'absolute'
relative (default): positioned according to the normal flow of the layout, then offset relative to that position based on the values of top, right, bottom, and left.absolute: doesn't take part in the normal layout flow. Position is determined based on the top, right, bottom, and left values.top: CSSValue
position to offset the element from its normal position or parent.right: CSSValue
position to offset the element from its normal position or parent.bottom: CSSValue
position to offset the element from its normal position or parent.left: CSSValue
position to offset the element from its normal position or parent.margin: string | number
marginTop: CSSValue
marginRight: CSSValue
marginBottom: CSSValue
marginLeft: CSSValue
padding: string | number
paddingTop: CSSValue
paddingRight: CSSValue
paddingBottom: CSSValue
paddingLeft: CSSValue
display: 'flex' | 'none'
flex: use flexbox layout systemnone: do not display this element'flex'overflow: 'visible' | 'scroll'
visible: overflowing children elements will stretch the parent containerscroll: the parent container's size will not be affected by the children element's bounds'visible''scroll'direction: 'inherit' | 'ltr' | 'rtl'
inherit (default): Use the parent's direction valueltr: Text and children laid out from left to rightrtl: Text and children laid out from right to left'inherit'flexDirection: 'column' | 'column-reverse' | 'row' | 'row-reverse'
column (default): Align children from top to bottomcolumn-reverse: Align children from bottom to toprow: Align children from left to rightrow-reverse: Align children from right to left'column'flexWrap: 'no-wrap' | 'wrap' | 'wrap-reverse'
wrap: items are wrapped into multiple lines along the main axis if neededwrap-reverse: same as wrap but the order of the lines is reversedjustifyContent: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'
flex-start (default): Align children to the start of the container's main axisflex-end: Align children to the endcenter: Align children in the centerspace-between: Evenly space children, distributing remaining space between themspace-around: Evenly space children, distributing remaining space around themspace-evenly: Evenly distributed with equal spacing'flex-start'alignContent: 'flex-start' | 'flex-end' | 'stretch' | 'center' | 'space-between' | 'space-around'
flexWrap.'flex-start'alignItems: 'stretch' | 'flex-start' | 'flex-end' | 'center' | 'baseline'
stretch (default): Stretch children to match the height of the container's cross axisflex-start: Align children to the start of the container's cross axisflex-end: Align children to the endcenter: Align children in the centerbaseline: Align children along a common baseline'stretch'alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'
alignItems for this specific child.flexGrow: number
0flexShrink: number
0flexBasis: CSSValue
extendViewportWithChildren: boolean
falseaccessibilityCategory: 'auto' | 'view' | 'text' | 'button' | 'image' | 'image-button' | 'input' | 'header' | 'link' | 'checkbox' | 'radio' | 'keyboard-key'
'auto'accessibilityNavigation: 'auto' | 'passthrough' | 'leaf' | 'cover' | 'group' | 'ignored'
auto: automatically chosen depending on the elementpassthrough: element is not focusable, but its children may be accessedleaf: element is fully focusable and interactive but none of its children are navigatablecover: element is first fully focusable and interactive and afterward its children can also be accessedgroup: element may be announced but not focused and its children may also be accessedignored: element and all its children will be ignored, unnavigatable and unfocusable'auto'accessibilityPriority: number | AccessibilityPriority
0accessibilityLabel: string
accessibilityHint: string
accessibilityValue: string
accessibilityStateDisabled: boolean
falseaccessibilityStateSelected: boolean
falseaccessibilityStateLiveRegion: boolean
falsestyle: IStyle<Layout>
Style<Layout>.JSX Element: <view>
iOS Native: SCValdiView
Android Native: com.snap.valdi.views.ValdiView
Represents a node in the layout tree backed by a native platform view. Use a <layout> instead of <view> whenever possible for better performance.
All properties from Layout, plus:
onViewCreate: () => void
onViewDestroy: () => void
onViewChange: (nativeView: NativeView | undefined) => void
IRenderedElement.getNativeNodeallowReuse: boolean
truebackground: string
"color1" to set a color."linear-gradient(color1, color2, color3...)" to set a gradient with evenly-spaced stops."linear-gradient(color1 stop1, color2 stop2, color3 stop3...)" to set a gradient with custom stops.backgroundColor: Color (string)
undefined sets a clear color.opacity: number
slowClipping: boolean
falseborder: string
borderWidth: CSSValue
0borderColor: Color
blackborderRadius: CSSValue
"5 10 0 20" (top/left/right/bottom)"10"0boxShadow: string
'{xOffset} {yOffset} {shadowOverflow} {color}'"0 2 10 rgba(0, 0, 0, 0.1)"touchEnabled: boolean
false to disable any user interactions on this view and its children.truehitTest: (event: TouchEvent) => boolean
onTouch: (event: TouchEvent) => void
onTouchStart: (event: TouchEvent) => void
onTouchEnd: (event: TouchEvent) => void
onTouchDelayDuration: number
onTapDisabled: boolean
true to disable tap completely.falseonTap: (event: TouchEvent) => void
onTapPredicate: (event: TouchEvent) => boolean
onTapDisabled if the decision can be made without TouchEvent data.onDoubleTapDisabled: boolean
true to disable double tap completely.falseonDoubleTap: (event: TouchEvent) => void
onDoubleTapPredicate: (event: TouchEvent) => boolean
longPressDuration: number
onLongPressDisabled: boolean
true to disable long press completely.falseonLongPress: (event: TouchEvent) => void
onLongPressPredicate: (event: TouchEvent) => boolean
onDragDisabled: boolean
true to disable drag completely.falseonDrag: (event: DragEvent) => void
onDragPredicate: (event: DragEvent) => boolean
onPinchDisabled: boolean
true to disable pinch completely.falseonPinch: (event: PinchEvent) => void
onPinchPredicate: (event: PinchEvent) => boolean
onRotateDisabled: boolean
true to disable rotate completely.falseonRotate: (event: RotateEvent) => void
onRotatePredicate: (event: RotateEvent) => boolean
touchAreaExtension: number
touchAreaExtensionTop: number
touchAreaExtensionRight: number
touchAreaExtensionBottom: number
touchAreaExtensionLeft: number
scaleX: number
scaleY: number
rotation: number
translationX: number
translationY: number
maskOpacity: number
1maskPath: GeometricPath
accessibilityId: string
canAlwaysScrollHorizontal: boolean
canAlwaysScrollVertical: boolean
filterTouchesWhenObscured: boolean
style: IStyle<View | Layout>
Style<View>.JSX Element: <scroll>
iOS Native: SCValdiScrollView
Android Native: com.snap.valdi.views.ValdiScrollView
A view that provides scrolling functionality for its children.
All properties from View, except flexDirection (which is replaced by horizontal), plus:
onScroll: (event: ScrollEvent) => void
onScrollEnd: (event: ScrollEndEvent) => void
onDragStart: (event: ScrollEvent) => void
onDragEnding: (event: ScrollDragEndingEvent) => ScrollOffset | undefined
onDragEnd: (event: ScrollDragEndEvent) => void
onContentSizeChange: (event: ContentSizeChangeEvent) => void
horizontal: boolean
falseflexDirection: never
scrollEnabled: boolean
truepagingEnabled: boolean
falsebounces: boolean
truebouncesFromDragAtStart: boolean
truebouncesFromDragAtEnd: boolean
truebouncesVerticalWithSmallContent: boolean
falsebouncesHorizontalWithSmallContent: boolean
falsecancelsTouchesOnScroll: boolean
truedismissKeyboardOnDrag: boolean
falsedismissKeyboardOnDragMode: 'immediate' | 'touch-exit-below'
true, this changes the behavior of when the keyboard is dismissed.immediate: keyboard is dismissed as soon as scrolling beginstouch-exit-below: keyboard is dismissed when the scroll drag gesture touches leave the lower boundary of the scroll bounds'immediate'showsVerticalScrollIndicator: boolean
trueshowsHorizontalScrollIndicator: boolean
truefadingEdgeLength: number
0viewportExtensionTop: number
0viewportExtensionRight: number
0viewportExtensionBottom: number
0viewportExtensionLeft: number
0circularRatio: number
circularRatio should be set to 2.0 (scroll is not circular)decelerationRate: 'normal' | 'fast'
'normal'scrollPerfLoggerBridge: IScrollPerfLoggerBridge
AttributedCallsite.forScrollPerfLoggingThese properties should not be used in TSX tags, only for programmatic attribute manipulation:
contentOffsetX: number
contentOffsetY: number
contentOffsetAnimated: boolean
staticContentWidth: number
staticContentHeight: number
style: IStyle<ScrollView | View | Layout>
Style<ScrollView>.JSX Element: <image>
iOS Native: SCValdiImageView
Android Native: com.snap.valdi.views.ValdiImageView
A view for displaying images from local assets or remote URLs.
All properties from Layout Attributes, plus:
src: string | Asset
undefinedobjectFit: 'fill' | 'contain' | 'cover' | 'none'
fill: stretch the image to fill the image view's boundscontain: conserve aspect ratio and scale to fit within bounds (can leave blank space)cover: conserve aspect ratio and scale to fill bounds (can crop parts of the image)none: conserve aspect ratio and don't scale to fit (just rendered in center)'fill'tint: Color
undefinedflipOnRtl: boolean
falsecontentScaleX: number
1contentScaleY: number
1contentRotation: number
0filter: ImageFilter
onAssetLoad: (success: boolean, errorMessage?: string) => void
onImageDecoded: (width: number, height: number) => void
All view properties from View including:
onViewCreate, onViewDestroy)backgroundColor, opacity, border, etc.)style: IStyle<ImageView | View | Layout>
Style<ImageView>.JSX Element: <video>
iOS Native: SCValdiVideoView
Android Native: com.snap.valdi.views.ValdiVideoView
A view for displaying and controlling video playback.
All properties from Layout Attributes, plus:
src: string | Asset
undefinedvolume: number
playbackRate: number
0 is paused1 is playingseekToTime: number
onVideoLoaded: (duration: number) => void
onBeginPlaying: () => void
onError: (error: string) => void
onCompleted: () => void
onProgressUpdated: (time: number, duration: number) => void
time is in millisecondsduration is in millisecondsAll view properties from View.
style: IStyle<VideoView | View | Layout>
Style<VideoView>.JSX Element: <label>
iOS Native: SCValdiLabel
Android Native: android.widget.TextView
A view for displaying text.
All properties from Layout Attributes, plus:
value: string | AttributedText
AttributedTextBuilder class to set a value composed of multiple strings with different text attributes.font: string
'AvenirNext-Bold 16 unscaled 16''system 12'color: Color
blacktextGradient: string
"linear-gradient(color1, color2, color3...)" for evenly-spaced stops."linear-gradient(color1 stop1, color2 stop2, color3 stop3...)" for custom stops.textShadow: string
'{color} {radius} {opacity} {offsetX} {offsetY}''rgba(0, 0, 0, 0.1) 1 1 1 1'numberOfLines: number
1textAlign: 'left' | 'right' | 'center' | 'justified'
'left'textDecoration: 'none' | 'strikethrough' | 'underline'
undefinedlineHeight: number
1letterSpacing: number
0textOverflow: 'ellipsis' | 'clip'
'ellipsis'adjustsFontSizeToFitWidth: boolean
true, and the text exceeds the label's bounding rectangle, the label reduces the font size until the text fits or it has scaled down to the minimum font size.true, be sure to also set an appropriate minimum font scale with minimumScaleFactor.falseminimumScaleFactor: number
adjustsFontSizeToFitWidth is true, use this property to specify the smallest multiplier for the current font size that yields an acceptable font size for the label's text.0All view properties from View.
style: IStyle<Label | View | Layout>
Style<Label>.JSX Element: <textfield>
iOS Native: SCValdiTextField
Android Native: com.snap.valdi.views.ValditText
A single-line text input field.
All properties from Layout Attributes, plus:
All text properties from Label including value, font, color, textGradient, textShadow.
placeholder: string
placeholderColor: Color
tintColor: Color
textAlign: 'left' | 'center' | 'right'
'left'enabled: boolean
truecontentType: 'default' | 'phoneNumber' | 'email' | 'password' | 'url' | 'number' | 'numberDecimal' | 'numberDecimalSigned' | 'passwordNumber' | 'passwordVisible' | 'noSuggestions'
'default'returnKeyText: 'done' | 'go' | 'join' | 'next' | 'search' | 'send' | 'continue'
'done'autocapitalization: 'sentences' | 'words' | 'characters' | 'none'
'sentences'autocorrection: 'default' | 'none'
'default'keyboardAppearance: 'default' | 'dark' | 'light'
enableInlinePredictions: boolean
falsecharacterLimit: number
undefinedselectTextOnFocus: boolean
falseclosesWhenReturnKeyPressed: boolean
truefalseselection: [number, number]
onChange: (event: EditTextEvent) => void
onWillChange: (event: EditTextEvent) => EditTextEvent | undefined
onEditBegin: (event: EditTextBeginEvent) => void
onEditEnd: (event: EditTextEndEvent) => void
onReturn: (event: EditTextEvent) => void
onWillDelete: (event: EditTextEvent) => void
onSelectionChange: (event: EditTextEvent) => void
focused: boolean
All view properties from View.
style: IStyle<TextField | View | Layout>
Style<TextField>.JSX Element: <textview>
iOS Native: SCValdiTextView
Android Native: com.snap.valdi.views.ValditTextMultiline
A multi-line text input field.
All properties from TextField, except returnKeyText is replaced with returnType, plus:
returnType: 'linereturn' | 'done' | 'go' | 'join' | 'next' | 'search' | 'send' | 'continue'
linereturn will let users add line returns, but any other value will be constrained to single line text.closesWhenReturnKeyPressed.'linereturn'textGravity: 'top' | 'center' | 'bottom'
'center'backgroundEffectColor: Color
clearbackgroundEffectBorderRadius: number
0backgroundEffectPadding: number
0focused: boolean
style: IStyle<TextView | View | Layout>
Style<TextView>.JSX Element: <blur>
iOS Native: SCValdiBlurView
Android Native: com.snap.valdi.views.ValdiView
A view that applies a blur effect to content behind it.
All properties from Layout Attributes and View Attributes (appearance and gestures), plus:
blurStyle: BlurStyle
'light''dark''extraLight''regular''prominent''systemUltraThinMaterial''systemThinMaterial''systemMaterial''systemThickMaterial''systemChromeMaterial''systemUltraThinMaterialLight''systemThinMaterialLight''systemMaterialLight''systemThickMaterialLight''systemChromeMaterialLight''systemUltraThinMaterialDark''systemThinMaterialDark''systemMaterialDark''systemThickMaterialDark''systemChromeMaterialDark'BlurView extends ContainerTemplateElement, so it can have children.
style: IStyle<BlurView | View | Layout>
Style<BlurView>.JSX Element: <spinner>
iOS Native: SCValdiSpinnerView
Android Native: com.snap.valdi.views.ValdiSpinnerView
A view that displays a loading spinner.
All properties from Layout Attributes and View, plus:
color: Color
style: IStyle<SpinnerView | View | Layout>
Style<SpinnerView>.JSX Element: <shape>
iOS Native: SCValdiShapeView
Android Native: com.snap.valdi.views.ShapeView
A view for drawing custom shapes using geometric paths.
All properties from Layout Attributes and View, plus:
path: GeometricPath
strokeWidth: number
strokeColor: Color
strokeCap: 'butt' | 'round' | 'square'
strokeJoin: 'bevel' | 'miter' | 'round'
strokeStart: number
strokeEnd: number
fillColor: Color
style: IStyle<ShapeView | View | Layout>
Style<ShapeView>.JSX Element: <animatedimage>
iOS Native: SCValdiAnimatedContentView
Android Native: com.snap.valdi.views.AnimatedImageView
A view for displaying animated images including Lottie animations, animated WebP, and other formats.
All properties from Layout Attributes and View, plus:
src: string | Asset
undefined (nothing rendered by default)loop: boolean
advanceRate: number
0 is paused1 means the animation runs at normal speed0.5 at half speed-1 the animation will run in reverse0currentTime: number
animationStartTime: number
0animationEndTime: number
objectFit: 'fill' | 'contain' | 'cover' | 'none'
fill: stretch the image to fill the view's boundscontain: conserve aspect ratio and scale to fit within bounds (can leave blank space)cover: conserve aspect ratio and scale to fill bounds (can crop parts)none: conserve aspect ratio and don't scale to fit (just rendered in center)'contain'fontProvider: IFontProvider
onAssetLoad: (success: boolean, errorMessage?: string) => void
onImageDecoded: (width: number, height: number) => void
onProgress: (event: AnimatedImageOnProgressEvent) => void
time: number (current time in seconds)duration: number (duration of the animation in seconds)style: IStyle<AnimatedImage | View | Layout>
Style<AnimatedImage>.JSX Element: <slot>
Slots are used for content projection, allowing a component to define placeholders that can be filled with content.
key: string
name: string
ref: IRenderedElementHolder<unknown>
Interface for text editing events.
interface EditTextEvent {
text: string;
selectionStart: number;
selectionEnd: number;
}
Extends EditTextEvent with no additional properties.
interface EditTextEndEvent extends EditTextEvent {
reason: EditTextUnfocusReason;
}
enum EditTextUnfocusReason {
Unknown = 0,
ReturnKeyPress = 1,
DismissKeyPress = 2,
}
enum MeasureMode {
Unspecified = 0,
Exactly = 1,
AtMost = 2,
}
type MeasuredSize = [number, number];
type OnMeasureFunc = (
width: number,
widthMode: MeasureMode,
height: number,
heightMode: MeasureMode,
) => MeasuredSize;
type CSSValue = string | number;
type Color = string;
type LabelValue = string | AttributedText;
type GestureHandler<Event> = (event: Event) => void;
type GesturePredicate<Event> = (event: Event) => boolean;
type ImageOnAssetLoadCallback = (success: boolean, errorMessage?: string) => void;
type ImageOnImageDecodedCallback = (width: number, height: number) => void;
type AnimatedImageOnProgressCallback = (event: AnimatedImageOnProgressEvent) => void;
type LayoutAccessibilityCategory =
| 'auto'
| 'view'
| 'text'
| 'button'
| 'image'
| 'image-button'
| 'input'
| 'header'
| 'link'
| 'checkbox'
| 'radio'
| 'keyboard-key';
type LayoutAccessibilityNavigation =
| 'auto'
| 'passthrough'
| 'leaf'
| 'cover'
| 'group'
| 'ignored';
type LabelTextDecoration = 'none' | 'strikethrough' | 'underline';
type LabelTextAlign = 'left' | 'right' | 'center' | 'justified';
type LabelFontWeight = 'light' | 'normal' | 'medium' | 'demi-bold' | 'bold' | 'black';
type LabelFontStyle = 'normal' | 'italic';
type ImageObjectFit = 'fill' | 'contain' | 'cover' | 'none';
type TextFieldAutocapitalization = 'sentences' | 'words' | 'characters' | 'none';
type TextFieldAutocorrection = 'default' | 'none';
type TextFieldTextAlign = 'left' | 'center' | 'right';
type TextFieldReturnKeyText = 'done' | 'go' | 'join' | 'next' | 'search' | 'send' | 'continue';
type TextFieldKeyboardAppearance = 'default' | 'dark' | 'light';
type TextFieldContentType =
| 'default'
| 'phoneNumber'
| 'email'
| 'password'
| 'url'
| 'number'
| 'numberDecimal'
| 'numberDecimalSigned'
| 'passwordNumber'
| 'passwordVisible'
| 'noSuggestions';
type TextViewReturnType = 'linereturn' | TextFieldReturnKeyText;
type TextViewTextGravity = 'top' | 'center' | 'bottom';
type ShapeStrokeCap = 'butt' | 'round' | 'square';
type ShapeStrokeJoin = 'bevel' | 'miter' | 'round';
type BlurStyle =
| 'light'
| 'dark'
| 'extraLight'
| 'regular'
| 'prominent'
| 'systemUltraThinMaterial'
| 'systemThinMaterial'
| 'systemMaterial'
| 'systemThickMaterial'
| 'systemChromeMaterial'
| 'systemUltraThinMaterialLight'
| 'systemThinMaterialLight'
| 'systemMaterialLight'
| 'systemThickMaterialLight'
| 'systemChromeMaterialLight'
| 'systemUltraThinMaterialDark'
| 'systemThinMaterialDark'
| 'systemMaterialDark'
| 'systemThickMaterialDark'
| 'systemChromeMaterialDark';
<layout width="100%" height={200} padding={10} flexDirection="row">
<view backgroundColor="red" flex={1} margin={5} />
<view backgroundColor="blue" flex={1} margin={5} />
</layout>
<scroll height={300} width="100%" horizontal={false}>
<layout padding={10}>
<image src={res.myImage} width={200} height={200} margin={10} />
<label value="My Image" textAlign="center" />
</layout>
</scroll>
<textfield
value={this.state.text}
placeholder="Enter your name"
placeholderColor="#888"
contentType="default"
returnKeyText="done"
onChange={(event) => {
this.setState({ text: event.text });
}}
onEditEnd={(event) => {
console.log('Editing ended:', event.text);
}}
/>
<shape
path={myGeometricPath}
strokeWidth={2}
strokeColor="blue"
fillColor="lightblue"
strokeCap="round"
strokeJoin="round"
width={100}
height={100}
/>
<animatedimage
src={res.myLottieAnimation}
loop={true}
advanceRate={1}
width={200}
height={200}
objectFit="contain"
onProgress={(event) => {
console.log(`Progress: ${event.time}/${event.duration}`);
}}
/>