본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

디자인 원칙 (Design Principles)

원문 보기 위키 갱신

HeroUI v3의 디자인과 개발을 이끄는 핵심 원칙들을 소개해요. HeroUI Native는 명확성, 접근성, 커스터마이징, 개발자 경험을 우선시하는 9가지 핵심 원칙을 따라 만들어진답니다. 각 원칙을 하나씩 살펴보면서 HeroUI가 어떤 생각으로 설계되었는지 파악해 보세요.

출처: 문서

본문

HeroUI Native는 명확성, 접근성, 커스터마이징, 그리고 개발자 경험을 우선시하는 9가지 핵심 원칙을 따릅니다.

Core Principles

1. Semantic Intent Over Visual Style

시각적 설명(solid, flat, bordered) 대신 의미적 이름(primary, secondary, tertiary)을 사용해요. Uber의 Base 디자인 시스템에서 영감을 받아 변형은 명확한 계층을 따릅니다.

// ✅ Semantic variants communicate hierarchy
<Button variant="primary">Save</Button>
<Button variant="secondary">Edit</Button>
<Button variant="tertiary">Cancel</Button>
Variant Purpose Usage
Primary 진행을 위한 주요 액션 컨텍스트당 1개
Secondary 대체 액션 여러 개 허용
Tertiary 거부형 액션 (취소, 건너뛰기) 아껴서 사용
Danger 파괴적 액션 필요할 때

2. Accessibility as Foundation

접근성은 모바일 개발 모범 사례를 따르며, 모든 컴포넌트에 적절한 터치 접근성, 포커스 관리, 화면 읽기 프로그램 지원이 내장되어 있어요. 모든 컴포넌트에는 VoiceOver(iOS)와 TalkBack(Android)을 위한 적절한 접근성 라벨과 의미 구조가 포함돼요.

import { Tabs } from 'heroui-native';

<Tabs value="profile" onValueChange={setActiveTab}>
  <Tabs.List>
    <Tabs.Indicator />
    <Tabs.Trigger value="profile">
      <Tabs.Label>Profile</Tabs.Label>
    </Tabs.Trigger>
    <Tabs.Trigger value="security">
      <Tabs.Label>Security</Tabs.Label>
    </Tabs.Trigger>
  </Tabs.List>
  <Tabs.Content value="profile">Content</Tabs.Content>
  <Tabs.Content value="security">Content</Tabs.Content>
</Tabs>

3. Composition Over Configuration

합성(compound) 컴포넌트를 사용하면 필요한 대로 파트를 재배열, 커스터마이즈, 또는 생략할 수 있어요. 점 표기법(dot notation)으로 정확히 필요한 형태로 컴포넌트를 구성해 보세요.

// Compose parts to build exactly what you need
import { Accordion } from 'heroui-native';

<Accordion>
  <Accordion.Item value="1">
    <Accordion.Trigger>
      Question Text
      <Accordion.Indicator />
    </Accordion.Trigger>
    <Accordion.Content>Answer content</Accordion.Content>
  </Accordion.Item>
</Accordion>

4. Progressive Disclosure

간단하게 시작하고, 필요할 때만 복잡성을 추가해요. 컴포넌트는 최소한의 prop으로 동작하며 요구사항이 커짐에 따라 확장돼요.

import { Button, Spinner } from 'heroui-native';
import { Feather } from '@expo/vector-icons';

// Level 1: Minimal
<Button>Click me</Button>

// Level 2: Enhanced
<Button variant="primary" size="lg">
  <Feather name="check" size={20} />
  <Button.Label>Submit</Button.Label>
</Button>

// Level 3: Advanced
<Button variant="primary" isDisabled={isLoading}>
  {isLoading ? (
    <>
      <Spinner size="sm" />
      <Button.Label>Loading...</Button.Label>
    </>
  ) : (
    <Button.Label>Submit</Button.Label>
  )}
</Button>

5. Predictable Behavior

크기(sm, md, lg), 변형, className 지원 같은 일관된 패턴을 모든 컴포넌트에 적용해요. 같은 API, 같은 동작.

import { Button, Chip, Avatar } from 'heroui-native';

// All components follow the same patterns
<Button size="lg" variant="primary" className="custom">
  <Button.Label>Click me</Button.Label>
