Style

open class Style(previousStyle: Style?, item: StyleItem<*>?)

An immutable ordered collection of attributes ( StyleItem s) that can be applied to a component, like width or click handling.

Adding new attributes to a Style (e.g. by calling .background) will return a new Style object. Ordering matters in that the last definition of an attribute 'wins'.

Styles can also be added via the + operator, with attributes from the right-hand side Style taking precedence if the two define different values for the same attribute, similar to adding maps.

Inheritors

Constructors

Link copied to clipboard
constructor(previousStyle: Style?, item: StyleItem<*>?)

Types

Link copied to clipboard
object Companion : Style

An empty Style singleton that can be used to build a chain of style items.

Functions

Link copied to clipboard
fun Style.accessibilityHeading(isAccessibilityHeading: Boolean): Style

Whether the view is a heading for a section of content for accessibility purposes.

Link copied to clipboard
fun Style.accessibilityRole(accessibilityRole: String?): Style

The Android Talkback "role" this component has. This will be read out when the view is visited in Talkback mode. See AccessibilityRoleType for possible roles.

Link copied to clipboard
fun Style.accessibilityRoleDescription(accessibilityRoleDescription: CharSequence?): Style

The description for this Component's accessibilityRole. This will be read out when the view is visited in Talkback mode.

Link copied to clipboard
fun Style.additionalOnClick(@IdRes key: Int, onClick: (ClickEvent) -> Unit): Style

Adds an additional click listener identified by key that fires alongside any primary handler installed via onClick or by the underlying component's CommonProps.clickHandler. Multiple additional listeners with distinct keys can coexist on the same view and all fire on click in insertion order.

Link copied to clipboard
inline fun Style.addSystemGestureExclusionZone(noinline exclusion: (bounds: Rect) -> Rect): Style

Excludes a rectangle within the local bounds from the system gesture. After layout, []exclusion] is called to determine the Rect to exclude from the system gesture area.

Link copied to clipboard
fun Style.alignSelf(align: YogaAlign): Style

Defines how a child should be aligned with a Row or Column, overriding the parent's align-items property for this child.

Link copied to clipboard

Sets the alpha of the View using a Value.

fun Style.alpha(alpha: Float): Style

Sets an alpha on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.androidStyle(@AttrRes defStyleAttr: Int = 0, @StyleRes defStyleRes: Int = 0): Style

Applies the default styled attributes from an Android style/theme resource to this component's common view and layout properties — the R.styleable.ComponentLayout set, e.g. background, foreground, padding, margin, minWidth/minHeight, contentDescription and importantForAccessibility. This is the Style equivalent of the legacy Spec builder's create(c, defStyleAttr, defStyleRes) overload.

Link copied to clipboard
fun Style.aspectRatio(aspectRatio: Float): Style

Defines an aspect ratio for this component, meaning the ratio of width to height. This means if aspectRatio is set to 2 and width is calculated to be 50px, then height will be 100px.

Link copied to clipboard
fun Style.background(background: DynamicValue<out Drawable>): Style

fun Style.background(background: Drawable?): Style

Sets a background on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.backgroundColor(@ColorInt backgroundColor: Long): Style

fun Style.backgroundColor(backgroundColor: Value<Color>): Style

Sets the background color of the View using a Value.

fun Style.backgroundColor(@ColorInt backgroundColor: Int): Style

Sets ColorDrawable of the given color as a background on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.blur(radiusX: Float, radiusY: Float, edgeTreatment: Shader.TileMode = Shader.TileMode.CLAMP): Style

Creates a Blur LithoRenderEffect with the specified radius along the x and y axis and applies it to the component.

Link copied to clipboard
fun Style.border(border: Border?): Style

Describes how a Border should be drawn around this component. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Applies a border using a DSL-style builder for complex configurations.

fun Style.border(width: Dimen, @ColorInt color: Int, radius: Dimen? = null, effect: BorderEffect? = null): Style

Applies a uniform border with the same width and color on all edges. This is a simplified API for the most common border use case.

Link copied to clipboard
fun Style.clickable(isClickable: Boolean): Style

