Build consistent UIs with design tokens and core components
A React/RN core component and design-token skill - spacing, color, typography tokens, and Box/Stack/Button/Input/Card usage.
Why it matters
Enforce design system consistency across UI development by providing a standardized component library with design tokens for spacing, colors, and typography, eliminating hard-coded values and ensuring uniform styling and behavior.
Outcomes
What it gets done
Replace hard-coded values with design tokens for spacing, colors, and typography
Build layouts using core components like Box, HStack, VStack, and Card
Implement forms and interactive elements with Button and Input components
Create consistent screen and list layouts following established patterns
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-code-showcase-core-components | bash Overview
Core Components
This skill covers a React/React Native design-token system and core component library: spacing, color, and typography tokens, plus Box, Stack, Button, Input, and Card components with layout patterns. Use it when building UI, using design tokens, or working with the component library. Avoid raw platform components or inline styles.
What it does
This skill covers a React and React Native core component library and design-token system for building consistent UI. It enforces never hard-coding values and always using design tokens: spacing tokens mapping to 4px through 32px, semantic color tokens for primary and secondary text, tertiary or disabled text, brand accent color, and error or success states instead of hex or rgb values, and typography tokens mapping extra-small through 2xl sizes for font size alongside weight tokens like semibold. Core components documented include Box, a token-aware layout primitive; HStack and VStack for horizontal and vertical flex layouts; Text for typography with token props; Button with solid, outline, ghost, and link variants plus loading and disabled states; Input with a label and validation error display; and Card with header and body composition. Layout patterns cover full-screen layouts with a screen header and content area, form layouts stacking inputs with a submit button, and list-item layouts combining an avatar, title and subtitle, and a chevron inside a bordered horizontal stack. Anti-patterns explicitly called out include raw inline styles instead of token props, importing raw platform components instead of the core library's wrapped versions, and inline style objects instead of token-based props. It also shows the component-authoring pattern itself: typed props restricted to specific token values, such as padding limited to a union of token strings, and a variant-styles lookup applied via spread. Button variants map to specific intents - solid for primary actions, outline for secondary actions, ghost for tertiary or subtle actions, and link for inline actions - which keeps visual hierarchy consistent across a screen without each developer inventing their own convention.
When to use - and when NOT to
Use it when building UI, working with design tokens, or using the component library - not for raw platform component usage or inline styling, which the skill explicitly treats as anti-patterns to avoid.
Inputs and outputs
Given a UI requirement, it produces component usage matching the design system's token conventions for spacing, color, and typography, built from the core component set - Box, HStack and VStack, Text, Button, Input, and Card - rather than raw platform primitives or inline styles.
Integrations
Integrates with sibling skills: a React UI patterns skill for UI state handling using these core components, a testing-patterns skill for mocking core components in tests, and Storybook for documenting component variants.
Who it's for
Frontend and mobile developers working in a codebase with this design-token-based component library who need consistent spacing, color, and typography usage instead of hard-coded values or raw platform components.
Source README
Core Components
When to Use
Use this skill when you need core component library and design system patterns. Use when building UI, using design tokens, or working with the component library.
Design System Overview
Use components from your core library instead of raw platform components. This ensures consistent styling and behavior.
Design Tokens
NEVER hard-code values. Always use design tokens.
Spacing Tokens
// CORRECT - Use tokens
<Box padding="$4" marginBottom="$2" />
// WRONG - Hard-coded values
<Box padding={16} marginBottom={8} />
| Token | Value |
|---|---|
$1 |
4px |
$2 |
8px |
$3 |
12px |
$4 |
16px |
$6 |
24px |
$8 |
32px |
Color Tokens
// CORRECT - Semantic tokens
<Text color="$textPrimary" />
<Box backgroundColor="$backgroundSecondary" />
// WRONG - Hard-coded colors
<Text color="#333333" />
<Box backgroundColor="rgb(245, 245, 245)" />
| Semantic Token | Use For |
|---|---|
$textPrimary |
Main text |
$textSecondary |
Supporting text |
$textTertiary |
Disabled/hint text |
$primary500 |
Brand/accent color |
$statusError |
Error states |
$statusSuccess |
Success states |
Typography Tokens
<Text fontSize="$lg" fontWeight="$semibold" />
| Token | Size |
|---|---|
$xs |
12px |
$sm |
14px |
$md |
16px |
$lg |
18px |
$xl |
20px |
$2xl |
24px |
Core Components
Box
Base layout component with token support:
<Box
padding="$4"
backgroundColor="$backgroundPrimary"
borderRadius="$lg"
>
{children}
</Box>
HStack / VStack
Horizontal and vertical flex layouts:
<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
Typography with token support:
<Text
fontSize="$lg"
fontWeight="$semibold"
color="$textPrimary"
>
Hello World
</Text>
Button
Interactive button with variants:
<Button
onPress={handlePress}
variant="solid"
size="md"
isLoading={loading}
isDisabled={disabled}
>
Click Me
</Button>
| Variant | Use For |
|---|---|
solid |
Primary actions |
outline |
Secondary actions |
ghost |
Tertiary/subtle actions |
link |
Inline actions |
Input
Form input with validation:
<Input
value={value}
onChangeText={setValue}
placeholder="Enter text"
error={touched ? errors.field : undefined}
label="Field Name"
/>
Card
Content container:
<Card padding="$4" gap="$3">
<CardHeader>
<Heading size="sm">Card Title</Heading>
</CardHeader>
<CardBody>
<Text>Card content</Text>
</CardBody>
</Card>
Layout Patterns
Screen Layout
const MyScreen = () => (
<Screen>
<ScreenHeader title="Page Title" />
<ScreenContent padding="$4">
{/* Content */}
</ScreenContent>
</Screen>
);
Form Layout
<VStack gap="$4" padding="$4">
<Input label="Name" {...nameProps} />
<Input label="Email" {...emailProps} />
<Button isLoading={loading}>Submit</Button>
</VStack>
List Item Layout
<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>
Anti-Patterns
// 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">
Component Props Pattern
When creating components, use token-based 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>
);
Integration with Other Skills
- react-ui-patterns: Use core components for UI states
- testing-patterns: Mock core components in tests
- storybook: Document component variants
Limitations
- Use this skill only when the task clearly matches its upstream source and local project context.
- Verify commands, generated code, dependencies, credentials, and external service behavior before applying changes.
- Do not treat examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.