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
  • s

    Satria Adi Putra

    02/18/2022, 4:18 AM
    I've been trying to use preview annotation in compose-web, but whenever I add implementation(compose.preview) i got this error
    Failed building KotlinMPPGradleModel
    org.gradle.internal.resolve.ArtifactNotFoundException: Could not find ui-tooling-preview-1.0.1-samplessources.jar (org.jetbrains.compose.ui:ui-tooling-preview:1.0.1).
    Searched in the following locations:
    https://repo.maven.apache.org/maven2/org/jetbrains/compose/ui/ui-tooling-preview/1.0.1/ui-tooling-preview-1.0.1-samplessources.jar
    What am i doing wrong? I use built in compose-web template from intellij idea
    a
    • 2
    • 2
  • d

    David Herman

    02/18/2022, 8:24 PM
    I notice Compose for Web API uses
    inline
    quite a bit more than I'd expect. Is that to reduce the final javascript bundle size?
    b
    • 2
    • 14
  • d

    dvdandroid

    02/20/2022, 4:31 PM
    how to add hover to property using
    org.jetbrains.compose.web.css.StyleScope
    ? ex:
    Span({
      style { // this is org.jetbrains.compose.web.css.StyleScope, not org.jetbrains.compose.web.css.CSSBuilder
        property("color", "#fff") // <-- hover??
      }
    })
    compose
    1.1.0-alpha05
    o
    d
    • 3
    • 9
  • o

    OdenEgg

    02/24/2022, 5:38 AM
    The documentation shows that the CSS class part is written in StyleSheet, but how do I implement the CSS id part? https://github.com/JetBrains/compose-jb/tree/master/tutorials/Web/Style_Dsl I would appreciate it if you could tell me how the CSS description compares to the Compose-web description.
    a
    • 2
    • 1
  • b

    Big Chungus

    02/24/2022, 11:34 AM
    https://github.com/JetBrains/compose-jb/releases/tag/v1.1.0 :kotlin-intensifies: :kotlin-intensifies-purple:
    🤩 4
    👍 8
    👀 3
    👍🏻 1
    🎉 11
    m
    a
    +3
    • 6
    • 11
  • s

    Spheniscine

    03/09/2022, 3:22 AM
    I've been trying out ReactJS for the past few months but had some issues, one huge one was how large and deeply-nested the node-modules folder could get
    b
    • 2
    • 3
  • a

    alexfacciorusso

    03/10/2022, 4:53 PM
    Hi all! I am trying to use compose web with a normal kotlin-js project (e.g. non-multiplatform). Gradle, though, keeps failing telling me it "can't find the compose runtime reference"
    b
    j
    • 3
    • 9
  • k

    Kirill Grouchnikov

    03/11/2022, 2:07 AM
    "and we're working on fixing that" is right there
    s
    e
    j
    • 4
    • 10
  • r

    Robert

    03/11/2022, 8:22 PM
    Are there any templates or components lib available for compose web?
    b
    • 2
    • 1
  • s

    spierce7

    03/13/2022, 10:30 PM
    I tried out the alpha version of Compose Web. Lots of fun! One thing that I wasn’t anticipating was how slow the frames are when compiling for development. The bad performance goes away completely when compiling for prouduction. I suppose most of my development work would be on the JVM anyways, so it’s not really a big deal. Excited for this to move to beta so I can port one of my compose products over to it!
    :yes-black: 6
    d
    • 2
    • 6
  • o

    Ovsyannikov Alexey

    03/14/2022, 12:06 PM
    Hello everybody. I want to create some
    Composable
    function inside of an interface and realize this function in realizations if that interface. I have tried to use some
    @Composable
    callback getters (
    val renderer: @Composable () -> Unit
    ), common functions (
    @Composable fun render()
    ) and several other ways, but I got errors in rendering fun (
    IllegalStateException {message: 'Function TextArea should have been replaced by compiler.', cause: undefined, name: 'IllegalStateException', stack: 'IllegalStateException: Function TextArea should ha…://127.0.0.1:8080/postssystem.client.js:1:2202661'}
    error,
    TextArea
    here is external
    @Composable
    top-level function) or event getting an error
    java.lang.AssertionError: No such value argument slot in IrCallImpl: 0 (total=0).
    . Could somebody help me with this?
    h
    s
    • 3
    • 15
  • p

    paoloconte

    03/17/2022, 12:12 PM
    Hello, I'm a bit confused on how to clear a Text Input.. let's say I have
    var text by remember { mutableStateOf("") }
    Input(type = InputType.Text, attrs = {
       defaultValue(text)
       onChange {  event ->
           text = event.target.value
       }
    })
    If I then set
    text = ""
    the input field is not cleared, as defaultValue is not reapplied... so how can I clear it? is the only way using a reference to the HTMLInputElement? Thanks
    h
    • 2
    • 4
  • d

    Derek Ellis

    03/18/2022, 5:22 PM
    I am running into an issue with
    routing-compose
    where a flow that I am collecting as state does not trigger a recomposition if the page is loaded under a path that is being matched by the router (regardless of whether I'm using
    HashRouter
    or
    BrowserRouter
    This is the relevant line of code that is not triggering recomposition: https://github.com/dellisd/reroute/blob/master/web/src/jsMain/kotlin/io/github/dellisd/reroute/map/MapDemo.kt#L31 it is a child of a
    HashRouter
    https://github.com/dellisd/reroute/blob/master/web/src/jsMain/kotlin/io/github/dellisd/reroute/Main.kt#L22-L23 Here (https://dellisd.github.io/reroute/), the page is loaded and the data is loaded asynchronously before being emitted to a flow, collected as state, and then displayed on the map (as the set of red points) But here (https://dellisd.github.io/reroute/#/stops/7664) where a specific route is matched, the data is still loaded but now the flow does not trigger a recomposition in the
    MapDemo
    composable and the map is not updated to display the points Am I missing something, or is this potentially a bug somewhere? And if it is a bug, does anyone have any tips on how to narrow down where the bug is actually coming from?
    s
    h
    • 3
    • 12
  • r

    Robert

    03/20/2022, 2:14 PM
    Any good example projects for compose web? Other than the flappy bird thing.
    b
    h
    • 3
    • 2
  • s

    Spheniscine

    03/23/2022, 4:35 AM
    But really Compose gets some things right that React doesn't IMO • state variables are single objects, not those annoying (value, setValue) tuples that have to be passed around everywhere, and where setValue doesn't actually change the immutable value variable until recomposition • kotlin-css is already integrated. If I try to use a CSS library with react, like emotion or JSS, things really blow up
    r
    a
    • 3
    • 6
  • c

    Casey Brooks

    03/25/2022, 6:22 PM
    Hey folks, I wanted to give a teaser of an MVI state management library I’ve been working on. It’s still fairly early and not yet officially released, but I was able to get some examples built and running in Compose Web in its documentation site! https://copper-leaf.github.io/ballast/wiki/examples/scorekeeper/
    👍🏽 1
    👍 4
    c
    r
    • 3
    • 4
  • s

    Sunny

    03/28/2022, 12:22 PM
    Hello, in compose web what would be an equivalent of
    box-shadow
    ? Use case is building a card.
    ✅ 1
    • 1
    • 1
  • n

    Nikky

    04/03/2022, 4:29 PM
    compose web draws into a canvas.. what javascript hooks would i need to adjust the canvas to the browser window size each time it gets resized ? i tried
    function resize_canvas(){
        canvas = document.getElementById("ComposeTarget");
        canvas.width  = window.innerWidth;
        canvas.height = window.innerHeight;
    }
    with
    <body onresize="resize_canvas()">
    and.. although that resizes the canvas.. it stops rendering
    h
    • 2
    • 8
  • n

    Nikky

    04/04/2022, 5:26 PM
    so i got compose web working when rendering on a canvas, but for some reason i cannot get my code to render to the dom, trying to follow https://github.com/JetBrains/compose-jb/tree/master/tutorials/Web/Getting_Started loosely but no matter what i do this gets thrown..
    CompositionLocal LocalDensity not present
    my main function is
    fun main() {
        renderComposable(rootElementId = "root") {
            console.log("rendering root element")
    
            Text("Test")
        }
    }
    and the index.html looks like so
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Pentagame</title>
    <!--    <script src="skiko.js"> </script>-->
    </head>
    <body>
        <div id="root"></div>
    <!--    <canvas id="ComposeTarget" width="1024" height="720"></canvas>-->
        <script src="app.js"></script>
    </body>
    </html>
    :plus-one: 1
    o
    n
    d
    • 4
    • 6
  • o

    Ovsyannikov Alexey

    04/06/2022, 5:42 AM
    Hello everybody 🙂 is there any news about compose with kotlin 1.6.20 compatibility?
    e
    • 2
    • 1
  • o

    Oliver.O

    04/10/2022, 5:48 PM
    Has anyone tried to use Kotlin 1.6.20 with the corresponding Compose pre-release compiler (
    1.2.0-dev-k1.6.20-61e81dadb1c
    )? Over here, building the IntelliJ wizard Compose Web demo fails in
    compileProductionExecutableKotlinJs
    with
    Internal error in file lowering: java.util.NoSuchElementException: Collection contains no element matching the predicate.
    h
    • 2
    • 6
  • n

    Norbi

    04/11/2022, 6:32 AM
    Hello, maybe is there a ticket where I could track Compose/Web canvas-based rendering progress? Thanks.
    ➕ 4
    👀 2
    o
    d
    • 3
    • 4
  • p

    Partho Paul

    04/11/2022, 2:50 PM
    Hi all, is there any alternative for http://google.github.io/accompanist/pager? I'm working on a front-end project using compose-web and the project is web-browser specific (it'll not be used in android or iOS), so I'm trying to avoid android dependencies.
    n
    • 2
    • 1
  • s

    salomonbrys

    04/11/2022, 5:55 PM
    Hey composers! Since the
    Stylesheet.css
    function was deleted (https://github.com/JetBrains/compose-jb/commit/cd7691a53fc73ed41abda6de604eb1f9a08af48b), I can find no way in Compose Web to have Css-In-JS, that is to have a component style classes defined within the component (I would usually use the syntax described in this issue: https://github.com/JetBrains/compose-jb/issues/1207). This type of syntax (aka CSS-In-JS) is supported in Kotlin React with https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-styled/README.md and is an important design decision in how we've been building our web apps with it. Is Jetbrains Compose Web going to support it back ? Is there a workaround we can use in the meantime ? Note that using
    style
    is insufficient as it does not allow full css selection (hover, children, etc.). Note that when we were using Kotlin-React, the difference between
    css
    and
    style
    was important: the former described "stable" style (in order to avoid class regeneration) while the second described "moving" style.
    ➕ 1
    o
    d
    • 3
    • 8
  • o

    Omar Shehe

    04/21/2022, 7:11 AM
    Hello, has anyone tried using
    Google Sign In
    with
    compose web
    ? I will appreciate any ideas or suggestions😊 .
    r
    • 2
    • 9
  • p

    phuc.tran

    04/21/2022, 7:36 AM
    Hello friends. I posted these questions on #multiplatform channel but I am copying it here, hope we have the answer faster 🙂 From what I understood, for now compose web parses kotlin code to DOM. So: 1. We can not share the mobile/desktop code with web (because mobile/desktop render on Canvas), is this correct? 2. But if web use Canvas, it will have the problem with SEO and performance (big bundle for first load) - like Flutter?
    h
    • 2
    • 6
  • p

    phuc.tran

    04/21/2022, 7:48 AM
    well, so if we want to have a good (in terms of SEO and performance) web, we need to build web UI separately 😐
    d
    b
    • 3
    • 7
  • s

    Sebastien Leclerc Lavallee

    04/21/2022, 4:31 PM
    Hello! I want to add compose web to my existing KMP project but the problem is that I’m already using Kotlin 1.6.20. Currently, the compose setup set the Jetbrain’s compose plugin to 1.1.1 (
    id("org.jetbrains.compose") version "1.1.1"
    ). I think I got this from a tutorial or wizard in IntelliJ. Now I know that compose 1.1.1 does not support Kotlin 1.6.20. But I saw last week that a new version of the compose compiler alpha version (
    1.2.0-alpha08
    ) does now support Kotlin 1.6.20. But how do I get to force the compiler version ? Will it even work since the compiler is the one provided by Google and not the Jetbrain’s one which support compose web. Or are there any difference?!
    build.gradle.kts
    setup in thread. Thanks for clarifications 😅
    k
    h
    +2
    • 5
    • 14
  • a

    Akram Bensalem

    04/24/2022, 1:48 PM
    How to serve webApp.js from a backend server ?
    n
    • 2
    • 1
  • p

    Partho Paul

    04/26/2022, 9:41 AM
    Hello! I want to convert an ISO date format into a given format. I'm doing it using JSJoda library as below:
    val date = LocalDateTime.parse(isoValue)
    val dateFormat = DateTimeFormatter.ofPattern(format)
    return date.format(dateFormat)
    This is giving me an error which says that
    DateTimeFormatter.ofPattern(format)
    needs a Locale but I'm not getting any option to set Locale by doing something like
    DateTimeFormatter.ofPattern(format).withLocale(Locale.ENGLISH)
    because
    Locale
    is just an interface without any implementation. Tried googling but didn't find anything. Is there any other way to do this? TIA
    ✅ 1
    r
    l
    • 3
    • 6
Powered by Linen
Title
p

Partho Paul

04/26/2022, 9:41 AM
Hello! I want to convert an ISO date format into a given format. I'm doing it using JSJoda library as below:
val date = LocalDateTime.parse(isoValue)
val dateFormat = DateTimeFormatter.ofPattern(format)
return date.format(dateFormat)
This is giving me an error which says that
DateTimeFormatter.ofPattern(format)
needs a Locale but I'm not getting any option to set Locale by doing something like
DateTimeFormatter.ofPattern(format).withLocale(Locale.ENGLISH)
because
Locale
is just an interface without any implementation. Tried googling but didn't find anything. Is there any other way to do this? TIA
✅ 1
r

rocketraman

04/26/2022, 12:48 PM
If you want to use JSJoda, check out: https://js-joda.github.io/js-joda/manual/formatting.html
In my project I created an expect/actual for date/time formatting. My JS implementation uses
Date.toLocaleTimeString
and looks like this:
actual fun formatDateTime(date: LocalDateTime, locale: String): String =
  jsFormatDateTime(date.year, date.monthNumber - 1, date.dayOfMonth, date.hour, date.minute, locale)

@Suppress("UNUSED_PARAMETER", "LongParameterList")
private fun jsFormatDateTime(yearArg: Int, monthArg: Int, dayArg: Int, hourArg: Int, minuteArg: Int, locale: String): String =
  js(
    "(new Date(yearArg, monthArg, dayArg, hourArg, minuteArg))" +
      ".toLocaleTimeString(locale, {year: 'numeric', month: 'short', day: '2-digit'});"
  ) as String
Where locale is just a standard locale string e.g.
en-US
.
l

Luc Girardin

04/26/2022, 3:18 PM
FYI, you can do all of this in pure Kotlin using Klock (https://docs.korge.org/klock/). At least this worked well for me…
p

Partho Paul

04/27/2022, 11:17 AM
@Luc Girardin This works for me. Thank you! @rocketraman Thanks for showing a different approach
👍 1
r

rocketraman

04/27/2022, 12:48 PM
Hopefully kotlinx-datetime will introduce formatting functions before long
:yes-black: 1
View count: 182