# androidx.fragment.compose

Insert package level documentation here

## Classes

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/fragment/compose/FragmentState` | Holder for the fragment state. |

## Composables

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/fragment/compose/AndroidFragment.composable` | Allows for adding a `https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment` directly into Compose. |
| `https://developer.android.com/reference/kotlin/androidx/fragment/compose/rememberFragmentState.composable` | Creates a `https://developer.android.com/reference/kotlin/androidx/fragment/compose/FragmentState` used to store the state of a `https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment` that is created via `https://developer.android.com/reference/kotlin/androidx/fragment/compose/AndroidFragment.composable#AndroidFragment(androidx.compose.ui.Modifier,androidx.fragment.compose.FragmentState,android.os.Bundle,androidx.lifecycle.Lifecycle.State,kotlin.Function1)`. |

## Extension functions summary

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ComposeView` | `https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment.https://developer.android.com/reference/kotlin/androidx/fragment/compose/package-summary#(androidx.fragment.app.Fragment).content(kotlin.Function0)(content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Wrapper function that handles the setup for creating a custom Fragment that hosts Compose content. |

## Extension functions

### Fragment.content

Artifact: [androidx.fragment:fragment-compose](https://developer.android.com/jetpack/androidx/releases/fragment) [View Source](https://cs.android.com/search?q=file:androidx/fragment/compose/Fragment.kt+function:content) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.7.0)

```
fun Fragment.content(content: @Composable () -> Unit): ComposeView
```

Wrapper function that handles the setup for creating a custom Fragment that hosts Compose content. It automatically sets the `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy` to `https://developer.android.com/reference/kotlin/androidx/compose/ui/platform/ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed`.

It should be used as part of the implementation of `https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment#onCreateView(android.view.LayoutInflater,android.view.ViewGroup,android.os.Bundle)` and requires a context meaning the fragment must be attached to a FragmentManager.

```kotlin
class ExampleFragment : Fragment() {
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ) = content {
        val viewModel: ExampleViewModel = viewModel()
        // put your @Composable content here
    }
}
```