</Button>
<Chip size="lg" color="success" className="custom">
  <Chip.Label>Success</Chip.Label>
</Chip>
<Avatar size="lg" className="custom">
  <Avatar.Fallback>JD</Avatar.Fallback>
</Avatar>

6. Type Safety First

IntelliSense, 자동 완성, 컴파일 타임 오류 감지를 갖춘 완전한 TypeScript 지원을 제공해요. 커스텀 컴포넌트를 위해 타입을 확장할 수 있어요.

import type { ButtonRootProps } from 'heroui-native';

// Type-safe props and event handlers
<Button
  variant="primary"  // Autocomplete: primary | secondary | tertiary | ghost | danger | danger-soft
  size="md"          // Type checked: sm | md | lg
  onPress={() => {   // Properly typed press handler
    console.log('Button pressed');
  }}
>
  <Button.Label>Click me</Button.Label>
</Button>

// Extend types for custom components
interface CustomButtonProps extends Omit<ButtonRootProps, 'variant'> {
  intent: 'save' | 'cancel' | 'delete';
}

7. Developer Experience Excellence

명확한 API, 설명적인 오류, IntelliSense, 그리고 AI 친화적인 마크다운 문서를 제공해요.

8. Complete Customization

기본적으로 아름다운 기본값을 제공하고, Uniwind의 테마 시스템을 통해 CSS 변수로 전체 모양을 바꿀 수 있어요. 모든 슬롯을 커스터마이즈할 수 있어요.

/* Custom colors using Uniwind's theme layer */
@layer theme {
  @variant light {
    --accent: oklch(0.65 0.25 270); /* Custom indigo accent */
    --background: oklch(0.98 0 0);  /* Custom background */
  }

  @variant dark {
    --accent: oklch(0.65 0.25 270);
    --background: oklch(0.15 0 0);
  }
}

/* Radius customization */
@theme {
  --radius: 0.75rem; /* Increase for rounder components */
}

9. Open and Extensible

필요에 맞게 컴포넌트를 감싸고, 확장하고, 커스터마이즈해요. 사용자 정의 래퍼를 만들거나 className으로 사용자 정의 스타일을 적용할 수 있어요.

import { Button } from 'heroui-native';
import type { ButtonRootProps } from 'heroui-native';

// Custom wrapper component
interface CTAButtonProps extends Omit<ButtonRootProps, 'variant'> {
  intent?: 'primary-cta' | 'secondary-cta' | 'minimal';
}

const CTAButton = ({
  intent = 'primary-cta',
  children,
  ...props
}: CTAButtonProps) => {
  const variantMap = {
    'primary-cta': 'primary',
    'secondary-cta': 'secondary',
    'minimal': 'ghost'
  } as const;

  return (
    <Button variant={variantMap[intent]} {...props}>
      <Button.Label>{children}</Button.Label>
    </Button>
  );
};

// Usage
<CTAButton intent="primary-cta">Get Started</CTAButton>
<CTAButton intent="secondary-cta">Learn More</CTAButton>

Tailwind Variants로 확장하기:

import { Button } from 'heroui-native';
import { tv } from 'tailwind-variants';

// Extend button styles with custom variants
const myButtonVariants = tv({
  base: 'px-4 py-2 rounded-lg',
  variants: {
    variant: {
      'primary-cta': 'bg-accent px-8 py-4 shadow-lg',
      'secondary-cta': 'border-2 border-accent px-6 py-3',
    }
  },
  defaultVariants: {
    variant: 'primary-cta',
  }
});

// Label variants for text colors (must be applied to Button.Label)
const myLabelVariants = tv({
  base: '',
  variants: {
    variant: {
      'primary-cta': 'text-accent-foreground',
      'secondary-cta': 'text-accent',
    }
  },
  defaultVariants: {
    variant: 'primary-cta',
  }
});

// Use the custom variants
function CustomButton({ variant, className, labelClassName, children, ...props }) {
  return (
    <Button className={myButtonVariants({ variant, className })} {...props}>
      <Button.Label className={myLabelVariants({ variant, className: labelClassName })}>
        {children}
      </Button.Label>
    </Button>
  );
}

// Usage
<CustomButton variant="primary-cta">Get Started</CustomButton>
<CustomButton variant="secondary-cta">Learn More</CustomButton>

더 알아보기 (Learn more)