Sets if the View this Component mounts to should be clickable. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.clip(outlineProvider: ViewOutlineProvider?): Style

Sets a ViewOutlineProvider on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

fun Style.clip(shape: Shape): Style

Clips the Component to the specified Shape. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.clipChildren(clipChildren: Boolean): Style

Setting this to false allows child views of this view to draw outside its bounds, overriding the default behavior. It only applies to direct children. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.clipToOutline(clipToOutline: Boolean): Style

Sets whether the View's Outline should be used to clip the contents of the View. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.componentTag(componentTag: Any?): Style

Sets a component-level tag on this Component, readable via com.facebook.litho.DebugComponent's componentTag / InspectableComponent.getComponentTag (test / inspection tooling). Unlike viewTag, this is not an Android View tag: it has no mount- or layout-time effect and does not force the Component to be represented as a View.

Link copied to clipboard
fun Style.containerTitle(containerTitle: CharSequence?): Style

Sets the container title for app-developer-defined container which can be any type of ViewGroup or layout. Container title will be used to group together related controls, similar to HTML fieldset.

Link copied to clipboard
fun Style.contentDescription(contentDescription: CharSequence?): Style

A description of the contents of this Component for accessibility.

Link copied to clipboard
fun Style.defaultFocusHighlightEnabled(defaultFocusHighlightEnabled: Boolean): Style

Sets whether this View should have a default focus highlight when it gets focus but doesn't have R.attr.state_focused defined in its background. Setting this property will cause the Component to be represented as a View at mount time if it wasn't already. Only effective on API 26+ (Android O); a no-op on older API levels.

Link copied to clipboard
fun Style.drawBehind(block: DrawScope.() -> Unit): Style
Link copied to clipboard
fun Style.duplicateChildrenStates(duplicateChildrenStates: Boolean): Style

Sets whether this ViewGroup's drawable states also include its children's drawable states. This is used, for example, to make a group appear to be focused when its child EditText or button is focused. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.duplicateParentState(duplicateParentState: Boolean): Style

Sets whether the View gets its drawable state (focused, pressed, etc.) from its direct parent rather than from itself. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

Sets the elevation of the View using a Value.

fun Style.elevation(elevation: Dimen): Style

Sets an elevation on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.enabled(isEnabled: Boolean): Style

Sets if the View this Component mounts to should be enabled. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
fun Style.flex(grow: Float? = null, shrink: Float? = null, basis: Dimen? = null, basisPercent: Float? = null): Style

Flex allows you to define how this component should take up space within its parent. It's comprised of the following properties:

Link copied to clipboard
fun Style.focusable(isFocusable: Boolean): Style

Setting this property will cause the Component to be focusable. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.focusOrder(focusOrderModel: FocusOrderModel): Style
Link copied to clipboard
open fun forEach(lambda: (StyleItem<*>) -> Unit)
Link copied to clipboard
fun Style.foreground(foreground: Drawable?): Style

Sets a foreground on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

fun Style.foregroundColor(@ColorInt foregroundColor: Int): Style

Sets ColorDrawable of the given color as a background on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Sets a specific preferred height for this component using a Value.

fun Style.height(height: Dimen): Style

Sets a specific preferred height for this component when its parent lays it out.

Link copied to clipboard

auto height

Link copied to clipboard
fun Style.heightIn(min: Dimen, max: Dimen): Style

Sets minimum and maximum height constraints.

Link copied to clipboard
fun Style.heightPercent(heightPercent: Float): Style

Sets a specific preferred percent height for this component when its parent lays it out.

Link copied to clipboard

Sets whether this Component is "important for accessibility". If it is, it fires accessibility events and is reported to accessibility services that query the screen. The value for this property can be one of the values in ImportantForAccessibility.

Link copied to clipboard
fun Style.isReferenceBaseline(isReferenceBaseline: Boolean): Style
Link copied to clipboard
fun Style.keyboardNavigationCluster(isKeyboardNavigationCluster: Boolean): Style

Setting this property will cause the Component to be a keyboard navigation cluster. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.labeledBy(viewTag: Any): Style

Sets the view which serves as the label of the view represented by this info for accessibility purposes.

