Weather Card

Pro

The weather an assistant returns in a chat reply: the place, the temperature now, the sky, the day's high and low, the next hours and the week ahead. A full card for one forecast, a row that opens in place when there are several.

Lisbon, PortugalNow · Thu, Nov 6
21 degrees CelsiusPartly cloudyHigh 24 degrees CelsiusLow 16 degrees Celsius
Feels like
20°
Rain
30%
Wind
14 km/h NW
Humidity
62%
NowPartly cloudy, 21 degrees Celsius
3 PMPartly cloudy, 22 degrees Celsius
4 PMCloudy, 22 degrees Celsius, chance of rain 10%
5 PMCloudy, 21 degrees Celsius, chance of rain 20%
6 PMDrizzle, 20 degrees Celsius, chance of rain 40%
7 PMRain, 19 degrees Celsius, chance of rain 60%
8 PMRain, 18 degrees Celsius, chance of rain 70%
9 PMRain, 17 degrees Celsius, chance of rain 50%
10 PMPartly cloudy, 17 degrees Celsius, chance of rain 20%
11 PMClear, 16 degrees Celsius
TodayPartly cloudy, chance of rain 30%Low 16 degrees CelsiusHigh 24 degrees Celsius
FriRain, chance of rain 80%Low 14 degrees CelsiusHigh 19 degrees Celsius
SatThunderstorms, chance of rain 70%Low 13 degrees CelsiusHigh 18 degrees Celsius
SunDrizzle, chance of rain 40%Low 12 degrees CelsiusHigh 20 degrees Celsius
MonCloudy, chance of rain 10%Low 14 degrees CelsiusHigh 22 degrees Celsius
TueSunnyLow 15 degrees CelsiusHigh 25 degrees Celsius
WedSunnyLow 17 degrees CelsiusHigh 27 degrees Celsius

Installation#

# One-time setup (tokens + lib helpers)npx koalaui-cli@latest init# Activate your Pro license (once per machine)npx koalaui-cli@latest login <key># Add this component (its dependencies come along)npx koalaui-cli@latest add weather-card

Usage#

This example is part of Koala UI Pro

The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.

Have a license? Unlock it here

Anatomy#

A header that names the place and the time, and the content under it: the weather now, the details, the next hours and the days ahead. Every part is droppable: a quick answer needs only the place and the temperature now.

import {  WeatherCard,  WeatherCardHeader,  WeatherCardLocation,  WeatherCardContent,  WeatherCardCurrent,  WeatherCardGlyph,  WeatherCardTemperature,  WeatherCardCondition,  WeatherCardRange,  WeatherCardStats,  WeatherCardStat,  WeatherCardHourly,  WeatherCardHour,  WeatherCardDaily,  WeatherCardDay,} from "@/components/ui/weather-card"<WeatherCard>  <WeatherCardHeader>    <WeatherCardLocation />  </WeatherCardHeader>  <WeatherCardContent>    <WeatherCardCurrent>      <WeatherCardGlyph />      <WeatherCardTemperature />      <WeatherCardCondition />      <WeatherCardRange />    </WeatherCardCurrent>    <WeatherCardStats>      <WeatherCardStat />    </WeatherCardStats>    <WeatherCardHourly>      <WeatherCardHour />    </WeatherCardHourly>    <WeatherCardDaily>      <WeatherCardDay />    </WeatherCardDaily>  </WeatherCardContent></WeatherCard>

Conditions#

Nine skies from Koala Icons, drawn for this card on the same grid as the rest of the set; clear and partly cloudy have a night glyph too. Set the sky once on the root with condition and night; the glyph and the wording follow it. WeatherIcon is the same map on its own, for a forecast anywhere else.

Sunny / Clearclear
Partly cloudypartly-cloudy
Cloudycloudy
Rainrain
Drizzledrizzle
Thunderstormsstorm
Snowsnow
Fogfog
Windywind

Hourly#

