blob: 33bd379d3bfc65fff41fbace68ab120997283c03 [file] [log] [blame]
<html devsite="true">
<head>
<title>Composable</title>
{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %}
{% include "_shared/_reference-head-tags.html" %}
</head>
<body>
<div id="metadata-info-block"></div>
<h1>Composable</h1>
<p>
<pre>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-must-be-documented/index.html">MustBeDocumented</a><br>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-retention/index.html">Retention</a>(value&nbsp;=&nbsp;AnnotationRetention.BINARY)<br>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-target/index.html">Target</a>(allowedTargets&nbsp;=&nbsp;[AnnotationTarget.FUNCTION,&nbsp;AnnotationTarget.TYPE,&nbsp;AnnotationTarget.TYPE_PARAMETER,&nbsp;AnnotationTarget.PROPERTY_GETTER])<br>annotation <a href="/reference/kotlin/androidx/compose/runtime/Composable.html">Composable</a></pre>
</p>
<hr>
<p><code><a href="/reference/kotlin/androidx/compose/runtime/Composable.html">Composable</a></code> functions are the fundamental building blocks of an application built with Compose.</p>
<p><code><a href="/reference/kotlin/androidx/compose/runtime/Composable.html">Composable</a></code> can be applied to a function or lambda to indicate that the function/lambda can be used as part of a composition to describe a transformation from application data into a tree or hierarchy.</p>
<p>Annotating a function or expression with <code><a href="/reference/kotlin/androidx/compose/runtime/Composable.html">Composable</a></code> changes the type of that function or expression. For example, <code><a href="/reference/kotlin/androidx/compose/runtime/Composable.html">Composable</a></code> functions can only ever be called from within another <code><a href="/reference/kotlin/androidx/compose/runtime/Composable.html">Composable</a></code> function. A useful mental model for <code><a href="/reference/kotlin/androidx/compose/runtime/Composable.html">Composable</a></code> functions is that an implicit &quot;composable context&quot; is passed into a <code><a href="/reference/kotlin/androidx/compose/runtime/Composable.html">Composable</a></code> function, and is done so implicitly when it is called from within another <code><a href="/reference/kotlin/androidx/compose/runtime/Composable.html">Composable</a></code> function. This &quot;context&quot; can be used to store information from previous executions of the function that happened at the same logical point of the tree.</p>
<h2>Summary</h2>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="100%"><h3>Public constructors</h3></th>
</tr>
</thead>
<tbody class="list">
<tr>
<td>
<div><code><a href="/reference/kotlin/androidx/compose/runtime/Composable.html#Composable()">Composable</a>()</code></div>
</td>
</tr>
</tbody>
</table>
</div>
<h2>Public constructors</h2>
<div><a name="Composable--"></a><a name="composable"></a>
<h3 class="api-name" id="Composable()">Composable</h3>
<pre class="api-signature no-pretty-print"><a href="/reference/kotlin/androidx/compose/runtime/Composable.html#Composable()">Composable</a>()</pre>
</div>
</body>
</html>