Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

Theme Generation

The defining feature of Ginga UI is automatic theme generation powered by LLMs. Just enter a prompt, and AI generates CSS variables that restyle your entire site.

Live demo

Enter a prompt in the form below to try theme generation in real time. The "Free tier" works without an API key but is limited to 100 generations across all users in the last 24 hours. With "Your own API key", you can choose any provider and model. If you choose "Gemini Nano", no API key is needed and generation runs entirely in your browser.

Run with
Try it without an API key

Calls an OpenAI model with the API key registered on the server. Shared by all users, up to 100 times in the last 24 hours. Your prompt and the generated result are logged on the server.

Server-side usage

In production, we strongly recommend generating themes on the server. This keeps your API key private and also improves SEO and performance.

Setting environment variables

First, set the API key for your LLM provider as an environment variable.

.env.local
OPENAI_API_KEY=sk-...
# or
GOOGLE_GENERATIVE_AI_API_KEY=...
# or
ANTHROPIC_API_KEY=...

Example with the Next.js App Router

app/layout.tsx
import { ThemeClient } from "@ginga-ui/utils";

export default async function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const themeClient = new ThemeClient({
    provider: "openai",
  });

  const result = await themeClient.generateTheme(
    "Mysteries of the universe"
  );

  return (
    <html lang="en">
      <body>
        {result.type === "success" && <style>{result.CSSCode}</style>}
        {children}
      </body>
    </html>
  );
}

In-browser usage

Specifying provider: "browser" generates themes with Gemini Nano, built into Chrome and Edge. No API key or server requests are needed, and generation runs entirely on the device. Only in this case, call it from a Client Component rather than a Server Component, since it works only in the browser.

Use getBrowserAIAvailability() to check whether it is available. It returns "unavailable", "downloadable", "downloading", or "available". In unsupported environments, fall back to a cloud provider. The first use downloads several gigabytes of model data, so we recommend showing progress with onDownloadProgress.

components/browser-theme-button.tsx
"use client";

import { getBrowserAIAvailability, ThemeClient } from "@ginga-ui/utils";
import { useState } from "react";

export function BrowserThemeButton() {
  const [css, setCss] = useState("");

  const generate = async () => {
    const availability = await getBrowserAIAvailability();

    if (availability === "unavailable") {
      return;
    }

    const themeClient = new ThemeClient({ provider: "browser" });

    const result = await themeClient.generateTheme("Stillness of the deep sea", {
      onDownloadProgress: (progress) => {
        console.log(`Downloading: ${Math.round(progress * 100)}%`);
      },
    });

    if (result.type === "success") {
      setCss(result.CSSCode);
    }
  };

  return (
    <>
      <button onClick={generate}>Generate theme</button>
      <style>{css}</style>
    </>
  );
}

Supported LLM providers

ThemeClient supports three cloud LLM providers and Gemini Nano built into the browser. Specify the provider with provider and any model with model. If you omit model, the provider's default model is used.

OpenAI

  • gpt-6-luna (default)
  • gpt-6.1-sol
  • gpt-6-astra

Google Gemini

  • gemini-3.8-flash (default)
  • gemini-3.5-flash-lite
  • gemini-4-argon

Anthropic Claude

  • claude-haiku-5-5 (default)
  • claude-sonnet-5-5
  • claude-opus-5-5

Gemini Nano

  • gemini-nano

No API key is required, and it runs in the browser. You don't need to specify model.

Generated CSS variables

ThemeClient generates the following CSS variables. Each generated value is checked for format and range, and invalid values fall back to the defaults. The text color is adjusted to at least 4.5:1 and the accent color to at least 3:1 against the background by changing only their lightness.

VariableDescription
--color-primaryAccent color
--color-secondaryText color
--color-backgroundBackground color
--width-borderBorder width
--size-radiusBorder radius
--font-familyFont family

In addition, a 0-9 color scale, including intermediate colors blended with the background color, is generated automatically for the primary and secondary colors.