},
]}
defaultActiveKey="tab1"
/>
// Controlled mode
const [activeKey, setActiveKey] = useState('tab1');
```
> Supports both controlled and uncontrolled modes. Smooth fade animation on tab switch.
---
### 1.14 Icon
```ts
type IconName =
| 'icon-miles' | 'icon-camera' | 'icon-chat' | 'icon-critterpedia'
| 'icon-design' | 'icon-diy' | 'icon-helicopter'
| 'icon-map' | 'icon-shopping' | 'icon-variant';
interface IconProps {
name: IconName; // REQUIRED — one of the 10 built-in SVG icons
size?: number | string; // default 24 — applied to width & height
className?: string;
style?: React.CSSProperties;
bounce?: boolean; // default false — adds hover bounce animation
}
// Runtime catalogue for dynamic rendering / pickers (length = 10):
declare const ICON_LIST: { name: IconName; label: string }[];
```
```tsx
{ICON_LIST.map(({ name, label }) => )}
```
> Icons are rendered as `` with a background-image SVG. Use `size` (number=px, string=any CSS length) — do NOT wrap in a sized div.
---
### 1.15 Select
```ts
type SelectOption = { key: string; label: string };
interface SelectProps {
options: SelectOption[]; // REQUIRED
value: string; // REQUIRED — controlled-only
onChange: (key: string) => void; // REQUIRED
placeholder?: string; // default '请选择'
disabled?: boolean; // default false
}
```
```tsx
const [lang, setLang] = useState('zh');
```
Notes:
- **Controlled only.** `value` and `onChange` are required — there is no `defaultValue`.
- Dropdown auto-flips (top/bottom, left/right) based on viewport space.
- Click-outside to close is built-in.
- Does NOT accept `className` / `style` / custom `renderOption`; style via CSS targeting descendant `.wrapper`.
---
### 1.16 Checkbox
```ts
type CheckboxSize = 'small' | 'middle' | 'large';
interface CheckboxOption {
label: React.ReactNode;
value: string | number;
disabled?: boolean; // disable this option only
}
interface CheckboxProps {
options: CheckboxOption[]; // REQUIRED
value?: Array; // controlled
defaultValue?: Array; // default []
size?: CheckboxSize; // default 'middle'
disabled?: boolean; // default false — disables all
direction?: 'horizontal' | 'vertical'; // default 'horizontal'
onChange?: (values: Array) => void;
className?: string;
style?: React.CSSProperties;
}
```
```tsx
// Uncontrolled
// Controlled + vertical
const [values, setValues] = useState>([]);
// Numeric values also allowed (string | number)
```
> Group-level `disabled` disables every item. Per-option `disabled` disables a single row. Checked box fills with `#19c8b9`. No indeterminate state.
---
### 1.17 CodeBlock
```ts
interface CodeBlockProps {
code: string; // REQUIRED — raw source string
style?: React.CSSProperties; // merged on top of the dark preset
className?: string;
}
```
```tsx
Go`} />
// Override theme
```
> Renders a `
` with built-in JSX/TS tokenizer. No language prop — always treated as JSX/TS. Not intended for non-JS languages. Default theme: bg `#2b2118`, border `1px solid #3d3028`, radius 20px, font-size 14, line-height 1.7.
---
## 2. Common Recipes
### 2.1 Form row
```tsx
```
### 2.2 Confirm dialog
```tsx
{ remove(); close(); }}
footer={
<>
>
}
>
This cannot be undone.
```
### 2.3 FAQ page
```tsx
FAQ
{faqs.map(f => )}
```
### 2.4 Game-style intro
```tsx
Welcome to Animal Island! Press OK to begin.
```
---
## 3. HARD RULES for AI code generation
Follow these strictly; violations are bugs:
1. **Import style only once**: `import 'animal-island-ui/style';` at app entry. Do not re-import per component.
2. **Do NOT invent props.** Every prop used must appear verbatim in section 1. No `variant`, `shape`, `rounded`, `theme`, `color="primary"` etc. unless listed.
3. **`Modal.open` is required**; always provide a matching `onClose` or the dialog cannot be dismissed by user.
4. **`Collapse.question` and `Collapse.answer` are required.**
5. **Button `type`** values are `primary | default | dashed | text | link` — NOT `secondary`, `outline`, `ghost`. Use `ghost` prop for ghost styling.
6. **Switch `size`** is `'small' | 'default'` (NOT `'middle' | 'large'`). Diverges from Button/Input sizing.
7. **Card `color`** must be one of the 13 listed `CardColor` values. Do not pass hex codes. `type` is `'default' | 'title' | 'dashed'` — no other values.
8. **Divider / Footer / Phone / Time / Cursor** accept no style-modifying props beyond `className` (and `type` where listed). For custom color/size, wrap/override via CSS targeting `className`.
9. **Typewriter emits no wrapper element.** Do not rely on a DOM node to style it — style the children instead.
10. **Icon `name` must be one of the 10 `IconName` values.** Do not pass arbitrary strings, URLs, or React nodes — only the built-in catalogue is supported.
11. **Select is controlled-only.** `options`, `value`, `onChange` are ALL required. Never omit `onChange` or pass `defaultValue`.
12. **Checkbox `size`** is `'small' | 'middle' | 'large'` (aligned with Button/Input — NOT with Switch). `options` is required; values can be `string | number`. No indeterminate state.
13. **CodeBlock** only highlights JSX/TS — do not pass Python/SQL/shell expecting language-specific coloring. There is no `language` prop.
14. **Do NOT import from deep paths** (`animal-island-ui/lib/...`, `animal-island-ui/src/...`). Only the package root and `animal-island-ui/style` are public.
15. **TypeScript**: always import types from the package root, not from internal files.
16. **Controlled vs uncontrolled**: `Switch`/`Input`/`Checkbox` support both. If you pass `checked`/`value`, you must also pass `onChange`.
17. **Design tokens (colors, radii, shadows) are NOT exposed as CSS custom properties.** To match the design elsewhere, hard-code values from `SKILL.md` / `DESIGN_PROMPT.md`.
18. **Never use `style={{ borderRadius: 0 }}` or force sharp corners on any interactive element** — it breaks the design language.
19. **Never override the 3D bottom shadow on Button/Input/Switch** — it is the core identity.
---
## 4. Where to read more
Shipped inside the npm package (available under `node_modules/animal-island-ui/`):
- `AI_USAGE.md` — this file (AI-optimized API reference for all 17 components)
- `README.md` — project overview & screenshots
- `dist/types/index.d.ts` — machine-readable TypeScript types for every exported component / prop / enum
Repo-only (NOT published to npm — read on GitHub):
- `skill/SKILL.md` — exhaustive style spec, every hex / px / keyframe for each of the 17 components
- `DESIGN_PROMPT.md` — prompts for v0 / Figma AI / MJ / DALL-E
- GitHub: https://github.com/guokaigdg/animal-island-ui
**When to use which:** API shape / legal prop values → this file. Pixel-exact CSS (sizes, shadows, animations) → `SKILL.md`. Feeding another design AI → `DESIGN_PROMPT.md`.
---
## 5. Minimal boilerplate (copy-paste-ready)
```tsx
// main.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import 'animal-island-ui/style';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')!).render();
```
```tsx
// App.tsx
import { Cursor, Button, Card, Input, Footer } from 'animal-island-ui';
export default function App() {
return (
Animal Island
);
}
```