Event Handling in SolidJS
From the SolidJS cheat sheet ยท Components & JSX ยท verified Jul 2026
Event Handling
Handle DOM events with on-prefixed attributes and native event delegation.
tsx
// Quick Reference
<button onClick={() => console.log("clicked")}>Click</button>
<input onInput={(e) => setValue(e.currentTarget.value)} />๐ก SolidJS uses event delegation for common events โ they're handled at the document level
โก Use on: prefix (e.g., on:scroll) for events that should NOT be delegated
๐ Pass a tuple [handler, data] to bind data to an event without creating a closure
๐ข Events use native DOM types โ e.currentTarget is properly typed in TypeScript
eventsdelegationhandlers