},
]}
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:
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`.
---
## 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. **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.
13. **TypeScript**: always import types from the package root, not from internal files.
14. **Controlled vs uncontrolled**: `Switch`/`Input` support both. If you pass `checked`/`value`, you must also pass `onChange`.
15. **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`.
16. **Never use `style={{ borderRadius: 0 }}` or force sharp corners on any interactive element** — it breaks the design language.
17. **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)
- `README.md` — project overview & screenshots
- `dist/types/index.d.ts` — machine-readable TypeScript types
Repo-only (NOT published to npm — read on GitHub):
- `skill/SKILL.md` — exhaustive style spec, every hex / px / keyframe
- `DESIGN_PROMPT.md` — prompts for v0 / Figma AI / MJ / DALL-E
- GitHub: https://github.com/guokaigdg/animal-island-ui
---
## 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
);
}
```