Weather

A forecast for one place, with current conditions, alerts, hourly and daily outlooks, and the agent's answer.

Experience · Shares patterns with Chart, Timeline

≈ 2,354 tokens per use (tool 1,231 · guidance 211 · typical payload 912)How token costs are estimated

Example: Weather

Will it rain in Lisbon this weekend?

Lisbon, Portugal

Updated 9:40 AM GMT+1Example Weather Service (opens in a new tab)

Temperature unit

19 °C

Partly cloudy

High 22 °C, low 15 °C today

Wind
14 km/h from the northwest
Chance of precipitation
5%
Humidity
68%
UV index
4
Sunrise
7:37 AM
Sunset
7:07 PM

Dry Saturday. Rain Sunday after 2 PM.

Hourly forecast

  1. 10 AM: Partly cloudy, 19 °C
  2. 11 AM: Partly cloudy, 20 °C
  3. 12 PM: Clear, 21 °C
  4. 1 PM: Clear, 22 °C
  5. 2 PM: Clear, 22 °C
  6. 3 PM: Clear, 22 °C
  7. 4 PM: Partly cloudy, 21 °C
  8. 5 PM: Partly cloudy, 20 °C
  9. 6 PM: Partly cloudy, 19 °C
  10. 7 PM: Clear, 18 °C
  11. 8 PM: Clear, 17 °C
  12. 9 PM: Clear, 17 °C
  13. 10 PM: Clear, 16 °C
  14. 11 PM: Partly cloudy, 16 °C
  15. 12 AM: Partly cloudy, 15 °C
  16. 1 AM: Cloudy, 15 °C, 10% chance of precipitation
  17. 2 AM: Cloudy, 15 °C, 10% chance of precipitation
  18. 3 AM: Cloudy, 15 °C, 20% chance of precipitation
  19. 4 AM: Cloudy, 14 °C, 20% chance of precipitation
  20. 5 AM: Cloudy, 14 °C, 10% chance of precipitation
  21. 6 AM: Partly cloudy, 15 °C
  22. 7 AM: Partly cloudy, 15 °C
  23. 8 AM: Partly cloudy, 16 °C
  24. 9 AM: Partly cloudy, 17 °C

5-day forecast

  1. Today: Partly cloudy, low 15 °C, high 22 °C, 5% chance of precipitation, sunrise 7:37 AM, sunset 7:07 PM
  2. Friday: Cloudy, low 14 °C, high 21 °C, 20% chance of precipitation, sunrise 7:38 AM, sunset 7:05 PM
  3. Saturday: Clear, low 15 °C, high 23 °C, 5% chance of precipitation, sunrise 7:39 AM, sunset 7:04 PM
  4. Sunday: Rain, low 16 °C, high 19 °C, 80% chance of precipitation, sunrise 7:40 AM, sunset 7:02 PM
  5. Monday: Drizzle, low 14 °C, high 18 °C, 50% chance of precipitation, sunrise 7:41 AM, sunset 7:01 PM

When to use

  • The user asks about the weather somewhere, or is planning around it: a trip, an event, packing, a drive.
  • A weather tool returned the forecast for that place.

When not to use

  • You don't have a forecast from a tool. Never invent or recall readings.
  • Weather is incidental and one sentence answers it.
  • The user compares many places at once. Use a Data Table.

How the agent should use it

  • Copy readings from the tool result unchanged, in the units it returned. Set units to match.
  • Put the answer to the question in highlight.note, in one short sentence (about ten words), and set highlight.date to the day it's about. That day's row is marked.
  • Include hourly when today or tonight matters, and daily when the question spans days.
  • Include alerts only when the tool returned official ones. Never write your own.

Interaction

  • °C / °F. The toggle converts every temperature locally, starting from the payload's units. Wind speed stays in the payload's units (km/h or mph).
  • Hourly strip. It scrolls sideways with snap points, and it's focusable so the arrow keys scroll it. Precipitation shows when the chance is 20% or more.
  • Daily rows. Each bar sits on one scale from the coolest low to the warmest high across the days shown, so days compare at a glance. All days are shown.

Layout

The current temperature is the focal number, with the condition and the agent's answer (highlight.note) beside and below it. Only wind and the chance of precipitation are shown from the current details; humidity, UV index, sunrise and sunset are read to screen readers. "Feels like" appears only when it differs from the temperature by 2° or more. The header's one quiet line carries the update time and the source. Alerts, the hourly strip and the daily rows follow, separated by space rather than rules.

Accessibility

Times use the location's time zone, not the viewer's. Icons are decorative; each hour and day has a visually hidden sentence with the condition, temperatures with their unit, precipitation, and sunrise and sunset. The detail row's labels are visually hidden and read in full ("Wind", "Chance of precipitation"), and wind direction is read as "from the northeast". Alert severity is shown by icon shape as well as color, and written out for screen readers.

Installation

npx shadcn@latest add https://your-site.com/r/weather.json

Usage

The Weather card is display-only, so the tool can return immediately:

app/api/chat/route.ts
import { tool } from "ai"
import { weatherTool } from "@/components/genui/weather.schema"

const tools = {
  [weatherTool.name]: tool({
    description: weatherTool.description,
    inputSchema: weatherTool.inputSchema,
    execute: async () => ({ shown: true }),
  }),
}

Render it through the Renderer under show_weather, or directly:

<Weather {...part.input} status={part.state === "input-streaming" ? "streaming" : "ready"} />

While streaming, current conditions render first, then hours, then days, with placeholders for what hasn't arrived.

With LangGraph

Push it from a graph node with ui.push({ name: "show_weather", props }, { message }), and render the thread's UI messages with the Renderer.

Schema

PropTypeNotes
location{ name, region? }Data-bound
asOfstringData-bound. ISO date-time of the observation
timezonestringIANA time zone of the location
units"metric" | "imperial"Units of every temperature and wind speed
current{ temp, feelsLike, condition, isDay, humidity?, windSpeed?, windDir?, precipChance?, uvIndex? }Data-bound. windDir is the direction the wind blows from, in degrees
alerts{ severity, title, starts, ends, description? }[]?Data-bound. Up to 3. severity: advisory, watch or warning
highlight{ date?, note }?The agent's one-sentence answer
hourly{ t, temp, condition, isDay?, precipChance? }[]?Data-bound. Up to 24 hours
daily{ date, min, max, condition, precipChance?, sunrise?, sunset? }[]?Data-bound. Up to 10 days
source{ label, url? }Data-bound. Linked when the URL is http(s)

condition is one of clear, partly-cloudy, cloudy, fog, drizzle, rain, heavy-rain, thunderstorm, snow, sleet or wind.

Host props: status (streaming or ready) and className.

Source

On this page