Using <code>svelte:window</code> to Track Window Resize
📖 Scenario: You are building a simple Svelte app that shows the current width of the browser window. This helps users see how wide their screen is in real time.
🎯 Goal: Create a Svelte component that listens to window resize events using svelte:window and updates the displayed window width dynamically.
📋 What You'll Learn
Create a variable
width to store the window widthUse
svelte:window with the on:resize eventUpdate
width when the window resizesDisplay the current
width in the component💡 Why This Matters
🌍 Real World
Tracking window size is common in responsive web design to adjust layouts or content dynamically.
💼 Career
Understanding how to handle window events in Svelte is useful for building interactive, accessible web apps that respond to user environment changes.
Progress0 / 4 steps