Palette System
Traditional Chinese color system implementation with 660+ historical colors.
Table of Contents
Overview
hikari-palette provides:
- 660+ Colors - Complete traditional Chinese color definitions
- Type-Safe - Compile-time color value checking
- Utility Classes - Type-safe Tailwind-style utility class builder
- Theme Palettes - Pre-configured theme color schemes
- Opacity Support - Color transparency and blending
All color definitions feature:
- Cultural Heritage - Traditional Chinese color names
- Type Safety - Enum-based color definitions
- Hex Values - Standard hex color codes
- Categories - Organized by color families
Colors
Basic Usage
rust
1
2
3
4
5
6
7
8
9
10
use Color;
// Access colors using enum variants
let green = 苍翠;
let pink = 粉红;
let yellow = 姜黄;
println!; // #519A73
println!; // #FFB3A7
println!; // #FFC773
Available Color Categories
Green Series (绿色系)
rust
1
2
3
4
5
6
// Traditional green colors
苍翠 // 苍翠 #519A73 - Verdant green
Vermilion // 朱红 #FF4C00 - Bright red-orange
Crimson // 绯红 #FF3030 - Deep crimson
PeachBlossom // 桃红 #F6BEC8 - Peach pink
RoseRed // 玫瑰红 #C21F30 - Rose red
Blue Series (蓝色系)
rust
1
2
3
4
5
6
// Traditional blue colors
IndigoBlue // 靛蓝 #144A74 - Indigo blue
鷃蓝 // 鷃蓝 #144A74 - Indigo blue
Cyan // 青色 #00CED1 - Cyan
SkyBlue // 天蓝 #87CEEB - Sky blue
Turquoise // 绿松石 #40E0D0 - Turquoise
Yellow Series (黄色系)
rust
1
2
3
4
5
// Traditional yellow colors
姜黄 // 姜黄 #FFC773 - Gamboge yellow
姜黄 // 姜黄 #FFC773 - Light yellow
Golden // 金色 #FFD700 - Gold
Amber // 琥珀 #FFBF00 - Amber
Green Series (绿色系)
rust
1
2
3
4
5
// Traditional green colors
ScallionGreen // 葱倩 #4CAF50 - Scallion green
BambooGreen // 竹青 #789262 - Bamboo green
Jade // 玉色 #A0E6DA - Jade green
Emerald // 翡翠 #50C878 - Emerald green
Neutral Series (中性色系)
rust
1
2
3
4
5
// Traditional neutral colors
InkBlack // 墨色 #1A1A2E - Ink black
MoonWhite // 月白 #F5F5F5 - Moon white
LightGray // 缟色 #E0E0E0 - Light gray
AshGray // 灰色 #808080 - Ash gray
Color Properties
Each color provides:
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
let color = 粉红;
// Get hex value
let hex = color.hex; // "#FFB3A7"
// Get RGB values
let rgb = color.rgb; // (0, 160, 233)
// Get color name
let name = color.name; // "石青"
// Get English name
let english_name = color.english_name; // "Azurite"
ClassesBuilder
Type-safe utility class generator for Tailwind CSS-like classes.
Basic Usage
rust
1
2
3
4
5
6
7
8
9
use ;
let classes = new
.add
.add
.add
.build;
// Output: "hi-flex hi-flex-row hi-gap-4"
Available Utility Classes
Display Classes
rust
1
2
3
4
5
6
use Display;
Block // "hi-block"
Flex // "hi-flex"
Grid // "hi-grid"
Hidden // "hi-hidden"
Flexbox Classes
rust
1
2
3
4
5
6
7
8
use ;
Row // "hi-flex-row"
Column // "hi-flex-column"
Center // "hi-items-center"
Stretch // "hi-items-stretch"
Center // "hi-justify-center"
Between // "hi-justify-between"
Spacing Classes
rust
1
2
3
4
5
6
7
use ;
P4 // "hi-p-4"
Px8 // "hi-px-8"
M4 // "hi-m-4"
MyAuto // "hi-my-auto"
Gap4 // "hi-gap-4"
Color Classes
rust
1
2
3
4
5
6
use ;
Primary // "hi-text-primary"
Secondary // "hi-text-secondary"
Primary // "hi-bg-primary"
Surface // "hi-bg-surface"
Typography Classes
rust
1
2
3
4
5
6
7
use ;
Base // "hi-text-base"
XL // "hi-text-xl"
2XL // "hi-text-2xl"
Normal // "hi-font-normal"
Bold // "hi-font-bold"
Border Classes
rust
1
2
3
4
5
6
use ;
B // "hi-border"
B2 // "hi-border-2"
Md // "hi-rounded-md"
Full // "hi-rounded-full"
Combining Classes
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use ;
// Complex component styling
let button_classes = new
.add
.add
.add
.add
.add
.add
.add
.add
.build;
// Output: "hi-flex hi-items-center hi-justify-center hi-px-4 hi-py-2 hi-rounded-md hi-bg-primary hi-text-white"
Type Safety Benefits
rust
1
2
3
4
5
6
7
8
9
10
// Type-safe - compile-time checking
let classes = new
.add
.add
.build;
// no Would not compile - typo protection
let classes = new
.add // Compile error!
.build;
Themes
Pre-configured theme palettes.
Hikari Theme (Light)
rust
1
2
3
4
5
6
7
8
9
use themes;
let hikari = palette;
println!; // #FFB3A7
println!; // #519A73
println!; // #FFC773
println!; // #FFFFFF
println!; // #F5F5F5
Color Scheme:
- Primary: Azurite (石青) - Fresh cyan-blue
- Secondary: Cinnabar (朱砂) - Energetic red-orange
- Accent: Vine Yellow (藤黄) - Warm golden yellow
- Background: Moon White (月白) - Clean white
- Surface: Light gray with subtle tint
Tairitsu Theme (Dark)
rust
1
2
3
4
5
6
7
8
9
use themes;
let tairitsu = palette;
println!; // #144A74
println!; // #519A73
println!; // #FFC773
println!; // #161823
println!; // rgb(32,35,54)
Color Scheme:
- Primary: Indigo (靛蓝) - Deep indigo blue
- Secondary: Cinnabar (朱砂) - Energetic red-orange
- Accent: Goose Yellow (鹅黄) - Bright pale yellow
- Background: Deep dark gray
- Surface: Slightly lighter dark gray
Custom Theme
rust
1
2
3
4
5
6
7
8
9
10
11
12
use ;
let custom = ThemePalette ;
Theme Structure
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
Opacity & Blending
Color transparency and blending utilities.
Opacity Function
rust
1
2
3
4
5
6
use ;
let color = 粉红;
let semi_blue = opacity;
// Output: "rgba(0, 160, 233, 0.5)"
Blend Function
rust
1
2
3
4
5
6
7
use ;
let color1 = 粉红;
let color2 = 苍翠;
let blended = blend;
// Blends 50% of each color
Color Lightening
rust
1
2
3
4
5
6
use ;
let color = InkBlack;
let lighter = lighten;
// Lightens by 20%
Color Darkening
rust
1
2
3
4
5
6
use ;
let color = MoonWhite;
let darker = darken;
// Darkens by 30%
Integration Examples
With ThemeProvider
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use ThemeProvider;
use themes;
}
With Components
rust
1
2
3
4
5
6
7
8
9
10
use Button;
use Color;
rsx!
With Utility Classes
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use ;
let card_classes = new
.add
.add
.add
.add
.build;
rsx!
API Reference
Color
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
ClassesBuilder
rust
1
2
3
4
5
6
7
8
9
ThemePalette
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
Color Utilities
rust
1
2
3
4
;
;
;
;
Design Philosophy
Cultural Significance
Each traditional Chinese color carries cultural and historical meaning:
- Cinnabar (朱砂): Used in imperial seals, represents power and authority
- Azurite (石青): Used in traditional painting, represents elegance
- Vine Yellow (藤黄): Traditional painting pigment, warmth and vitality
- Ink Black (墨色): Calligraphy ink, represents knowledge and depth
- Moon White (月白): Pale blue-white, represents purity
Color Harmony
Traditional Chinese color combinations follow specific harmony rules:
- Complementary: Red + Green (朱砂 + 竹青)
- Analogous: Blue + Cyan (石青 + 青色)
- Triadic: Red + Yellow + Blue (朱砂 + 藤黄 + 石青)
Best Practices
1. Use Enum for Type Safety
rust
1
2
3
4
5
// Good - Type-safe
let color = 粉红;
// no Avoid - String-based
let color = "#FFB3A7";
2. Leverage Theme Palettes
rust
1
2
3
4
5
6
// Good - Use theme palette
let palette = palette;
let primary = palette.primary;
// no Avoid - Hardcoded colors
let primary = "#FFB3A7";
3. Use Utility Classes
rust
1
2
3
4
5
6
7
8
// Good - Type-safe utilities
let classes = new
.add
.add
.build;
// Acceptable - String-based (less type-safe)
let classes = "hi-flex hi-gap-4";
4. Semantic Color Naming
rust
1
2
3
4
5
6
7
// Good - Semantic usage
let button_color = theme.palette.primary;
let error_color = theme.palette.danger;
// no Avoid - Direct color references
let button_color = 粉红;
let error_color = 苍翠;
Related Systems
- Theme System - Theme context and CSS variables
- Components - Component library using palettes