Skip to content

Instantly share code, notes, and snippets.

@cmelchior
Created February 18, 2026 11:57
Show Gist options
  • Select an option

  • Save cmelchior/d1a44e08e1d821306fbd5e6b74f070ec to your computer and use it in GitHub Desktop.

Select an option

Save cmelchior/d1a44e08e1d821306fbd5e6b74f070ec to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"metadata": {
"collapsed": true
},
"source": [
"// Include Compose support\n",
"// The compose compiler plugin used must be provided by IntelliJ, similar to Serialization, DataFrames and others.\n",
"// This should also ensure that we get the correct platform API's.\n",
"%use compose"
],
"id": "adfd4294e6ed8d31",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"// Example 1: Define Composable functions and show them inline in the notebook\n",
"@Composable\n",
"fun simpleButton() {\n",
" Button(onClick = {}) {\n",
" Text(\"Hello Compose!\")\n",
" }\n",
"}\n",
"\n",
"// COMPOSE returns a `ComposePanel`\n",
"// It will be rendered as Cell output.\n",
"COMPOSE {\n",
" simpleButton()\n",
"}"
],
"id": "4612bac328609f87",
"outputs": [],
"execution_count": null
},
{
"metadata": {
"executionRelatedData": {
"compiledClasses": [
"Line_3_jupyter"
]
}
},
"cell_type": "code",
"source": [
"// Example 2: Call a Composable function from dependencies\n",
"import com.example.compose.composableFunctionFromDependencies\n",
"\n",
"COMPOSE {\n",
" composableFunctionFromDependencies()\n",
"}"
],
"id": "fc72798f17db68ba",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": "",
"id": "438e81928402ac90",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"// Example 3: Use other JVM API's to bridge into Compose\n",
"application(exitProcessOnExit = false) {\n",
" Window(onCloseRequest = ::exitApplication, title = \"Compose App\") {\n",
" AllColors()\n",
" }\n",
"}"
],
"id": "b21fad08bc82240c",
"outputs": [],
"execution_count": null
}
],
"metadata": {
"kernelspec": {
"display_name": "Kotlin",
"language": "kotlin",
"name": "kotlin"
},
"language_info": {
"name": "kotlin",
"version": "2.4.0-dev-2124",
"mimetype": "text/x-kotlin",
"file_extension": ".kt",
"pygments_lexer": "kotlin",
"codemirror_mode": "text/x-kotlin",
"nbconvert_exporter": ""
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment