• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLKnowledge Workdeployment

react-ui

プラグイン
Val Town
ソース
GitHub で見る ↗
説明

次のような場合に使用: ユーザーインターフェース(ユーザーが画面で見る操作部分)を含む値を構築する場合。ダッシュボード、ウェブアプリ、ランディングページ、フォーム、管理ツール、ブラウザに表示される任意のものが対象となります。 カバーする内容: - JSX/React の記述方法 - Twind/Tailwind のスタイリング手法 - React のバージョン固定方法 - ソースコード表示リンクの必須要件 - 避けるべき手法(テンプレート文字列による HTML 記述や外部リソースの読み込みなど)

原文を表示

Use when building any val with a user interface — dashboards, web apps, landing pages, forms, admin tools, anything users see in a browser. Covers JSX/React conventions, Twind/Tailwind styling, React version pinning, the view-source link requirement, and what to avoid (template-string HTML, external assets).

ユースケース
  • ユーザーインターフェースを構築するとき
  • ダッシュボードを作成するとき
  • ウェブアプリを開発するとき
  • フォームを実装するとき
  • ランディングページを構築するとき
本文(日本語訳)

React UI

UIを表示する値については、特に指示がなければ React コンポーネントを .tsx ファイルで構築してください。templates/react-hono-starter テンプレートはこれに対応しているため、最初から構築するのではなく remix_val でここから始めることをお勧めします。

ファイルの規則

