on* attributes.
Mouse Events
Mouse events are triggered by mouse interactions with elements.onclick
Fired when a mouse button is clicked (pressed and released) on an element.MouseData
coordinates()- Element, page, client, and screen coordinatesheld_buttons()- Set of mouse buttons currently heldtrigger_button()- Which button triggered the eventmodifiers()- Keyboard modifiers (Ctrl, Alt, Shift, Meta)
ondoubleclick
Fired when a mouse button is double-clicked on an element.MouseData
Reference: MDN
oncontextmenu
Fired when the right mouse button is clicked (before context menu appears).MouseData
Reference: MDN
onmousedown
Fired when a mouse button is pressed on an element.MouseData
Reference: MDN
onmouseup
Fired when a mouse button is released on an element.MouseData
Reference: MDN
onmousemove
Fired when the mouse pointer moves over an element.MouseData
Reference: MDN
onmouseenter
Fired when the mouse pointer enters an element (does not bubble).MouseData
Bubbles: No
Reference: MDN
onmouseleave
Fired when the mouse pointer leaves an element (does not bubble).MouseData
Bubbles: No
Reference: MDN
onmouseover
Fired when the mouse pointer moves onto an element (bubbles).MouseData
Reference: MDN
onmouseout
Fired when the mouse pointer moves out of an element (bubbles).MouseData
Reference: MDN
Keyboard Events
Keyboard events are triggered by keyboard interactions.onkeydown
Fired when a key is pressed down.KeyboardData
key()- Key value (considers modifiers and layout)code()- Physical key codelocation()- Physical location of the keyis_auto_repeating()- Whether the key is being heldis_composing()- Whether key is part of compositionmodifiers()- Active modifier keys (Ctrl, Alt, Shift, Meta)
onkeyup
Fired when a key is released.KeyboardData
Reference: MDN
onkeypress
Fired when a key that produces a character value is pressed down.KeyboardData
Note: This event is deprecated in favor of onkeydown.
Reference: MDN
Form Events
Form events are triggered by form control interactions.oninput
Fired when the value of an input, select, or textarea changes.FormData
value()- Current value as stringparsed<T>()- Parse value to type Tchecked()- For checkboxes (returns bool)values()- All form values (for forms)files()- Selected files (for file inputs)
onchange
Fired when the value of an input element is committed.FormData
Difference from oninput: onchange fires when the value is committed (e.g., on blur for text inputs), while oninput fires on every change.
Reference: MDN
onsubmit
Fired when a form is submitted.FormData
Reference: MDN
onreset
Fired when a form is reset.FormData
Reference: MDN
oninvalid
Fired when a form control fails validation.FormData
Reference: MDN
Focus Events
Focus events are triggered when elements gain or lose focus.onfocus
Fired when an element receives focus (does not bubble).FocusData
Bubbles: No
Reference: MDN
onblur
Fired when an element loses focus (does not bubble).FocusData
Bubbles: No
Reference: MDN
onfocusin
Fired when an element is about to receive focus (bubbles).FocusData
Reference: MDN
onfocusout
Fired when an element is about to lose focus (bubbles).FocusData
Reference: MDN
Clipboard Events
Clipboard events are triggered by clipboard operations.oncopy
Fired when content is copied.ClipboardData
Reference: MDN
oncut
Fired when content is cut.ClipboardData
Reference: MDN
onpaste
Fired when content is pasted.ClipboardData
Reference: MDN
Drag Events
Drag events are triggered during drag-and-drop operations.ondrag
Fired continuously while an element is being dragged.DragData
Reference: MDN
ondragstart
Fired when a drag operation starts.DragData
Reference: MDN
ondragend
Fired when a drag operation ends.DragData
Reference: MDN
ondragenter
Fired when a dragged element enters a drop target.DragData
Reference: MDN
ondragleave
Fired when a dragged element leaves a drop target.DragData
Reference: MDN
ondragover
Fired when a dragged element is over a drop target.DragData
Reference: MDN
ondrop
Fired when an element is dropped.DragData
Reference: MDN
Scroll Events
onscroll
Fired when an element is scrolled.ScrollData
Reference: MDN
Media Events
onplay
Fired when media playback starts.MediaData
Reference: MDN
onpause
Fired when media playback is paused.MediaData
Reference: MDN
onended
Fired when media playback reaches the end.MediaData
Reference: MDN
Pointer Events
Pointer events provide a unified model for mouse, touch, and pen input.onpointerdown
Fired when a pointer becomes active.PointerData
pointer_type()- Type of pointer (mouse, touch, pen)pointer_id()- Unique identifierpressure()- Pressure appliedwidth(),height()- Contact geometry
onpointerup
Fired when a pointer is no longer active. Event Data:PointerData
Reference: MDN
onpointermove
Fired when a pointer moves. Event Data:PointerData
Reference: MDN
Touch Events
Touch events provide information about touch interactions.ontouchstart
Fired when a touch point is placed on the touch surface.TouchData
Reference: MDN
ontouchmove
Fired when a touch point moves along the touch surface. Event Data:TouchData
Reference: MDN
ontouchend
Fired when a touch point is removed from the touch surface. Event Data:TouchData
Reference: MDN
ontouchcancel
Fired when a touch point has been disrupted. Event Data:TouchData
Reference: MDN
Wheel Events
onwheel
Fired when a wheel button of a pointing device is rotated.WheelData
delta_x(),delta_y(),delta_z()- Scroll amountsdelta_mode()- Unit of delta values
Animation Events
onanimationstart
Fired when a CSS animation starts.AnimationData
Reference: MDN
onanimationend
Fired when a CSS animation ends. Event Data:AnimationData
Reference: MDN
onanimationiteration
Fired when a CSS animation iteration completes. Event Data:AnimationData
Reference: MDN
Transition Events
ontransitionend
Fired when a CSS transition completes.TransitionData
Reference: MDN
Mounted Events
onmounted
Special Dioxus event fired when an element is mounted to the DOM.MountedData
- Access to the underlying DOM element
- Useful for measuring, focusing, or integrating with JavaScript
Event Methods
All events provide these common methods:prevent_default()
Prevents the default browser action.stop_propagation()
Stops the event from bubbling up to parent elements.Async Event Handlers
Event handlers can be async:Event Handler Patterns
Capturing Values
Extracting Event Data
Inline Event Handlers
Named Event Handlers
See Also
- HTML Elements - Complete list of HTML elements
- HTML Attributes - Available attributes
- Interactivity Guide - Learn more about event handling in Dioxus