astro-components
4
总安装量
4
周安装量
#48868
全站排名
安装命令
npx skills add https://github.com/soborbo/claudeskills --skill astro-components
Agent 安装分布
github-copilot
4
opencode
3
codex
3
kimi-cli
3
gemini-cli
3
amp
3
Skill 文档
Astro Components Skill
Purpose
Provides reusable UI components. Does NOT handle sections, layouts, or business logic.
Scope
| â Use For | â NOT For |
|---|---|
| Marketing sites | Web apps |
| Lead gen pages | Dashboards |
| Service websites | E-commerce carts |
Core Rules
- All styling via design-tokens â No hardcoded colors/spacing
- Token missing = build error â Never fallback to arbitrary values
- Mobile-first â Base styles for mobile,
md:for larger - 44px minimum touch targets â All interactive elements
- Zero external dependencies â Pure Astro + Tailwind only
Semantic HTML Rules
| Element | Use | Never |
|---|---|---|
<button> |
Actions, toggles | <div onclick> |
<a> |
Navigation | <span onclick> |
<input> |
Form data | Contenteditable div |
Rule: If it does something â <button>. If it goes somewhere â <a>.
Component Variants
Fixed variants only. Claude cannot invent new variants.
| Component | Allowed Variants |
|---|---|
| Button | primary, secondary, outline, ghost |
| Card | default, elevated, outlined |
| Badge | default, success, warning, error, info |
| Alert | info, success, warning, error |
New variant needed? â Update this skill first, then use.
Props Pattern (All Components)
interface Props {
variant?: 'primary' | 'secondary'; // Explicit union, no string
size?: 'sm' | 'md' | 'lg'; // Fixed sizes only
class?: string; // Allow extension
// ... component-specific
}
const { variant = 'primary', size = 'md' } = Astro.props;
JavaScript Rules
| Allowed | Forbidden |
|---|---|
client:visible islands |
Inline onclick |
| Astro actions | <script> in component |
Separate .ts files |
Any DOM manipulation |
Exception: None. If JS needed, use island architecture.
Icon Handling
// If icon name not found â render nothing + console.warn
const path = icons[name];
if (!path) {
console.warn(`Icon "${name}" not found`);
return null;
}
No silent failures. Missing icon = visible warning in dev.
Form Components
| Rule | Requirement |
|---|---|
| Label | Always visible, linked via for |
| Placeholder | Hint only, never replaces label |
| Error | Below input, role="alert" |
| Required | Visual indicator (*) + required attr |
Component Boundaries
Components must NOT:
- Fetch data
- Format/transform data
- Access global state
- Import other components (except Icon)
- Contain business logic
Rule: Component receives props â renders UI. Nothing else.
File Structure
src/components/ui/
âââ Button.astro
âââ Input.astro
âââ Card.astro
âââ Badge.astro
âââ Alert.astro
âââ Icon.astro
âââ index.ts
Forbidden
- â External UI libraries
- â Hardcoded colors/spacing
- â Touch targets under 44px
- â Missing focus states
- â Inline JavaScript
- â Inventing new variants
- â Silent failures
References
- button.md â Button component code
- input.md â Input component code
- card.md â Card component code
- icon.md â Icon component + full icon list
Definition of Done
- Uses design-tokens only
- All interactive: focus states + 44px touch
- TypeScript Props interface
- No inline JavaScript
- Tested on mobile 375px