---
title: "semantics"
description: "Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc."
type: "function"
lastmod: "2026-07-19T07:47:45.715451Z"
---
## API Reference

### semantics

> Source set: Android

```kotlin
public fun SubspaceModifier.semantics(
    properties: (SubspaceSemanticsPropertyReceiver.() -> Unit)
): SubspaceModifier
```

Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc.

**Mental Model (Picture Frame vs. Canvas):** When building a combined UI in Compose for XR, think
of a Subspace node (such as `SpatialPanel`) as a "Picture Frame" existing in 3D space, and the
standard 2D Compose UI elements inside it as the "Canvas".
- Use [SubspaceModifier.semantics](/jetpack-compose/androidx.xr.compose/compose/functions/semantics) on the 3D container (the frame) to provide spatial properties (such as [testTag](/jetpack-compose/androidx.xr.compose/compose/functions/testTag) and [contentDescription](/jetpack-compose/androidx.xr.compose/compose/properties/contentDescription)) for 3D placement, anchoring, or testing.
- Use standard [androidx.compose.ui.semantics.semantics](/jetpack-compose/androidx.xr.compose/compose/functions/semantics) modifiers on the 2D Compose composables (the canvas) for fine-grained user interactions and TalkBack accessibility.

**Interop & Merging Guidance:** The 3D Subspace semantics tree and the 2D foundational semantics
tree operate as distinct hierarchies. Spatial containers do not support merging descendant
semantics (`mergeDescendants = true`).

#### Parameters

| | |
| --- | --- |
| properties | Builder block where the semantics properties are defined. |

### semantics

> **Deprecated** Replaced by semantics that takes SubspaceSemanticsPropertyReceiver

> Source set: Android

```kotlin
public fun SubspaceModifier.semantics(
    properties: (SemanticsPropertyReceiver.() -> Unit)
): SubspaceModifier
```

Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc.

#### Parameters

| | |
| --- | --- |
| properties | Builder block where the semantics properties are defined. |

## Code Examples
### SubspaceSemanticsModifierSample
```kotlin
public fun SubspaceSemanticsModifierSample() {
    @Composable
    fun AppContent() {
        // Mental Model: The "Picture Frame" (3D Container) vs. the "Canvas" (2D Content)
        Subspace {
            SpatialPanel(
                modifier =
                    SubspaceModifier.semantics {
                        // Set spatial semantics on the 3D container (the "Picture Frame")
                        testTag = "main_settings_panel"
                        contentDescription = "System Settings Window"
                    }
            ) {
                // Standard 2D Compose UI goes inside (the "Canvas").
                // These elements use standard Modifier.semantics for TalkBack and interactions.
                Column {
                    Text("System Settings")
                    Button(
                        onClick = { /* do something */ },
                        modifier = Modifier.semantics { contentDescription = "Perform action" },
                    ) {
                        Text("Click Me")
                    }
                }
            }
        }
    }
}
```
