搜索

PythonReactSEOPDF
GitHub Skill

create-component

Create CVA + DaisyUI components following Iridium patterns. Use when asked to create UI components, buttons, inputs, cards, modals, alerts, or any reusable UI element.

tech-with-seth☆ 1 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Create Component

When to Use

  • Creating new UI components (buttons, inputs, cards, modals)
  • Building form elements with labels and error states
  • User asks to "add a component" or "create a component"

Critical Rules

1. Always Import from CVA Config
// CORRECT
import type { VariantProps } from 'cva';
import { cva, cx } from '~/cva.config';

// WRONG
import { cva } from 'cva';  // Wrong package
import { cn } from '~/lib/utils';  // Wrong utility
2. className Last in cx()
className={cx(buttonVariants({ size, status }), className)}  // className always last

Quick Start

import type { VariantProps } from 'cva';
import { cva, cx } from '~/cva.config';

export const buttonVariants = cva({
    base: 'btn',
    variants: {
        status: {
            primary: 'btn-primary',
            secondary: 'btn-secondary',
        },
        size: {
            sm: 'btn-sm',
            md: 'btn-md',
            lg: 'btn-lg',
        },
    },
    defaultVariants: {
        status: 'primary',
        size: 'md',
    },
});

interface ButtonProps
    extends React.ButtonHTMLAttributes<HTMLButtonElement>,
        VariantProps<typeof buttonVariants> {
    loading?: boolean;
}

export function Button({ status, size, className, children, ...props }: ButtonProps) {
    return (
        <button className={cx(buttonVariants({ status, size }), className)} {...props}>
            {children}
        </button>
    );
}

Component Directories

Category Directory Examples
Actions app/components/actions/ Button
Data Display app/components/data-display/ Card, Badge
Data Input app/components/data-input/ TextInput, Select
Feedback app/components/feedback/ Alert, Modal
Layout app/components/layout/ Container

Checklist

  1. Create in appropriate category directory
  2. Define CVA variants with base, variants, defaultVariants
  3. Extend native HTML attributes in props interface
  4. Put className last in cx() call
  5. Add JSDoc with usage example

Templates

Full Reference

See .github/instructions/component-patterns.instructions.md and .github/instructions/cva.instructions.md for:

  • Form component patterns
  • Boolean variants
  • Compound variants
  • DaisyUI class reference

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!