マークアップ、スタイル、スクリプトは実ファイルに記述し、テンプレート文字列(例:new Response(\<html>...</html>`)`)は避けてください。テンプレート文字列内のコードはシンタックスハイライト(構文の色分け)、リント(文法チェック)、型チェック、レビューに対応していません。

  • .tsx — React/JSX コンポーネント、ロジックやインタラクティブ機能を含む UI
  • .html — 静的なマークアップのみ
  • .ts — サーバーコードとスクリプト

UIは .tsx ファイルでコンポーネント単位で構築してください。1つの大きなページを描画するのではなく、小さなコンポーネントを組み合わせます。

スタイリング:Twind + Tailwind

実行時に Tailwind ユーティリティクラスを適用できる Twind(ビルドステップが不要)を優先してください。HTML の基本テンプレートにスクリプトを追加します:

<script src="https://cdn.twind.style" crossorigin></script>

その後、JSX 内で Tailwind クラスを直接使用します:

<div className="flex items-center gap-4 p-6 rounded-lg bg-white shadow">
  <h1 className="text-2xl font-bold">Hello</h1>
</div>

ユーザーが別の方法を指示しない限り、インラインの <style> タグ、CSS-in-JS オブジェクト、別の .css ファイルは避けてください。

アセット(リソース)の配信:バージョン管理と不変キャッシュ

std/utils の serveImmutableFile を使ってクライアント用のモジュールを配信してください。ブラウザはこれらを永続的にキャッシュし、値を公開するときにバージョンがアップデートされると自動的に無効化されます(詳しくは client-side-js スキルのパターンを参照)。キャッシュされない frontend/root.tsx シェル(hono/jsx)は immutableFileUrl でエントリーポイントとファビコンをスタンプします:

// frontend/root.tsx — Root() HTML シェル内:
<script src={immutableFileUrl("/frontend/index.tsx")} type="module" />

// index.ts:
app.get("/", (c) => c.html(Root()));
app.get("/__immutable/*", (c) => serveImmutableFile(c.req.path));

ソースコード表示リンク

すべての UI 値は、ユーザーがそのソースコードを確認したり、改造版を作成(remix)したりできるようにする必要があります。以下の 2 つの部分が必須です:

  1. バックエンドのルート:
    import { parseVal } from "https://esm.town/v/std/utils/index.ts";
    app.get("/source", (c) => c.redirect(parseVal().links.self.val));
    
  2. フロントエンドの表示されるリンク:
    <a href="/source">view source</a>
    

React バージョンの固定

よくあるエラー「Cannot read properties of null (reading 'useState')」は、React の依存パッケージが異なるバージョンを読み込んでいることを意味します。React 関連のインポートはすべてバージョン 18.2.0 に固定してください:

import SomeLib from "https://esm.sh/some-lib?deps=react@18.2.0,react-dom@18.2.0";

アセット(リソース)

破損する可能性がある外部画像やホストされたアセットは使用しないでください。以下を優先してください:

  • 絵文字または Unicode 記号
  • インライン SVG
  • CDN 経由のアイコンフォント(Lucide、Font Awesome など)

クライアント側エラーの記録

ブラウザのエラーを値のログに送信する(get_logs で表示可能)には、HTML シェルに以下のスクリプトを含めてください:

<script src="https://esm.town/v/std/catch"></script>

変更の確認

UI 値を編集したら、fetch_val_endpoint を実行してページがエラーなく描画されることを確認し、その後 get_logs でクライアント側のエラーがないかチェックしてください。この両方を確認してから、変更が完了したと報告してください。

原文(English)を表示

React UI

For any val that renders a UI, prefer to build it with React components in .tsx files, unless the user states otherwise. The templates/react-hono-starter template is set up for this — start there with remix_val instead of building from scratch.

File conventions

Put markup, styles, and scripts in real files — avoid template literal strings (e.g. new Response(\<html>...</html>`)`). Code in template strings has no syntax highlighting, no linting, no type checking, and is unreviewable.

  • .tsx — React/JSX components, any UI with logic or interactivity
  • .html — purely static markup
  • .ts — server code and scripts

Build UI component by component in .tsx files. Compose small components rather than rendering one giant page.

Styling: Twind + Tailwind

Prefer Twind to apply Tailwind utility classes at runtime — no build step required. Add the script to your HTML shell:

<script src="https://cdn.twind.style" crossorigin></script>

Then use Tailwind classes directly in JSX:

<div className="flex items-center gap-4 p-6 rounded-lg bg-white shadow">
  <h1 className="text-2xl font-bold">Hello</h1>
</div>

Avoid inline <style> tags, CSS-in-JS objects, or separate .css files, unless the user says otherwise.

Serving assets: versioned + immutable

Serve client modules with serveImmutableFile from std/utils — browsers cache them immutably, and publishing bumps the val's version, which invalidates automatically (full pattern: the client-side-js skill). A never-cached frontend/root.tsx shell (hono/jsx) stamps the entry and favicon with immutableFileUrl:

// frontend/root.tsx — in the Root() HTML shell:
<script src={immutableFileUrl("/frontend/index.tsx")} type="module" />

// index.ts:
app.get("/", (c) => c.html(Root()));
app.get("/__immutable/*", (c) => serveImmutableFile(c.req.path));

View source link

Every UI val should expose a way for users to see and remix its source. Both parts are required:

  1. Backend route:
    import { parseVal } from "https://esm.town/v/std/utils/index.ts";
    app.get("/source", (c) => c.redirect(parseVal().links.self.val));
    
  2. Visible link in the frontend:
    <a href="/source">view source</a>
    

React version pinning

A common error — "Cannot read properties of null (reading 'useState')" — means a React sub-dependency is loading a different React version. Pin all React-related imports to 18.2.0:

import SomeLib from "https://esm.sh/some-lib?deps=react@18.2.0,react-dom@18.2.0";

Assets

Do not use external images or hosted assets that may break. Prefer:

  • Emojis or unicode symbols
  • Inline SVG
  • Icon fonts via CDN (Lucide, Font Awesome)

Surfacing client-side errors

To send browser errors back to val logs (visible via get_logs), include this script in your HTML shell:

<script src="https://esm.town/v/std/catch"></script>

Verifying changes

After editing a UI val, call fetch_val_endpoint to confirm the page renders without error, then check get_logs for any client-side errors. Don't report the change as done without both.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。