WeatherCardHourly lays the next hours out as a strip that runs to the card's edges and scrolls sideways, snapping hour by hour, with the edge fading while there is more to see. The chance of rain is the one thing in colour, and only when there is a chance. Tab into the strip and the arrow keys scroll it.

Lisbon, PortugalNow · Thu, Nov 6
21 degrees CelsiusPartly cloudyHigh 24 degrees CelsiusLow 16 degrees Celsius
NowPartly cloudy, 21 degrees Celsius
3 PMPartly cloudy, 22 degrees Celsius
4 PMCloudy, 22 degrees Celsius, chance of rain 10%
5 PMCloudy, 21 degrees Celsius, chance of rain 20%
6 PMDrizzle, 20 degrees Celsius, chance of rain 40%
7 PMRain, 19 degrees Celsius, chance of rain 60%
8 PMRain, 18 degrees Celsius, chance of rain 70%
9 PMRain, 17 degrees Celsius, chance of rain 50%
10 PMPartly cloudy, 17 degrees Celsius, chance of rain 20%
11 PMClear, 16 degrees Celsius

Forecast#

WeatherCardDaily sets one scale for the week from the coldest low to the warmest high, so every day's bar sits where it falls on it and a cold snap reads at a glance. The bar takes a quiet hue from the day's mean, cold to hot. Pass current on today to mark the temperature now on its bar.

Lisbon, Portugal7-day forecast
TodayPartly cloudy, chance of rain 30%Low 16 degrees CelsiusHigh 24 degrees Celsius
FriRain, chance of rain 80%Low 14 degrees CelsiusHigh 19 degrees Celsius
SatThunderstorms, chance of rain 70%Low 13 degrees CelsiusHigh 18 degrees Celsius
SunDrizzle, chance of rain 40%Low 12 degrees CelsiusHigh 20 degrees Celsius
MonCloudy, chance of rain 10%Low 14 degrees CelsiusHigh 22 degrees Celsius
TueSunnyLow 15 degrees CelsiusHigh 25 degrees Celsius
WedSunnyLow 17 degrees CelsiusHigh 27 degrees Celsius

Compact#

layout="compact" turns the header into one line you can click: the glyph, the place over the sky and the time, the temperature and the range. The card grows to show the forecast underneath, the same object getting taller rather than a panel swapping in. Stack a few for “weather in my three cities”.

NowPartly cloudy, 21 degrees Celsius
3 PMPartly cloudy, 22 degrees Celsius
4 PMCloudy, 22 degrees Celsius, chance of rain 10%
5 PMCloudy, 21 degrees Celsius, chance of rain 20%
6 PMDrizzle, 20 degrees Celsius, chance of rain 40%
7 PMRain, 19 degrees Celsius, chance of rain 60%
8 PMRain, 18 degrees Celsius, chance of rain 70%
9 PMRain, 17 degrees Celsius, chance of rain 50%
10 PMPartly cloudy, 17 degrees Celsius, chance of rain 20%
11 PMClear, 16 degrees Celsius
TodayPartly cloudy, chance of rain 30%Low 16 degrees CelsiusHigh 24 degrees Celsius
FriRain, chance of rain 80%Low 14 degrees CelsiusHigh 19 degrees Celsius
SatThunderstorms, chance of rain 70%Low 13 degrees CelsiusHigh 18 degrees Celsius
SunDrizzle, chance of rain 40%Low 12 degrees CelsiusHigh 20 degrees Celsius
MonCloudy, chance of rain 10%Low 14 degrees CelsiusHigh 22 degrees Celsius

In a conversation#

Inside a reply the card takes the message column's width, with no bubble around it. The answer leads in words and the card backs it up with the numbers.

