<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/listening-for-element-events-with-compose-for-web-srtuobgfe" -->

---
title: Listening for element events with Compose for Web
description: A tutorial on handling browser events in Compose for Web (Kotlin). Covers basic event listeners like onClick and onInput using AttributesBuilder, then dives...
canonical: https://daily.dev/posts/listening-for-element-events-with-compose-for-web-srtuobgfe
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Listening for element events with Compose for Web | daily.dev
og:description: A tutorial on handling browser events in Compose for Web (Kotlin). Covers basic event listeners like onClick and onInput using AttributesBuilder, then dives...
og:url: https://daily.dev/posts/listening-for-element-events-with-compose-for-web-srtuobgfe
og:image: https://api.daily.dev/og/posts/SRTuObgfE.png
og:image:alt: Listening for element events with Compose for Web
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Listening for element events with Compose for Web

**[Touchlab](https://daily.dev/sources/touchlab)** · 6 min read · 0 upvotes · 0 comments

## Summary

A tutorial on handling browser events in Compose for Web (Kotlin). Covers basic event listeners like onClick and onInput using AttributesBuilder, then dives into a more complex drag-and-drop example using SideEffect to bridge imperative JS-style event handling (onmousedown, onmousemove, onmouseup) into the Compose declarative model. Includes full code snippets for a draggable window component built with 98.css styling.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://touchlab.co/compose-html-events>

## Similar posts on daily.dev

- [Compose & kotlinx.html](https://daily.dev/posts/compose-kotlinx-html-bwnvtjbsl) · Jake Wharton · 3 upvotes · 1 comments
- [jetc.dev Newsletter Issue \#331](https://daily.dev/posts/jetc-dev-newsletter-issue-331-1j5ljyhwl) · Jetpack Compose Newsletter · 0 upvotes · 0 comments
- [Mastering Jetpack Compose Side-Effect Handlers](https://daily.dev/posts/mastering-jetpack-compose-side-effect-handlers-sburtpuli) · Medium · 1 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#kotlin](https://daily.dev/tags/kotlin), [#jetpack-compose](https://daily.dev/tags/jetpack-compose)

[View this post on daily.dev](https://daily.dev/posts/listening-for-element-events-with-compose-for-web-srtuobgfe)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Listening for element events with Compose for Web","url":"https://daily.dev/posts/listening-for-element-events-with-compose-for-web-srtuobgfe","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/listening-for-element-events-with-compose-for-web-srtuobgfe"},"datePublished":"2026-08-02T07:15:26.515Z","dateModified":"2026-08-02T07:40:14.378Z","description":"A tutorial on handling browser events in Compose for Web (Kotlin). Covers basic event listeners like onClick and onInput using AttributesBuilder, then dives...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8313f5d0d19b1e07b62ce84807ba2f1d?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8313f5d0d19b1e07b62ce84807ba2f1d?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Touchlab","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Touchlab","logo":"https://media.daily.dev/image/upload/s--CQ0u6GwB--/f_auto,q_auto/v1785654902/logos/touchlab?_a=BAMAMicg0","url":"https://daily.dev/sources/touchlab"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/listening-for-element-events-with-compose-for-web-srtuobgfe","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,kotlin,jetpack-compose","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Touchlab","item":"https://daily.dev/sources/touchlab"},{"@type":"ListItem","position":3,"name":"Listening for element events with Compose for Web"}]}
```

