Caroa UI

カラーシステム

Caroa UIのカラートークンと使い方

概要

Caroa UIは一貫したカラーシステムを提供しています。すべてのカラーはCSS変数(--caroa-color-*)として定義されており、Tailwind CSSクラスから利用できます。

カラーパレット一覧

Black(黒)

Loading...

White(白)

Loading...

Sand(サンド)

Loading...

Ash(アッシュ)

Loading...

Fog(フォグ)

Loading...

Orange(オレンジ) - ブランドカラー

Loading...

Blue(ブルー)

Loading...

Purple(パープル)

Loading...

Turquoise(ターコイズ)

Loading...

Green(グリーン)

Loading...

Red(レッド)

Loading...

Yellow(イエロー)

Loading...

セマンティックカラー

セマンティックカラーは「意味」に基づいた色の定義です。生のカラートークン(orange-baseなど)を直接使わず、セマンティックカラー(primaryなど)を使うことで、テーマ変更や一括修正が容易になります。

基本原則

// ✅ 推奨: セマンティックカラーを使う
<Button variant="primary">購入する</Button>
<div className="bg-background">...</div>
 
// ❌ 非推奨: 生のカラートークンを直接使う
<div className="bg-orange-base">...</div>

背景・テキスト系

ページ全体やコンテナの背景色に使います。

Loading...

アクション系

ボタンやインタラクティブ要素に使います。

Loading...

💡 accent と accent-action について

一般的なデザイン理論では「accent = 目立つ差し色」ですが、Caroa UIでは「温かみのある控えめな背景色」として定義しています。

accent (sand-light)

  • 静的な背景色として使用
  • ページ全体の背景、セクション背景、カードの背景など
  • 落ち着いた雰囲気を演出し、白一色より温かみのある印象を与える

accent-action (sand-base)

  • ユーザー操作に反応するインタラクティブな状態で使用
  • ホバー時、選択状態、アクティブ状態、フォーカス状態など
  • accentより少し濃い色で、操作可能であることや現在の状態を視覚的にフィードバック
// ページ背景(静的)
<main className="bg-accent">
 
// ホバー時の背景変化
<button className="hover:bg-accent-action">
 
// 選択状態の背景
<div className={cn(selected && "bg-accent-action")}>
 
// テーブル行のホバー
<tr className="hover:bg-accent-action">
 
// サイドバーのアクティブ項目
<SidebarItem className={cn(isActive && "bg-accent-action")}>

状態・フィードバック系

ユーザーへのフィードバックや状態表示に使います。

Loading...

destructive と error の使い分け

destructiveerror は同じ色(red-base)ですが、意味的に使い分けることで、コードの意図が明確になります。

// ✅ 破壊的アクション → destructive
<Button variant="destructive">削除する</Button>
<Button variant="destructive">アカウントを完全に削除</Button>
 
// ✅ エラー状態 → error
<span className="text-error">入力値が不正です</span>
<div className="border-error bg-error-light">エラーメッセージ</div>
<Input className="border-error" aria-invalid="true" />
用途使用するトークン
削除ボタンdestructive<Button variant="destructive">
取り消せない操作destructive「完全に削除」ボタン
バリデーションエラーerrortext-error, border-error
フォームエラーメッセージerror<FieldError>, text-error
エラートーストerrortoast.error()

状態色の使用例

Loading...

ボーダー・入力系

境界線やフォーム要素に使います。

Loading...

リンク・サイドバー系

Loading...

セマンティックカラー一覧(まとめ)

セマンティック実際の色Tailwindクラス用途
backgroundwhitebg-backgroundページ背景
foregroundblack-basetext-foregroundメインテキスト
cardwhitebg-cardカード背景
popoverwhitebg-popoverポップオーバー背景
primaryorange-basebg-primaryブランド、CTA
baseblack-basebg-base通常のUI
secondarysand-basebg-secondaryサブ要素
accentsand-lightbg-accent温かみのある背景色。ページ背景やセクション背景など、落ち着いた雰囲気を演出する
accent-actionsand-basebg-accent-actionインタラクティブ状態の背景。ホバー、選択状態、アクティブ状態など、ユーザー操作に反応する要素に使用
mutedash-lightbg-muted無効、補足
destructivered-basebg-destructive破壊的アクション(削除ボタンなど)
errorred-basetext-errorエラー状態(destructiveのエイリアス)
successgreen-basebg-success成功、完了
warningyellow-basebg-warning警告、注意
infoblue-basebg-info情報、ヒント
borderash-lightborder-borderボーダー
border-mutedash-light / 0.8border-border-muted薄めのボーダー
inputash-lightborder-input入力ボーダー
ringfog-darkring-ringフォーカスリング
linkblue-darktext-linkリンク
sidebarwhitebg-sidebarサイドバー背景
sidebar-accentsand-lightbg-sidebar-accentサイドバーハイライト

コンポーネントでの使い方

Buttonのカラーバリアント

Loading...
<Button>Base (Default)</Button>
<Button variant="primary">Primary</Button>
<Button variant="success">Success</Button>
<Button variant="warning">Warning</Button>
<Button variant="destructive">Destructive</Button>

Tailwind CSSでの使い方

{/* 背景色 */}
<div className="bg-orange-base">ブランドカラー背景</div>
<div className="bg-destructive-light">エラー背景(薄い)</div>
 
{/* テキスト色 */}
<p className="text-blue-base">青いテキスト</p>
<p className="text-destructive">エラーテキスト</p>
 
{/* ボーダー */}
<div className="border border-ash-base">グレーボーダー</div>
<div className="border border-destructive/20">エラーボーダー(透明度20%)</div>

CSS変数

すべてのカラートークンは--caroa-color-*形式のCSS変数として利用可能です。

/* プロジェクト固有のカスタマイズ */
:root {
  /* セマンティックカラーの上書き */
  --caroa-primary: var(--caroa-color-blue-base);
  --caroa-destructive: var(--caroa-color-red-base);
 
  /* 独自のカラー追加 */
  --brand-gradient: linear-gradient(
    to right,
    hsl(var(--caroa-color-orange-base)),
    hsl(var(--caroa-color-orange-bright))
  );
}

useAutoThemeフック

テーマカラーを動的に変更するためのフックです。

import { useAutoTheme } from '@caroainc/ui-components'
 
function App() {
  useAutoTheme({
    primary: 'blue-base',      // プライマリカラー
    base: 'black-base',        // ベースカラー
    secondary: 'sand-base',    // セカンダリカラー
    accent: 'sand-light',      // アクセントカラー
    borderRadius: '0.5rem',    // 角丸
  })
 
  return <YourApp />
}