Link copied to clipboard
fun Style.layerType(layerType: Int, paint: Paint? = null): Style
Link copied to clipboard
fun Style.layoutDirection(layoutDirection: YogaDirection): Style

Describes the RTL/LTR direction of component. Determines whether {@link YogaEdge#START} and {@link YogaEdge#END} will resolve to the left or right side, among other things. INHERIT indicates this setting will be inherited from this component's parent. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

Sets the live region mode for this view. This indicates to accessibility services whether they should automatically notify the user about changes to the view's content description or text, or to the content descriptions or text of the view's children (where applicable).

Link copied to clipboard
fun Style.margin(all: Dimen? = null, horizontal: Dimen? = null, vertical: Dimen? = null, start: Dimen? = null, top: Dimen? = null, end: Dimen? = null, bottom: Dimen? = null, left: Dimen? = null, right: Dimen? = null): Style

Defines margin around the component on a per-edge basis.

Link copied to clipboard
fun Style.marginAuto(edge: YogaEdge): Style

Sets margin value for specified edge to auto. The item will extend the margin for this edge to occupy the extra space in the parent, depending on the direction (Row or Column).

Link copied to clipboard
fun Style.marginPercent(all: Float? = null, horizontal: Float? = null, vertical: Float? = null, start: Float? = null, top: Float? = null, end: Float? = null, bottom: Float? = null, left: Float? = null, right: Float? = null): Style

Defines margin around the component on a per-edge basis, with a percent value of container's size. See https://www.yogalayout.dev/docs/styling/margin-padding-border for more information.

Link copied to clipboard
fun Style.maxHeight(maxHeight: Dimen): Style

Sets a preferred maximum height for this component when its parent lays it out.

Link copied to clipboard
fun Style.maxHeightPercent(maxHeightPercent: Float): Style

Sets a specific maximum percent height for this component when its parent lays it out.

Link copied to clipboard
fun Style.maxWidth(maxWidth: Dimen): Style

Sets a preferred maximum width for this component when its parent lays it out.

Link copied to clipboard
fun Style.maxWidthPercent(maxWidthPercent: Float): Style

Sets a specific maximum percent width for this component when its parent lays it out.

Link copied to clipboard

Sets the minimum time duration between two content change events, which is used in throttling content change events in accessibility services.

Link copied to clipboard
fun Style.minHeight(minHeight: Dimen): Style

Sets a preferred minimum height for this component when its parent lays it out.

Link copied to clipboard
fun Style.minHeightPercent(minHeightPercent: Float): Style

Sets a specific minimum percent height for this component when its parent lays it out.

Link copied to clipboard
fun Style.minWidth(minWidth: Dimen): Style

Sets a preferred minimum width for this component when its parent lays it out.

Link copied to clipboard
fun Style.minWidthPercent(minWidthPercent: Float): Style

Sets a specific minimum percent width for this component when its parent lays it out.

Link copied to clipboard
fun Style.onBind(func: BindFunc<Any>): Style

fun Style.onBind(vararg deps: Any?, func: BindFunc<Any>): Style

This Style adds a mount callbacks. The BindFunc is invoked when the Component is mounted, and it receives a BindScope and the content this Component rendered to which can be a View or Drawable. The BindFunc must return an UnbindFunc and it must undo any mutations made to the View in the BindFunc. This API can be used to create higher-order Styles.

Link copied to clipboard
fun Style.onBindHostView(func: BindFunc<View>): Style

fun Style.onBindHostView(vararg deps: Any?, func: BindFunc<View>): Style

Use this Style instead of onBind to force the binder to be applied on a wrapped HostView.

Link copied to clipboard
fun Style.onBindHostViewWithDescription(name: String, func: BindFunc<View>): Style

inline fun Style.onBindHostViewWithDescription(noinline description: () -> String, vararg deps: Any?, func: BindFunc<View>): Style

Use this Style instead of onBind to force the binder to be applied on a wrapped HostView.

Link copied to clipboard
fun Style.onBindView(func: BindFunc<View>): Style

fun Style.onBindView(vararg deps: Any?, func: BindFunc<View>): Style

Note: Please use onBindViewWithDescription instead.

Link copied to clipboard
fun Style.onBindViewWithDescription(name: String, func: BindFunc<View>): Style

inline fun Style.onBindViewWithDescription(noinline description: () -> String, vararg deps: Any?, func: BindFunc<View>): Style

Use this Style instead of onBind to force the binder to be applied on a View; for example if a binder needs to be set on a Row or Column component, or if the binder needs to set common view properties even for components that render a Drawable.

Link copied to clipboard
inline fun <T> Style.onBindViewWithValue(noinline name: () -> String, value: Value<T>, defaultValue: T, crossinline func: View.(T) -> Unit): Style

This Style adds a mount callback for state value.

Link copied to clipboard
fun Style.onBindWithDescription(name: String, func: BindFunc<Any>): Style

inline fun Style.onBindWithDescription(noinline description: () -> String, vararg deps: Any?, func: BindFunc<Any>): Style

This Style adds a mount callbacks. The BindFunc is invoked when the Component is mounted, and it receives a BindScope and the content this Component rendered to which can be a View or Drawable. The BindFunc must return an UnbindFunc and it must undo any mutations made to the View in the BindFunc. This API can be used to create higher-order Styles.

Link copied to clipboard
fun Style.onClick(action: (ClickEvent) -> Unit): Style

Sets a listener that will invoke the given lambda when this Component is clicked. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

fun Style.onClick(enabled: Boolean, action: (ClickEvent) -> Unit): Style

Sets a listener that will invoke the given lambda when this Component is clicked but only if enabled is true. If enabled, setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

Sets a listener that will invoke the given lambda when this Component's focus changes. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Sets a listener that will invoke the given lambda when this Component's focus changes but only if enabled is true. If enabled, setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.onFocusedVisible(visibleWidthRatio: Float = 0.0f, visibleHeightRatio: Float = 0.0f, callback: (FocusedVisibleEvent) -> Unit): Style

Registers a callback to be called when either the Component occupies at least half of the viewport, or, if the Component is smaller than half the viewport, when it is fully visible.

Link copied to clipboard
fun Style.onFullImpression(visibleWidthRatio: Float = 0.0f, visibleHeightRatio: Float = 0.0f, callback: (FullImpressionVisibleEvent) -> Unit): Style

Registers a callback to be called when all parts of a Component have been made visible at some point, termed a "full impression". A full impression is defined as:

Link copied to clipboard
inline fun Style.onHover(noinline handler: (View, MotionEvent) -> Boolean): Style

Sets a listener that will invoke the given lambda when this Component is hovered on. If the component does not render a view then the framework will render it inside a View.

Link copied to clipboard
inline fun Style.onInitializeAccessibilityEvent(noinline onInitializeAccessibilityEventHandler: (OnInitializeAccessibilityEventEvent) -> Unit): Style

Initializes an AccessibilityEvent with information about the the host View which dispatched the event.

Link copied to clipboard
inline fun Style.onInitializeAccessibilityNodeInfo(noinline onInitializeAccessibilityNodeInfoHandler: (OnInitializeAccessibilityNodeInfoEvent) -> Unit): Style

Initializes an AccessibilityNodeInfoCompat with information about the host view.

Link copied to clipboard

Sets a listener that will intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point. Implementations should return true if they intercepted the event and wish to receive subsequent events, and false otherwise. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Sets a listener that will intercept all touch screen motion events but only if enabled is true. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point. Implementations should return true if they intercepted the event and wish to receive subsequent events, and false otherwise. If enabled is true, setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.onInvisible(visibleWidthRatio: Float = 0.0f, visibleHeightRatio: Float = 0.0f, callback: (InvisibleEvent) -> Unit): Style

Registers a callback to be called when a Component becomes fully invisible (e.g. scrolled off or unmounted).

Link copied to clipboard
inline fun Style.onKeyEvent(noinline listener: (View, Int, KeyEvent) -> Boolean): Style

Sets a listener that will invoke the given lambda when key event is received by this Component. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

Sets a listener that will invoke the given lambda when this Component is long clicked. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

fun Style.onLongClick(enabled: Boolean, action: (LongClickEvent) -> Boolean): Style

Sets a listener that will invoke the given lambda when this Component is long clicked but only if enabled is true. If enabled, setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
inline fun Style.onPerformAccessibilityActionWithResult(noinline onPerformAccessibilityActionHandler: (PerformAccessibilityActionEvent) -> Boolean): Style

Called when performing the specified accessibility action on the view. Return true when the action was handled, or false otherwise.

Link copied to clipboard
inline fun Style.onPerformActionForVirtualViewWithResult(noinline onPerformActionForVirtualViewHandler: (PerformActionForVirtualViewEvent) -> Boolean): Style

Performs the specified accessibility action on a virtual view child of the host View. Return true when the action was handled, or false otherwise.

Link copied to clipboard
inline fun Style.onPopulateAccessibilityEvent(noinline onPopulateAccessibilityEventHandler: (OnPopulateAccessibilityEventEvent) -> Unit): Style

Gives a chance to the host View to populate the accessibility event with its text content.

Link copied to clipboard
inline fun Style.onPopulateAccessibilityNode(noinline onPopulateAccessibilityNodeHandler: (OnPopulateAccessibilityNodeEvent) -> Unit): Style

Gives a chance to the component to implement its own accessibility support.

inline fun Style.onRequestSendAccessibilityEventWithResult(noinline onRequestSendAccessibilityEventHandler: (OnRequestSendAccessibilityEventEvent) -> Boolean): Style

Called when a child of the host View requests sending an AccessibilityEvent. Return true to allow the event to propagate, or false to block it.

Link copied to clipboard
inline fun Style.onSendAccessibilityEvent(noinline onSendAccessibilityEventHandler: (SendAccessibilityEventEvent) -> Unit): Style

Called when Sends an accessibility event of the given type. If accessibility is not enabled this method has no effect.

Link copied to clipboard
inline fun Style.onSendAccessibilityEventUnchecked(noinline onSendAccessibilityEventUncheckedHandler: (SendAccessibilityEventUncheckedEvent) -> Unit): Style

Sends an accessibility event. This method behaves exactly as sendAccessibilityEvent() but takes as an argument an empty AccessibilityEvent and does not perform a check whether accessibility is enabled.

Link copied to clipboard
fun Style.onTouch(action: (TouchEvent) -> Boolean): Style

Sets a listener that will invoke the given lambda when this Component is touched. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

fun Style.onTouch(enabled: Boolean, action: (TouchEvent) -> Boolean): Style

Sets a listener that will invoke the given lambda when this Component is touched but only if enabled is true. If enabled, setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.onUnfocusedVisible(visibleWidthRatio: Float = 0.0f, visibleHeightRatio: Float = 0.0f, callback: (UnfocusedVisibleEvent) -> Unit): Style

Registers a callback to be called when the Component is no longer focused, i.e. it is not fully visible and does not occupy at least half the viewport.

Link copied to clipboard
inline fun Style.onVirtualViewKeyboardFocusChanged(noinline onVirtualViewKeyboardFocusChangedHandler: (VirtualViewKeyboardFocusChangedEvent) -> Unit): Style

Called when a virtual view child of the host View has changed keyboard focus and gives an opportunity to the parent (the host) to react (changing visual display, etc.)

Link copied to clipboard
fun Style.onVisibilityChanged(visibleWidthRatio: Float = 0.0f, visibleHeightRatio: Float = 0.0f, callback: (VisibilityChangedEvent) -> Unit): Style

Registers a callback to be called when the visible rect of a Component changes.

Link copied to clipboard
fun Style.onVisible(visibleWidthRatio: Float = 0.0f, visibleHeightRatio: Float = 0.0f, callback: (VisibleEvent) -> Unit): Style

Registers a callback to be called when a Component becomes visible on screen.

Link copied to clipboard
fun Style.onVisibleWithTag(visibleWidthRatio: Float = 0.0f, visibleHeightRatio: Float = 0.0f, tag: () -> String?, callback: (VisibleEvent) -> Unit): Style

Registers a callback to be called when a Component becomes visible on screen, with a tag for identification.

Link copied to clipboard

Returns this Style if it's not null, otherwise returns the default empty Style singleton.

Link copied to clipboard

Sets a ViewOutlineProvider on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.padding(all: Dimen? = null, horizontal: Dimen? = null, vertical: Dimen? = null, start: Dimen? = null, top: Dimen? = null, end: Dimen? = null, bottom: Dimen? = null, left: Dimen? = null, right: Dimen? = null): Style

Defines padding on the component on a per-edge basis.

Link copied to clipboard
fun Style.paddingPercent(all: Float? = null, horizontal: Float? = null, vertical: Float? = null, start: Float? = null, top: Float? = null, end: Float? = null, bottom: Float? = null, left: Float? = null, right: Float? = null): Style

Defines padding on the component on a per-edge basis, with a percent value of container's size. See https://www.yogalayout.dev/docs/styling/margin-padding-border for more information.

Link copied to clipboard
fun Style.paneTitle(accessibilityPaneTitle: CharSequence?): Style

Visually distinct portion of a window with window-like semantics are considered panes for accessibility purposes. One example is the content view of a large fragment that is replaced. In order for accessibility services to understand a pane's window-like behavior, panes should have descriptive titles. Views with pane titles produce AccessibilityEvent#TYPE_WINDOW_STATE_CHANGEDs when they appear, disappear, or change title.

Link copied to clipboard
fun Style.pivotPercent(@FloatRange(from = 0.0, to = 100.0) pivotXPercent: Float = 50.0f, @FloatRange(from = 0.0, to = 100.0) pivotYPercent: Float = 50.0f): Style

Sets the transform pivot of a View (used for scale and rotation transforms) to be centered at the given percentages of the View's width and height. The default pivot point is (50f, 50f).

Link copied to clipboard
operator fun plus(other: Style?): Style
operator fun plus(nextItem: StyleItem<*>?): Style
Link copied to clipboard
inline fun plusIf(condition: Boolean, styleProvider: () -> Style): Style

Appends styleProvider to the current style if condition is true.

Link copied to clipboard
inline fun <T> plusIfNotNull(value: T?, styleProvider: (T) -> Style): Style

Appends styleProvider to the current style if value is not null.

Link copied to clipboard
fun Style.position(all: Dimen? = null, horizontal: Dimen? = null, vertical: Dimen? = null, start: Dimen? = null, top: Dimen? = null, end: Dimen? = null, bottom: Dimen? = null, left: Dimen? = null, right: Dimen? = null): Style

Used in conjunction with positionType to define how a component should be positioned in its parent.

Link copied to clipboard
fun Style.positionPercent(all: Float? = null, horizontal: Float? = null, vertical: Float? = null, start: Float? = null, top: Float? = null, end: Float? = null, bottom: Float? = null, left: Float? = null, right: Float? = null): Style

Used in conjunction with positionType to define how a component should be positioned in its parent, with a float value between 0 and 100.

Link copied to clipboard
fun Style.positionType(positionType: YogaPositionType): Style

See docs in position.

Link copied to clipboard
fun Style.reportFirstContentDraw(isContentReady: Boolean = true, reporter: FirstDrawReporter): Style

Style prop that provides FirstDrawReporter to report the first draw after isContentReady is first set to true.

Link copied to clipboard

Sets the requested frame rate for the View this Component mounts to. Only effective on API 35+ (Android 15). On older API levels, this is a no-op.

Link copied to clipboard
fun Style.requestInitialAccessibilityFocus(requestInitialAccessibilityFocus: Boolean): Style

Sets whether the node has requested initial accessibility focus.

Link copied to clipboard

Sets the rotation of the View using a Value.

fun Style.rotation(rotation: Float): Style

Sets the degree that this component is rotated around the pivot point. Increasing the value results in clockwise rotation. By default, the pivot point is centered on the component. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

Sets the X-axis rotation of the View using a Value.

fun Style.rotationX(rotationX: Float): Style

Sets the degree that this component is rotated around the horizontal axis through the pivot point. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

Sets the Y-axis rotation of the View using a Value.

fun Style.rotationY(rotationY: Float): Style

Sets the degree that this component is rotated around the vertical axis through the pivot point. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

Sets the scale (scaleX and scaleY) of the View using a Value.

fun Style.scale(scale: Float): Style

Sets the scale (scaleX and scaleY) on this component. This is mostly relevant for animations and being able to animate size changes. Otherwise for non-animation usecases, you should use the standard layout properties to control the size of your component. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Sets whether this View should be a focusable element for screen readers

Link copied to clipboard
fun Style.selected(isSelected: Boolean): Style

Changes the selection state of this Component. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.shadow(elevation: Dimen, outlineProvider: ViewOutlineProvider = ViewOutlineProvider.BOUNDS, @ColorInt ambientShadowColor: Int = Color.BLACK, @ColorInt spotShadowColor: Int = Color.BLACK): Style

Style for attaching a standard Material Design shadow to a component. Refer to https://material.io/design/environment/light-shadows.html for more information.

Link copied to clipboard
fun Style.size(size: Dimen): Style

Sets both width and height to the same value.

Link copied to clipboard

Sets the state description of the component associated to this Style.

Link copied to clipboard

Attaches the provided StateListAnimator to this Component. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.testKey(testKey: String?): Style

Sets testKey on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.tooltipText(tooltipText: String?): Style

Sets the tooltip text which will be displayed in a small popup next to the view.

Link copied to clipboard
fun Style.touchExpansion(all: Dimen? = null, horizontal: Dimen? = null, vertical: Dimen? = null, start: Dimen? = null, top: Dimen? = null, end: Dimen? = null, bottom: Dimen? = null, left: Dimen? = null, right: Dimen? = null): Style

Defines touch Expansion area around the component on a per-edge basis.

Link copied to clipboard

Adds a diff-based transition to the host represented by this Style.

Link copied to clipboard
fun Style.transitionKey(context: ComponentContext, transitionKey: String?, transitionKeyType: Transition.TransitionKeyType = TransitionKeyType.LOCAL): Style

Sets transition key and Transition.TransitionKeyType on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.transitionName(transitionName: String?): Style

Sets Activity transition name on the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

Sets the X-axis translation of the View using a Value.

Link copied to clipboard

Sets the Y-axis translation of the View using a Value.

Link copied to clipboard
Link copied to clipboard
fun Style.useHeightAsBaseline(useHeightAsBaseline: Boolean): Style
Link copied to clipboard
fun <BindDataT : Any> Style.viewBinder(binder: RenderUnit.Binder<Unit, View, BindDataT>): Style

An overload of Style.viewBinder which takes a RenderUnit.Binder that does not require a model.

fun Style.viewBinder(binder: RenderUnit.DelegateBinder<*, View, Any>): Style

fun <ModelT, BindDataT : Any> Style.viewBinder(binder: RenderUnit.Binder<ModelT, View, BindDataT>, model: ModelT): Style

Creates a Style which will apply the given RenderUnit.Binder to the View rendered by the Component the Style is added to. This abstraction can be used to create higher-level Styles which can apply some property generically to any type of Component.

Link copied to clipboard
fun Style.viewId(@IdRes viewId: Int): Style

Adds a View tag to the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.viewTag(viewTag: Any?): Style

Adds a View tag to the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard
fun Style.viewTags(viewTags: SparseArray<out Any>): Style

Adds a set of View tags to the View this Component mounts to. Setting this property will cause the Component to be represented as a View at mount time if it wasn't going to already.

Link copied to clipboard

Sets the visibility of the View rendered by this Component using a DynamicValue. The value should be one of Visibility.Visible or Visibility.Invisible.

Defines the visibility of the Component. The value can be Visibility.Visible or Visibility.Invisible; the default is Visibility.Visible.

Link copied to clipboard

Sets a specific preferred width for this component using a Value.

fun Style.width(width: Dimen): Style

Sets a specific preferred width for this component when its parent lays it out.

Link copied to clipboard

auto width

Link copied to clipboard
fun Style.widthIn(min: Dimen, max: Dimen): Style

Sets minimum and maximum width constraints.

Link copied to clipboard
fun Style.widthPercent(widthPercent: Float): Style

Sets a specific preferred percent width for this component when its parent lays it out.

Link copied to clipboard

Specifies that this Component should be represented as a View when this hierarchy is mounted.