Level up your frontend skills with bite-sized tutorials and master the art of frontend development with the help of Webtips

Guided roadmaps →
Joined May 2020
Webtips retweeted
💡 Want to loop through an object? Use Object.entries combined with a forEach to read both keys and values:
1
1
100
💡 Want to prevent elements from receiving click events? Here are three solutions you can use: 1️⃣ Set the `disabled` attribute in HTML 2️⃣ Set `pointer-events` to `none` in CSS 3️⃣ Call `event.preventDefault` in JavaScript
1
1
104
💡 Want to display a JavaScript object in a readable way in your React app? You can use a combination of Object.keys with a map to create a loop and display the data in a tabular format:
1
1
97
💡 JavaScript tip(2): If you want to remove duplicates from your array, make a `Set()` out of it, and spread it back into an array:
4
44
3
400
37,595
Here are four patterns you can use in React to improve your codebase: 1️⃣ Child-to-parent communication: Most commonly, you want to lift your state when you want to pass data from child-to-parent components. However, you can also use callback functions:
1
1
106
Webtips retweeted
Want to benchmark your JavaScript code? You can use the Performance API. Copy the following helper function to your project to use it:
1
1
104
Carousels are a common way to present a list of media in a limited space. Learn how you can build the following animated Carousel component in React with the help of CSS transitions: webtips.dev/animated-carouse…
1
89
Modals are a great way to display information outside the regular content flow. You can create them natively in HTML in three simple steps: 1️⃣ Create the modal using a dialog element 2️⃣ Use form method="dialog" to close modals 3️⃣ Use dialog.showModal to open the modal
1
130
Webtips retweeted
💡 Do you need to get query parameters in your React components? Simply use the URLSearchParams:
1
1
1
144
Webtips retweeted
💡 To remove duplicates from an array, you can use a Set combined with the spread operator. The same approach can be used with ...args in a function to combine as many arrays as necessary without duplicates.
1
121
Quick JS tip: When "console-logging" several variables, you can wrap them in curly brackets to better see which value comes from which variable. A small thing, but hey.
1
12
2
111
8,524
Webtips retweeted
💡 Tip: If you need to get the intersection of two arrays, you can use .filter combined with .includes. The same logic can be used to: ✅ Get the difference between two arrays ✅ Get the symmetric difference between two arrays
1
1
113
HTML Tip 💡 You may not know that now we can use <hr> inside <select> to visually divide the group of related options 🤩
6
13
78
3,186
those little details™ Scale up and down on scroll with CSS 📜✨ a { animation: scale, scale; animation-direction: normal, reverse; animation-timeline: view(inline); animation-range: entry, exit; } @​keyframes scale { 0% { scale: 0; } }
20
203
10
2,026
246,209
💡 When using JSX, you can reference method names as components. However, regular functions should always be capitalized; otherwise, your component will be treated as an HTML element.
1
115
You can do blobs with CSS filter but it only works as black or white as far as I know but you can use SVGs to achieve the result you want.
27
156
12
1,718
291,007
Astro 4.0 is here! Introducing the Astro Dev Toolbar — your new companion for local development. Inspect, audit, and extend your dev environment in the browser. Plus: ⚡️ 80% faster builds, 🌐 i18n routing, 🪄 View Transition updates and more! astro.build/blog/astro-4/
53
324
90
1,712
188,206
CSS Trick 📜 You can trigger text highlights on scroll with scroll-driven animations 😎 mark { animation: highlight; animation-timeline: view(); } @​keyframes highlight { to { --lit: 1; }} mark span { background-position: calc(var(--lit) * -110%) 0; transition: background 1s; } The trick is using a scroll-driven animation to flip a custom property on a <mark> element 🎚️ You flip the value between 0 and 1, and that transitions the background position of the <mark> element mark { --lit: 0; animation: highlight steps(1) both; animation-timeline: view(); animation-range: entry 100% cover 10%; } The background has to be applied on a child of the mark to see the change in the custom property 👀 mark span { background: linear-gradient( 120deg, yellow 50%, transparent 50%) 110% 0 / 220% 100% no-repeat; background-position: calc(var(--lit) * 110%) 0; transition: background-position 1s; } The trick is to set the background-size so that it's bigger than the element and then split the background-color in the middle using a linear-gradient 🤙 And the property flips fills in the color 🫶 That's it! If there isn't support for scroll-driven animations, use JavaScript's IntersectionObserver API. The code for this is in the demo 😎 Cool example of using CSS as an IntersectionObserver! @CodePen link below 👇
11
263
5
2,389
208,529