https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
compose-web
  • l

    Lucas

    06/21/2022, 2:33 PM
    How can i load a custom font?
    b
    • 2
    • 12
  • b

    Big Chungus

    06/22/2022, 2:40 PM
    Any ETAs around for 1.7.0 CfW support?
    👀 1
    h
    • 2
    • 6
  • s

    Sebastien Leclerc Lavallee

    06/23/2022, 7:09 PM
    Hello! Quick question… I’m building a webapp using compose web and I wanted to know if there is a tool of command line argument to help diagnose why the website was completely reloaded? Why a component is redrawn? Thanks 🙂
    m
    d
    • 3
    • 4
  • s

    Scott Kruse

    06/27/2022, 5:06 PM
    Is the plan for compose 1.2 RC to have stable canvas based multiplatform (iOS, Android, Web, Desktop) components? Haven't pulled the 1.2 alphas in a couple months but last time i checked saw onWasmReady, etc. How close are we thinking we are to beta?
    ➕ 8
    s
    m
    +8
    • 11
    • 35
  • c

    CLOVIS

    06/27/2022, 8:37 PM
    Is there a Compose Web version for Kotlin 1.6.20 or higher? I'm blocked on https://youtrack.jetbrains.com/issue/KT-52047
    h
    n
    • 3
    • 5
  • e

    Erik

    06/29/2022, 1:12 PM
    How would I being with implementing reordering by dragging and dropping items in some list/col/row/grid, or maybe a table, with compose for web?
    h
    o
    • 3
    • 4
  • e

    Erik

    07/01/2022, 2:03 PM
    How can I respond to the user pressing Enter/Return on a
    TextInput
    or
    NumberInput
    ? I hoped that adding this would work:
    addEventListener("submit") {
        onSubmit()
        it.preventDefault()
    }
    And I also tried the
    "onkeyup"
    event, but I can't seem to trigger a callback. Must I use a
    Form
    for this, or can it be done without one?
    • 1
    • 1
  • a

    Ayfri

    07/01/2022, 9:34 PM
    Hey, I just started using Compose Web yesterday, and I have some questions about routing. Is there any help or snippets on how to handle multiple routes ? How to have like something always present in every routes (header/footer) etc ? Or do I have to do all this by myself using Ktor ?
    b
    d
    • 3
    • 8
  • c

    CLOVIS

    07/02/2022, 1:50 PM
    What's the recommended way of doing animations in Compose Web?
    b
    j
    • 3
    • 11
  • c

    CLOVIS

    07/02/2022, 2:09 PM
    It seems like animateFloatAsState is not available
  • a

    Ayfri

    07/02/2022, 3:17 PM
    Hey, why does the
    margin
    and
    padding
    methods doesn't work in styling ?
  • t

    Tunji Dahunsi

    07/04/2022, 2:17 PM
    Is there a way to: • wait for the window
    onLoad
    event • Resize the HTML5 canvas element compose for web renders on • Call
    onWasmReady {}
    Before rendering my Compose app? The examples declare a fixed window size in the samples. Using dom listeners just seem to stretch the canvas, I’m wondering if anyone has dealt with this already.
    👀 2
    • 1
    • 1
  • s

    Slackbot

    07/05/2022, 5:59 PM
    This message was deleted.
  • a

    Ayfri

    07/05/2022, 9:09 PM
    Hey, what is the idiomatic way to add and remove a class to an element using a
    mutableState<Boolean>
    ? For now I have this but it's very ugly I guess 👀
    data class Tab(val name: String, val link: String, val selected: MutableState<Boolean> = mutableStateOf(false)) 
    
    @Composable
    fun Tab(tab: Tab) {
    	NavLink(tab.link, {
    		if (tab.selected.value) {
    			ref { htmlAnchorElement ->
    				htmlAnchorElement.classList.add("selected")
    				onDispose {}
    			}
    		} else {
    			ref { htmlAnchorElement ->
    				htmlAnchorElement.classList.remove("selected")
    				onDispose {}
    			}
    		}
    	}) {
    		Text(tab.name)
    	}
    }
    b
    h
    • 3
    • 8
  • t

    Tunji Dahunsi

    07/06/2022, 4:02 AM
    How does one load custom fonts on compose web targeting the canvas? The method has the following signature:
    fun Font(
        identity: String,
        data: ByteArray,
        weight: FontWeight = FontWeight.Normal,
        style: FontStyle = FontStyle.Normal
    ): Font = LoadedFont(identity, data, weight, style)
    However I’m unsure how to create the the
    ByteArray
    for the
    data
    argument. The required
    .tff
    file is in resources, but I’m not sure what API to use to actually read it in js for the browser.
    j
    • 2
    • 4
  • a

    Ayfri

    07/07/2022, 4:37 PM
    I have a question, how compose for web can be used for multiplaform ? As you create HTML components and CSS ? I don't quite get it
    👍 1
    d
    c
    +5
    • 8
    • 56
  • c

    Cedrick Cooke

    07/07/2022, 4:38 PM
    Are pre-release builds hosted anywhere? On maven central the highest pre-release version I can find is 1.2.0-alpha1-dev620, but GitHub lists 1.2.0-alpha01-dev741
    k
    • 2
    • 2
  • a

    Arjan van Wieringen

    07/08/2022, 6:44 AM
    I have a DisposableEffect which registers an eventlistener, and disposes of it again. But it appears that I am not allowed to update MutableState variables inside this event listener? I get compiler errors:
    var editMode by remember { mutableStateOf(false) }
    
    DisposableEffect(Unit) {
            val handler : EventListener = object : EventListener {
                override fun handleEvent(event: Event) {
                    if (event.target != null) {
                        //editMode = false <- compiler error when I uncomment this
                    }
                }
            }
    
            document.body?.addEventListener("click", handler)
            onDispose {
                document.body?.removeEventListener("click", handler)
            }
        }
    And the last part of the stack-trace:
    java.lang.IllegalStateException: Validation failed in file Components.kt
    	at org.jetbrains.kotlin.backend.common.IrValidator.error(IrValidator.kt:83)
    	at org.jetbrains.kotlin.backend.common.IrValidator.access$error(IrValidator.kt:61)
    EDIT: It appears to work when using a lambda function as argument to the eventListener and not an object.
    s
    • 2
    • 2
  • a

    Arjan van Wieringen

    07/09/2022, 6:23 AM
    I have the issue that I have an
    Input
    which on recomposition doesn't update the UI with the latest value, but it is visible in the DOM tree. The code is a bit like this
    @Composable fun EditableTitle(value: String, onInputChange: (String) -> Unit = {}) {
        var editMode by remember { mutableStateOf(false) }
        val nativeElement = remember { mutableStateOf<HTMLInputElement?>(null) }
    
        // I need to use this as a hack to overwrite the value so that it works
        LaunchedEffect(value) {
            nativeElement.value?.value = value
        }
    
        LaunchedEffect(editMode, nativeElement.value) {
            when {
                editMode -> nativeElement.value?.select()
                !editMode && nativeElement.value != null -> {
                    nativeElement.value?.value?.also(onInputChange)
                    nativeElement.value?.blur()
                }
            }
        }
    
        Input(InputType.Text) {
            placeholder("Enter list name...")
            defaultValue(value) // when I use value(value) it blocks my UI
            refState(nativeElement) // this one uses DisposableEffect to fetch the nativeElement
    
            if (editMode && evt.key == "Enter") {
                editMode = false
            }
        }
    }
    I do some stuff with some other state variables to make it more UI friendly. The
    value
    parameter can be updated externally as well and when it has been modified at least once in the above Composable, the UI doesn't update if the input value into the composable is changed. When I use the
    LaunchedEffect(value)
    it works. Is this logical?
    o
    h
    • 3
    • 14
  • b

    Big Chungus

    07/15/2022, 9:30 AM
    Is CfW compatible with KJS plugin yet?
    h
    • 2
    • 2
  • s

    spierce7

    07/17/2022, 2:24 AM
    I realize that it’s still very early, but does anyone know if Native DOM can be positioned inside the Canvas API for Compose Web in the alpha version?
    l
    • 2
    • 3
  • m

    MrPowerGamerBR

    07/23/2022, 2:49 PM
    For anyone trying to use Jetpack Compose Web on Kotlin 1.7.10: You can disable the version check with
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile> {
        kotlinOptions {
            // Jetpack Compose doesn't support Kotlin 1.7.10 yet, but the latest version seems to compile just fine under Kotlin 1.7.10
            freeCompilerArgs += listOf("-P", "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true")
        }
    }
    The project compiles and runs fine after disabling the check, using
    1.2.0-alpha01-dev750
    :)
  • a

    Ayfri

    07/24/2022, 2:26 PM
    Hi, is it possible to trigger Intellij build action when saving ?
    h
    • 2
    • 2
  • o

    orangy

    07/28/2022, 6:19 PM
    message has been deleted
  • a

    Ayfri

    07/28/2022, 11:11 PM
    I don't know why Compose for Web don't have for now DSL for creating transitions, but I created mine and I find it pretty cool :) Using the builder functions directly into the
    transitions
    lambda set the default values for each ^^ And
    all
    just apply the transition to the properties given, and has an optional lambda argument to have a specific transition for them, for the last part the name is good but just to apply the default values to these properties I didn't come up with a good name, if anyone has an idea I'll listen to it !
    h
    n
    • 3
    • 4
  • z

    zt

    07/29/2022, 5:05 AM
    I'm using the
    --continuous
    option for the
    jsBrowserRun
    task but its not reloading in the browser. When I save, it shows the logs that its sending the data but the site is the same.
    c
    • 2
    • 3
  • z

    zt

    07/29/2022, 5:22 AM
    Can I add
    kotlin-js-store
    to my
    .gitignore
    file?
    a
    m
    • 3
    • 3
  • h

    hfhbd

    07/31/2022, 9:47 AM
    Nice! I would just create the PR 😄
  • a

    Ayfri

    07/31/2022, 2:42 PM
    Hi, is it possible to insert a
    @import
    CSS rule ?
  • g

    Greg Steckman

    08/01/2022, 3:22 AM
    message has been deleted
Powered by Linen
Title
g

Greg Steckman

08/01/2022, 3:22 AM
message has been deleted
View count: 4