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

More SolidJS tasks

Back to the full SolidJS cheat sheet