A beautiful, interactive weather card component with forecast, detailed metrics, and multiple weather conditions support.
On This Page
Search for a command to run...
A beautiful, interactive weather card component with forecast, detailed metrics, and multiple weather conditions support.
On This Page
United States
Feels like: 21°
clear sky
The Weather Card automatically adapts its theme based on weather conditions with unique gradients and icons for different weather types including rain, snow, thunderstorms, fog, and more.
United States
Feels like: 23°
clear sky
France
Feels like: 17°
few clouds
Japan
Feels like: 15°
overcast clouds
United Kingdom
Feels like: 11°
drizzle
United Kingdom
Feels like: 12°
moderate rain
India
Feels like: 32°
thunderstorm
United States
Feels like: -6°
snow
Canada
Feels like: 9°
mist
United States
Feels like: 14°
fog
China
Feels like: 26°
haze
UAE
Feels like: 36°
dust
United States
Feels like: 4°
squalls
Display a 5-day weather forecast with expandable sections.
Japan
Feels like: 17°
broken clouds
Supports both Celsius and Fahrenheit with easy unit switching.
France
Feels like: 19°
clear sky
France
Feels like: 66°
clear sky
import { WeatherCard } from "@/components/ui/weather-card";
const weatherData = {
coord: {
lon: -122.4194,
lat: 37.7749,
},
weather: [
{
id: 800,
main: "Clear",
description: "clear sky",
icon: "01d",
},
],
main: {
temp: 22,
feels_like: 21,
temp_min: 18,
temp_max: 25,
pressure: 1013,
humidity: 60,
},
visibility: 10000,
wind: {
speed: 3.5,
deg: 180,
},
dt: 1699641600,
sys: {
country: "US",
sunrise: 1699622400,
sunset: 1699660800,
},
timezone: -28800,
name: "San Francisco",
location: {
city: "San Francisco",
country: "United States",
region: "California",
},
};
export default function Example() {
return <WeatherCard weatherData={weatherData} />;
}| Prop | Type | Default | Description |
|---|---|---|---|
| weatherData | WeatherData | - | Weather data object (required) |
| className | string | undefined | Additional CSS classes |
| showForecast | boolean | true | Whether to show the forecast section |
| showDetails | boolean | true | Whether to show the additional details section |
| defaultUnit | "celsius" | "fahrenheit" | "celsius" | Default temperature unit |
interface WeatherData {
coord?: {
lon: number;
lat: number;
};
weather: WeatherCondition[];
main: WeatherMain;
visibility?: number;
wind: WeatherWind;
dt: number;
sys: WeatherSys;
timezone: number;
name: string;
location: WeatherLocation;
forecast?: ForecastDay[];
}
interface WeatherLocation {
city: string;
country: string | null;
region: string | null;
}
interface WeatherMain {
temp: number; // Temperature in Celsius
feels_like: number; // Feels like temperature in Celsius
temp_min: number;
temp_max: number;
pressure: number; // Atmospheric pressure in hPa
humidity: number; // Humidity percentage
}
interface WeatherWind {
speed: number; // Wind speed in m/s
deg: number; // Wind direction in degrees
}
interface WeatherCondition {
id: number; // Weather condition ID
main: string; // Weather parameter (Rain, Snow, Clear, etc.)
description: string; // Weather description
icon: string;
}
interface WeatherSys {
country: string; // Country code
sunrise: number; // Sunrise time (Unix timestamp)
sunset: number; // Sunset time (Unix timestamp)
}
interface ForecastDay {
date: string; // Date string (YYYY-MM-DD)
timestamp: number; // Unix timestamp
temp_min: number; // Minimum temperature
temp_max: number; // Maximum temperature
humidity: number; // Humidity percentage
weather: {
main: string;
description: string;
icon: string;
};
}This component works great with weather data from:
Display only current weather without forecast or details:
<WeatherCard
weatherData={weatherData}
showForecast={false}
showDetails={false}
/>Set Fahrenheit as the default unit:
<WeatherCard weatherData={weatherData} defaultUnit="fahrenheit" />Add custom classes to modify appearance:
<WeatherCard weatherData={weatherData} className="max-w-lg shadow-2xl" />Show complete weather data with forecast:
<WeatherCard
weatherData={weatherDataWithForecast}
showForecast={true}
showDetails={true}
/>