Skip to content
Discussion options

You must be logged in to vote
# Automatically scrolls to top upon loading
<div 
  x-data
  x-init="window.scrollTo({top: 0, behavior: 'smooth'})"
  class=""></div>

# Scrolls to top of the page on click
<button 
  x-data
  @click.window="window.scrollTo({top: 0, behavior: 'smooth'})"
  class="">Top</button>

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@arewtech
Comment options

@grobiwebdesign
Comment options

Answer selected by Shadecute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants