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

Surface (표면)

원문 보기 위키 갱신

Surface는 자식 컴포넌트에 높이감과 배경 스타일을 제공하는 컨테이너 컴포넌트예요. 여러 variant를 통해 화면에서의 중요도에 맞는 표면 레벨을 쉽게 적용할 수 있어요. 중첩해서 사용하면 시각적 위계 구조도 만들 수 있어요.

출처: 문서

본문

가져오기 (Import)

import { Surface } from 'heroui-native';

구조 (Anatomy)

Surface 컴포넌트는 높이감과 배경 스타일을 제공하는 컨테이너예요. 자식을 받아들이며 variant와 스타일링 프롭으로 커스터마이징할 수 있어요.

<Surface>...</Surface>
  • Surface: variant를 통해 일관된 패딩, 배경 스타일, 높이감을 제공하는 메인 컨테이너 컴포넌트

사용법 (Usage)

기본 사용법 (Basic Usage)

Surface 컴포넌트는 일관된 패딩과 스타일을 가진 컨테이너를 만들어요.

<Surface>...</Surface>

변형 (Variants)

서로 다른 표면 레벨로 시각적 모양을 제어해요.

<Surface variant="default">
  ...
</Surface>

<Surface variant="secondary">
  ...
</Surface>

<Surface variant="tertiary">
  ...
</Surface>

중첩된 Surface (Nested Surfaces)

서로 다른 variant의 표면을 중첩해서 시각적 위계 구조를 만들어요.

<Surface variant="default">
  ...
  <Surface variant="secondary">
    ...
    <Surface variant="tertiary">...</Surface>
  </Surface>
</Surface>

커스텀 스타일링 (Custom Styling)

className 또는 style 프롭으로 커스텀 스타일을 적용해요.

<Surface className="bg-accent-soft">
  ...
</Surface>

<Surface variant="tertiary" className="p-0">
  ...
</Surface>

모든 애니메이션 비활성화 (Disable All Animations)

animation 프롭에 "disable-all" 값을 사용해서 자식을 포함한 모든 애니메이션을 비활성화해요.

{
  /* Disable all animations including children */
}
<Surface animation="disable-all">No Animations</Surface>;

예제 (Example)

import { Surface } from 'heroui-native';
import { Text, View } from 'react-native';

export default function SurfaceExample() {
  return (
    <View className="gap-4">
      <Surface variant="default" className="gap-2">
        <AppText className="text-foreground">Surface Content</AppText>
        <AppText className="text-muted">
          This is a default surface variant. It uses bg-surface styling.
        </AppText>
      </Surface>

      <Surface variant="secondary" className="gap-2">
        <AppText className="text-foreground">Surface Content</AppText>
        <AppText className="text-muted">
          This is a secondary surface variant. It uses bg-surface-secondary
          styling.
        </AppText>
      </Surface>

      <Surface variant="tertiary" className="gap-2">
        <AppText className="text-foreground">Surface Content</AppText>
        <AppText className="text-muted">
          This is a tertiary surface variant. It uses bg-surface-tertiary
          styling.
        </AppText>
      </Surface>
    </View>
  );
}

더 많은 예제는 GitHub 저장소에서 찾을 수 있어요.

API 참고 (API Reference)

Surface

prop type default description
variant 'default' | 'secondary' | 'tertiary' | 'transparent' 'default' Visual variant controlling background color and border
children React.ReactNode - Content to be rendered inside the surface
className string - Additional CSS classes to apply
animation "disable-all" | undefined undefined Animation configuration. Use "disable-all" to disable all animations including children
asChild boolean false Whether to render as a child element
...ViewProps ViewProps - All standard React Native View props are supported

더 알아보기 (Learn more)