mcpField
C
core-components

core-components

github.com/chriswilesデザイン・UI6.1k78 回インストール42 週間前に更新
リポジトリ

core-components について

React UI 開発者向けのデザインシステム活用スキルです。レイアウト、テキスト、ボタン、入力欄、カードの基本コンポーネントと、デザイントークンによる一貫した実装を紹介します。

主な機能

  1. 01コア UI コンポーネントの利用
  2. 02間隔・色・文字のトークン適用
  3. 03レイアウトとフォームのパターン
  4. 04ボタンの種類とコンポーネント属性

活用シーン

  1. 01一貫した React UI の構築
  2. 02フォームやリストのレイアウト
  3. 03スタイル値の直書き回避

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/chriswiles/claude-code-showcase --skill core-components

インストール後、Claude Code で/core-componentsを入力して読み込まれたか確認します。

詳細

コアコンポーネント

デザインシステムの概要

プラットフォームの生のコンポーネントではなく、コアライブラリのコンポーネントを使用してください。これにより、スタイルと動作の一貫性が保たれます。

デザイントークン

値を直接ハードコードしないでください。必ずデザイントークンを使用してください。

スペーシングトークン
// CORRECT - Use tokens
<Box padding="$4" marginBottom="$2" />

// WRONG - Hard-coded values
<Box padding={16} marginBottom={8} />
トークン値
$14px
$28px
$312px
$416px
$624px
$832px
カラートークン
// CORRECT - Semantic tokens
<Text color="$textPrimary" />
<Box backgroundColor="$backgroundSecondary" />

// WRONG - Hard-coded colors
<Text color="#333333" />
<Box backgroundColor="rgb(245, 245, 245)" />
セマンティックトークン用途
$textPrimaryメインテキスト
$textSecondary補足テキスト
$textTertiary無効/ヒントテキスト
$primary500ブランド/アクセントカラー
$statusErrorエラー状態
$statusSuccess成功状態
タイポグラフィトークン
<Text fontSize="$lg" fontWeight="$semibold" />
トークンサイズ
$xs12px
$sm14px
$md16px
$lg18px
$xl20px
$2xl24px

コアコンポーネント

Box

トークンサポートを備えた基本レイアウトコンポーネント:

<Box
  padding="$4"
  backgroundColor="$backgroundPrimary"
  borderRadius="$lg"
>
  {children}
</Box>
HStack / VStack

水平方向および垂直方向のフレックスレイアウト:

<HStack gap="$3" alignItems="center">
  <Icon name="user" />
  <Text>Username</Text>
</HStack>

<VStack gap="$4" padding="$4">
  <Heading>Title</Heading>
  <Text>Content</Text>
</VStack>
Text

トークンサポートを備えたタイポグラフィ:

<Text
  fontSize="$lg"
  fontWeight="$semibold"
  color="$textPrimary"
>
  Hello World
</Text>
Button

バリエーションを備えたインタラクティブなボタン:

<Button
  onPress={handlePress}
  variant="solid"
  size="md"
  isLoading={loading}
  isDisabled={disabled}
>
  Click Me
</Button>
バリアント用途
solid主要なアクション
outline副次的なアクション
ghost三次的/控えめなアクション
linkインラインアクション
Input

バリデーションを備えたフォーム入力:

<Input
  value={value}
  onChangeText={setValue}
  placeholder="Enter text"
  error={touched ? errors.field : undefined}
  label="Field Name"
/>
Card

コンテンツのコンテナ:

<Card padding="$4" gap="$3">
  <CardHeader>
    <Heading size="sm">Card Title</Heading>
  </CardHeader>
  <CardBody>
    <Text>Card content</Text>
  </CardBody>
</Card>

レイアウトパターン

画面レイアウト
const MyScreen = () => (
  <Screen>
    <ScreenHeader title="Page Title" />
    <ScreenContent padding="$4">
      {/* Content */}
    </ScreenContent>
  </Screen>
);
フォームレイアウト
<VStack gap="$4" padding="$4">
  <Input label="Name" {...nameProps} />
  <Input label="Email" {...emailProps} />
  <Button isLoading={loading}>Submit</Button>
</VStack>
リストアイテムレイアウト
<HStack
  padding="$4"
  gap="$3"
  alignItems="center"
  borderBottomWidth={1}
  borderColor="$borderLight"
>
  <Avatar source={{ uri: imageUrl }} size="md" />
  <VStack flex={1}>
    <Text fontWeight="$semibold">{title}</Text>
    <Text color="$textSecondary" fontSize="$sm">{subtitle}</Text>
  </VStack>
  <Icon name="chevron-right" color="$textTertiary" />
</HStack>

アンチパターン

// WRONG - Hard-coded values
<View style={{ padding: 16, backgroundColor: '#fff' }}>

// CORRECT - Design tokens
<Box padding="$4" backgroundColor="$backgroundPrimary">


// WRONG - Raw platform components
import { View, Text } from 'react-native';

// CORRECT - Core components
import { Box, Text } from 'components/core';


// WRONG - Inline styles
<Text style={{ fontSize: 18, fontWeight: '600' }}>

// CORRECT - Token props
<Text fontSize="$lg" fontWeight="$semibold">

コンポーネントのPropsパターン

コンポーネントを作成する際は、トークンベースのPropsを使用してください:

interface CardProps {
  padding?: '$2' | '$4' | '$6';
  variant?: 'elevated' | 'outlined' | 'filled';
  children: React.ReactNode;
}

const Card = ({ padding = '$4', variant = 'elevated', children }: CardProps) => (
  <Box
    padding={padding}
    backgroundColor="$backgroundPrimary"
    borderRadius="$lg"
    {...variantStyles[variant]}
  >
    {children}
  </Box>
);

他のスキルとの連携

  • react-ui-patterns: UIの状態にはコアコンポーネントを使用してください
  • testing-patterns: テストではコアコンポーネントをモックしてください
  • storybook: コンポーネントのバリアントをドキュメント化してください

コメント