Will it rain in Lisbon tomorrow?
Yes, take an umbrella. Friday brings rain most of the day, an 80% chance, with a high of 19°. The weekend stays unsettled and clears up from Tuesday.
Lisbon, PortugalTomorrow · Fri, Nov 7
19 degrees CelsiusRainHigh 19 degrees CelsiusLow 14 degrees Celsius
Rain
80%
Wind
22 km/h SW
FriRain, chance of rain 80%Low 14 degrees CelsiusHigh 19 degrees Celsius
SatThunderstorms, chance of rain 70%Low 13 degrees CelsiusHigh 18 degrees Celsius
SunDrizzle, chance of rain 40%Low 12 degrees CelsiusHigh 20 degrees Celsius
MonCloudy, chance of rain 10%Low 14 degrees CelsiusHigh 22 degrees Celsius
TueSunnyLow 15 degrees CelsiusHigh 25 degrees Celsius

Loading#

While a forecast streams in, WeatherCardSkeleton holds its place in the same frame, with the temperature and the hours where they will land.

API reference#

WeatherCard

One forecast, an <article>, and the context every part reads: the unit, the sky now and whether it is night. Every part accepts className, merged last, and every part is droppable. weatherCardVariants is the recipe.

PropTypeDefaultDescription
unit"c" | "f""c"The unit the temperatures are in. It words what a screen reader hears ("21 degrees Celsius") and sets the range bar's colour bands; the numbers are yours.
conditionWeatherCondition-The sky now. WeatherCardGlyph and WeatherCardCondition draw and word it.
nightbooleanfalseDraws the night glyph (moon) and the night wording ("Clear" instead of "Sunny").
layout"full" | "compact""full"full shows everything at once. compact makes the header a one-line disclosure and folds WeatherCardContent under it.
openboolean-Controlled open state of a compact card.
defaultOpenbooleanfalseInitial open state of a compact card.
onOpenChange(open: boolean) => void-Called when a compact card opens or closes.
Data attributeDescription
data-slot"weather-card".
data-layout"full" or "compact".
data-unit"c" or "f".
data-conditionThe condition.
data-nightPresent when night.
data-stateopen or closed, on a compact card only.

WeatherCardHeader

The top line, a flex row. In a compact card it is the Radix Collapsible.Trigger (a <button>) holding the glyph, the place, the temperature and the range, and adds the caret; in a full card it is a <div>.

Data attributeDescription
data-slot"weather-card-header".

WeatherCardLocation

The place (the children) over a muted line for the time, a <span> that takes the row's free width. Both truncate.

PropTypeDefaultDescription
timeReact.ReactNode-When the forecast is for: "Now", "Tomorrow · Fri, Nov 7". Pass formatted text.
Data attributeDescription
data-slot"weather-card-location"; the lines are "weather-card-place" and "weather-card-time".

WeatherCardContent

Everything under the header, a <div> stacking its parts 16px apart. In a compact card it is the Radix Collapsible.Content: its height tweens open and shut and the parts fade in with it.

Data attributeDescription
data-slot"weather-card-content".
data-stateopen or closed, in a compact card.

WeatherCardCurrent

The weather now, a grid: the glyph, the temperature, then the condition over the range on the right. Drop any of them and the rest close up.

Data attributeDescription
data-slot"weather-card-current".

WeatherCardGlyph

The root's condition as a WeatherIcon: 44px in a full card, 28px in a compact one. Forwards icon props.

PropTypeDefaultDescription
conditionWeatherCondition-Overrides the root's condition.
nightboolean-Overrides the root's night.
Data attributeDescription
data-slot"weather-card-glyph".

WeatherCardTemperature

The hero number, 48px semibold in tabular-nums (20px in a compact card), its degree sign set lighter and tucked in. Rounds, writes a true minus, and rolls its digits when the value changes. Reads "21 degrees Celsius".

PropTypeDefaultDescription
value*number-The temperature, in the card's unit.
Data attributeDescription
data-slot"weather-card-temperature".

WeatherCardCondition

The sky in words, a <span>, worded from the root's condition ("Partly cloudy").

PropTypeDefaultDescription
conditionWeatherCondition-Overrides the root's condition.
nightboolean-Overrides the root's night.
childrenReact.ReactNode-Your own wording, such as "Light rain".
Data attributeDescription
data-slot"weather-card-condition".

WeatherCardRange

The day's high and low, "H 24° L 16°", read as "High 24 degrees, Low 16 degrees".

PropTypeDefaultDescription
high*number-The high.
low*number-The low.
highLabelstring"H"The visible mark before the high.
lowLabelstring"L"The visible mark before the low.
Data attributeDescription
data-slot"weather-card-range".

WeatherCardStats

The details, a <dl> under a hairline: two columns, four once the card is 448px wide.

Data attributeDescription
data-slot"weather-card-stats".

WeatherCardStat

One detail: a muted label with an optional glyph over the value. A <dt> and <dd> in a <div>.

PropTypeDefaultDescription
label*React.ReactNode-What it measures: "Feels like", "Wind".
iconReact.ReactNode-A 14px glyph before the label.
children*React.ReactNode-The value, formatted: "14 km/h NW".
Data attributeDescription
data-slot"weather-card-stat".

WeatherCardHourly

The next hours, a <section> holding a horizontal strip that runs to the card's edges, scrolls, snaps hour by hour and fades at the edge with more to see. The strip takes focus, so the arrow keys scroll it.

PropTypeDefaultDescription
labelReact.ReactNode-A small caption above the strip. Without it the section is named "Hourly forecast".
Data attributeDescription
data-slot"weather-card-hourly"; the scroller is "weather-card-hourly-viewport".

WeatherCardHour

One hour: the time, the glyph, the temperature and, when there is one, the chance of rain in the info hue. A role="listitem".

PropTypeDefaultDescription
time*React.ReactNode-"Now", "3 PM". Pass formatted text.
temperature*number-The temperature that hour.
condition*WeatherCondition-The sky that hour.
nightbooleanfalseDraws the night glyph.
precipitationnumber-The chance of rain, 0 to 100. Hidden at 0.
Data attributeDescription
data-slot"weather-card-hour".

WeatherCardDaily

The days ahead, a <section> of rows. It reads every day's low and high to set one scale for the week, so each range bar sits where its day falls between the coldest night and the warmest afternoon. Days must be direct children.

PropTypeDefaultDescription
labelReact.ReactNode-A small caption above the rows. Without it the section is named "Daily forecast".
minnumber-Overrides the bottom of the scale.
maxnumber-Overrides the top of the scale.
Data attributeDescription
data-slot"weather-card-daily".

WeatherCardDay

One day: the name, the glyph, the chance of rain, the low, the range bar and the high. The bar's hue follows the day's mean: cold, mild, warm or hot.

PropTypeDefaultDescription
day*React.ReactNode-"Today", "Fri". Pass formatted text.
low*number-The low.
high*number-The high.
condition*WeatherCondition-The day's sky.
nightbooleanfalseDraws the night glyph.
precipitationnumber-The chance of rain, 0 to 100. Hidden at 0.
currentnumber-Today's temperature now, marked as a dot on the bar.
Data attributeDescription
data-slot"weather-card-day"; the bar is "weather-card-day-bar".

WeatherCardSkeleton

Holds a forecast's place while it streams in, in the same frame, hidden from assistive tech.

PropTypeDefaultDescription
layout"full" | "compact""full"Which card it stands in for.
Data attributeDescription
data-slot"weather-card-skeleton".

WeatherIcon

The condition-to-glyph map on its own, for a forecast outside the card. Day and night glyphs from Koala Icons. WEATHER_CONDITIONS exposes the map and its wording, weatherConditionLabel the wording alone.

PropTypeDefaultDescription
condition*WeatherCondition-clear, partly-cloudy, cloudy, rain, drizzle, storm, snow, fog or wind.
nightbooleanfalseThe night glyph, where the sky has one.

FAQ#

From your tool call. The card draws what it is given: numbers for temperatures, a condition for the sky, and formatted text for times and days. Map your provider's codes (Open-Meteo, OpenWeather, Apple WeatherKit) to the nine conditions once, in the tool that fetches the forecast.