Skip to content
VenusUI
Get started

Weather Widget

A weather widget with a live sky: turning sun rays, drifting clouds, falling rain or snow, and twinkling stars.

Preview

Installation

npx shadcn@latest add @venusui/weather-widget

Run this in a project set up with shadcn. If you haven’t set it up yet, run npx shadcn@latest init first.

Files added to your project

Paths use the default shadcn aliases. The CLI follows the aliases in your components.json.

  • @/components/ui/weather-widget.tsx

Usage

The code behind the preview above.

weather-widget-demo.tsx

"use client"

import * as React from "react"

import { WeatherWidget, type WeatherCondition } from "@/components/ui/weather-widget"
import { cn } from "@/lib/utils"

const SCENES: { condition: WeatherCondition; label: string; temperature: number; high: number; low: number; summary: string }[] = [
  { condition: "sunny", label: "Sunny", temperature: 24, high: 27, low: 17, summary: "Sunny and warm" },
  { condition: "cloudy", label: "Cloudy", temperature: 19, high: 21, low: 15, summary: "Mostly cloudy" },
  { condition: "rain", label: "Rain", temperature: 14, high: 16, low: 11, summary: "Light rain all afternoon" },
  { condition: "snow", label: "Snow", temperature: -2, high: 0, low: -5, summary: "Snow showers" },
  { condition: "night", label: "Night", temperature: 12, high: 22, low: 11, summary: "Clear night" },
]

export default function WeatherWidgetDemo() {
  const [index, setIndex] = React.useState(2)
  const scene = SCENES[index]

  return (
    <div className="flex w-[min(22rem,calc(100vw-3rem))] flex-col items-center gap-5">
      <WeatherWidget
        city="Lisbon"
        condition={scene.condition}
        temperature={scene.temperature}
        high={scene.high}
        low={scene.low}
        summary={scene.summary}
        forecast={[
          { day: "Tue", condition: "rain", high: 16, low: 11 },
          { day: "Wed", condition: "cloudy", high: 19, low: 13 },
          { day: "Thu", condition: "sunny", high: 23, low: 15 },
          { day: "Fri", condition: "sunny", high: 25, low: 16 },
          { day: "Sat", condition: "cloudy", high: 21, low: 14 },
        ]}
      />
      <div role="group" aria-label="Weather" className="flex flex-wrap justify-center gap-0.5 rounded-lg border p-0.5 text-xs">
        {SCENES.map((s, i) => (
          <button
            key={s.condition}
            type="button"
            aria-pressed={index === i}
            onClick={() => setIndex(i)}
            className={cn("rounded-md px-2.5 py-1", index === i ? "bg-muted font-medium" : "text-muted-foreground hover:text-foreground")}
          >
            {s.label}
          </button>
        ))}
      </div>
    </div>
  )
}

API reference

PropTypeDefaultDescription
citystring—Shown at the top and in the section's label.
condition"sunny" | "cloudy" | "rain" | "snow" | "night"—Sets the sky and the animation.
temperature, high, lownumber—In whatever unit you use.
summarystring—Short description; defaults to the condition's name.
forecast{ day; condition; high; low }[]—Up to five days, shown on frosted glass.

All <section> props.

Requirements

  • lucide-react for the forecast icons. React 19 and Tailwind CSS v4. The CLI adds the weather-drift and weather-fall keyframes.

Customization

  • Map your weather API's codes to the five conditions. Rain and snow positions are fixed per drop, so the server and browser render the same scene.

Accessibility

  • A labelled section (“Weather in Lisbon”); the sky is decorative and the forecast icons have text names.
  • With reduced motion the scene is still.

Troubleshooting

Rain or clouds don't move.
Check that the weather-* keyframes are in your CSS; the CLI adds them.
Unknown registry "@venusui"
Your shadcn CLI couldn’t find the namespace in the shadcn registry index. Use the latest CLI (npx shadcn@latest), install by URL, or register it with its address: npx shadcn@latest registry add @venusui=https://venusui.com/r/{name}.json.
No components.json found
Run npx shadcn@latest init in your project first.
Loading preview

Notification Stack

Data display

Phone-style stacked notifications with frosted glass that fan out into a list on hover or click.

Loading preview

Receipt Printer

Animations

A receipt that prints out of a slot line by line, with itemized totals and a torn zig-zag edge.

Loading preview

Terminal

Data display

A terminal window that types commands and prints their output when it scrolls into view.