Responsive UI Design
0 139
๐ฑ Responsive UI Design in a Weather App
Building a weather app is a great project โ but what makes it truly production-ready is its responsiveness. Your app should look and function beautifully on all screen sizes: from a tiny mobile phone to a full desktop monitor. In this guide, weโll explore how to make your weather app adapt gracefully using React and Tailwind CSS. ๐ค๏ธ๐งฉ
๐ฏ Why Responsiveness Matters
- ๐ฑ Over 70% of users browse on mobile
- ๐ A responsive app increases usability and retention
- ๐ Boosts SEO and Core Web Vitals score
- ๐ฏ Ensures consistent UX across devices
๐งฑ App Layout Overview
Letโs say our app has three main UI sections:
- ๐ A search bar
- ๐ฆ๏ธ Weather summary card
- ๐ Forecast and extra details
Weโll now make each of these responsive with simple design patterns.
๐ Responsive Search Bar
<div className="flex flex-col sm:flex-row items-center gap-2">
<input
type="text"
placeholder="Enter city"
className="w-full sm:w-auto p-2 border rounded"
/>
<button className="bg-blue-500 text-white px-4 py-2 rounded">
Search
</button>
</div>
๐ก On small screens: full-width input. On medium and up: input and button go inline.
๐ฆ๏ธ Weather Info Card (Flex/Grid)
<div className="flex flex-col sm:flex-row justify-between items-center p-4 bg-white rounded shadow mt-4">
<div>
<h2 className="text-xl font-semibold">๐ Delhi</h2>
<p>๐ก๏ธ 34ยฐC | โ๏ธ Clouds</p>
</div>
<img
src="https://openweathermap.org/img/wn/03d@2x.png"
alt="weather icon"
className="w-20 h-20 mt-2 sm:mt-0"
/>
</div>
๐ This layout stacks vertically on mobile, then side-by-side on tablets and up.
๐ Forecast Section with Grid
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-4 mt-6">
{forecast.map((day) => (
<div className="bg-blue-100 p-3 rounded text-center" key={day.id}>
<p>{day.date}</p>
<p>๐ก๏ธ {day.temp}ยฐC</p>
<p>โ๏ธ {day.condition}</p>
</div>
))}
</div>
๐ The grid automatically adjusts: 2 columns on mobile, up to 5 on desktop!
๐จ Tailwind Breakpoints Used
sm:
โฅ 640px (phones)md:
โฅ 768px (tablets)lg:
โฅ 1024px (desktops)
Use classes like sm:flex-row
, md:grid-cols-4
to change layout across sizes.
๐ Custom Media Queries (CSS option)
If you're not using Tailwind:
.weather-card {
display: flex;
flex-direction: column;
}
@media (min-width: 768px) {
.weather-card {
flex-direction: row;
justify-content: space-between;
}
}
๐ง Responsive Design Best Practices
- ๐ช Design mobile-first: stack content naturally
- ๐ Use percentages and viewport units instead of fixed sizes
- ๐ Test responsiveness in browser dev tools and on real devices
- ๐งฉ Use utility libraries (like Tailwind) to simplify styling
๐ Summary
- โ Built flexible layouts using Tailwind's responsive classes
- โ Search bar, info card, and forecast all adapt to screen size
- โ Learned both Tailwind and pure CSS techniques
๐ Final Thoughts
A responsive weather app doesnโt just look better โ it feels better. With just a few layout tweaks, you can make your app shine on every screen. Whether you're building a hobby project or a full product, responsive design is no longer optional โ it's expected. ๐ฒโก
If youโre passionate about building a successful blogging website, check out this helpful guide at Coding Tag โ How to Start a Successful Blog. It offers practical steps and expert tips to kickstart your blogging journey!
For dedicated UPSC exam preparation, we highly recommend visiting www.iasmania.com. It offers well-structured resources, current affairs, and subject-wise notes tailored specifically for aspirants. Start your journey today!

Share:
Comments
Waiting for your comments