मुख्य सामग्री पर जाएँ
Skillpedia
इंटरफ़ेस (UI/UX)41k · #6809

web-component-design

यह क्या करती है

यह टूल वेबसाइट और ऐप के लिए बार-बार इस्तेमाल होने वाले और व्यवस्थित user interface components बनाने में मदद करता है। यह React, Vue और Svelte जैसी technologies का इस्तेमाल करके इन components को कुशलता और अच्छे डिज़ाइन के साथ बनाने के तरीके सिखाता है।

कब इस्तेमाल करें

  • ✓जब किसी प्रोजेक्ट के लिए visual components की library बना रहे हों।
  • ✓जब buttons, cards या दूसरे elements का रूप और व्यवहार डिज़ाइन करना हो।
  • ✓जब components पर styles (रंग, फ़ॉन्ट, आकार) लगाने का तरीका तय करना हो।

Skill का लिंक

https://github.com/wshobson/agents/blob/main/plugins/ui-design/skills/web-component-design/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/wshobson/agents/blob/main/plugins/ui-design/skills/web-component-design/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“React में एक reusable button कैसे बनाऊँ, जिसके अलग-अलग रंग हों और उसमें एक icon भी हो?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह टूल सिखाता है कि components को एक-दूसरे के साथ अच्छे से काम करने के लिए कैसे जोड़ा जाए, जैसे 'compound components' या 'slots'। यह styling के अलग-अलग तरीके भी दिखाता है, जैसे CSS-in-JS।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Web Component Design

Build reusable, maintainable UI components using modern frameworks with clean composition patterns and styling approaches.

When to Use This Skill

  • Designing reusable component libraries or design systems
  • Implementing complex component composition patterns
  • Choosing and applying CSS-in-JS solutions
  • Building accessible, responsive UI components
  • Creating consistent component APIs across a codebase
  • Refactoring legacy components into modern patterns
  • Implementing compound components or render props

Core Concepts

1. Component Composition Patterns

Compound Components: Related components that work together

// Usage
<Select value={value} onChange={setValue}>
  <Select.Trigger>Choose option</Select.Trigger>
  <Select.Options>
    <Select.Option value="a">Option A</Select.Option>
    <Select.Option value="b">Option B</Select.Option>
  </Select.Options>
</Select>

Render Props: Delegate rendering to parent

<DataFetcher url="/api/users">
  {({ data, loading, error }) =>
    loading ? <Spinner /> : <UserList users={data} />
  }
</DataFetcher>

Slots (Vue/Svelte): Named content injection points

<template>
  <Card>
    <template #header>Title</template>
    <template #content>Body text</template>
    <template #footer><Button>Action</Button></template>
  </Card>
</template>

2. CSS-in-JS Approaches

Solution Approach Best For
Tailwind CSS Utility classes Rapid prototyping, design systems
CSS Modules Scoped CSS files Existing CSS, gradual adoption
styled-components Template literals React, dynamic styling
Emotion Object/template styles Flexible, SSR-friendly
Vanilla Extract Zero-runtime Performance-critical apps

3. Component API Design

interface ButtonProps {
  variant?: "primary" | "secondary" | "ghost";
  size?: "sm" | "md" | "lg";
  isLoading?: boolean;
  isDisabled?: boolean;
  leftIcon?: React.ReactNode;
  rightIcon?: React.ReactNode;
  children: React.ReactNode;
  onClick?: () => void;
}

Principles:

  • Use semantic prop names (isLoading vs loading)
  • Provide sensible defaults
  • Support composition via children
  • Allow style overrides via className or style

Quick Start: React Component with Tailwind

import { forwardRef, type ComponentPropsWithoutRef } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";

const buttonVariants = cva(
  "inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50",
  {
    variants: {
      variant: {
        primary: "bg-blue-600 text-white hover:bg-blue-700",
        secondary: "bg-gray-100 text-gray-900 hover:bg-gray-200",
        ghost: "hover:bg-gray-100 hover:text-gray-900",
      },
      size: {
        sm: "h-8 px-3 text-sm",
        md: "h-10 px-4 text-sm",
        lg: "h-12 px-6 text-base",
      },
    },
    defaultVariants: {
      variant: "primary",
      size: "md",
    },
  },
);

interface ButtonProps
  extends
    ComponentPropsWithoutRef<"button">,
    VariantProps<typeof buttonVariants> {
  isLoading?: boolean;
}

export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
  ({ className, variant, size, isLoading, children, ...props }, ref) => (
    <button
      ref={ref}
      className={cn(buttonVariants({ variant, size }), className)}
      disabled={isLoading || props.disabled}
      {...props}
    >
      {isLoading && <Spinner className="mr-2 h-4 w-4" />}
      {children}
    </button>
  ),
);
Button.displayName = "Button";

Framework Patterns

React: Compound Components

import { createContext, useContext, useState, type ReactNode } from "react";

interface AccordionContextValue {
  openItems: Set<string>;
  toggle: (id: string) => void;
}

const AccordionContext = createContext<AccordionContextValue | null>(null);

function useAccordion() {
  const context = useContext(AccordionContext);
  if (!context) throw new Error("Must be used within Accordion");
  return context;
}

export function Accordion({ children }: { children: ReactNode }) {

…
अक्सर पूछे जाने वाले सवाल

'compound components' क्या होते हैं?

ये ऐसे components होते हैं जो एक सेट की तरह मिलकर काम करते हैं। जैसे select component में चुना हुआ option दिखाने, options की list और list के हर item के लिए अलग हिस्से हो सकते हैं, लेकिन वे एक ही इकाई की तरह काम करते हैं।

'CSS-in-JS' क्या है?

यह styling का code (CSS) सीधे component के code (JavaScript/TypeScript) के अंदर लिखने का तरीका है, जिससे styling ज़्यादा dynamic और व्यवस्थित हो जाती है।

'component API design' का मतलब क्या है?

इसका मतलब है कि component कौन-कौन से options और properties लेता है (जैसे color, size, disabled है या नहीं), और उन्हें इस तरह तय करना कि दूसरे developers उसे आसानी से इस्तेमाल कर सकें।

जानकारी

लेखक का मूल विवरण

Master React, Vue, and Svelte component patterns including CSS-in-JS, composition strategies, and reusable component architecture. Use when building UI component libraries, designing component APIs, or implementing frontend design systems.

repo: wshobson/agents

लोकप्रियता

GitHub स्टार
41k
रैंकिंग में स्थान
#6809
लाइसेंस
MIT
अपडेट की गई
15/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills