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

Separator (구분선)

원문 보기 위키 갱신

Separator는 콘텐츠나 UI 요소 사이에 시각적인 구분선을 그려 주는 헤드리스 컴포넌트예요. 가로·세로 방향을 지정할 수 있고, 화면 리더에게 불필요한 장식용일 수도 있어요. 스타일은 전적으로 여러분이 맡게 되므로, 데이터 속성으로 방향을 구분해서 직접 꾸미면 됩니다.

출처: 문서

본문

<script lang="ts">
  import { Separator } from "bits-ui";
</script>
<div>
  <div class="space-y-1">
    <h4 class="font-semibold">Bits UI</h4>
    <p class="text-muted-foreground text-sm">
      Headless UI components for Svelte.
    </p>
  </div>
  <Separator.Root
    class="bg-border my-4 shrink-0 data-[orientation=horizontal]:h-px data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-[1px]"
  />
  <div class="flex h-5 items-center space-x-4 text-sm">
    <div>Blog</div>
    <Separator.Root
      orientation="vertical"
      class="bg-border my-4 shrink-0 data-[orientation=horizontal]:h-px data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-[1px]"
    />
    <div>Docs</div>
    <Separator.Root
      orientation="vertical"
      class="bg-border my-4 shrink-0 data-[orientation=horizontal]:h-px data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-[1px]"
    />
    <div>Source</div>
  </div>
</div>

구조

<script lang="ts">
  import { Separator } from "bits-ui";
</script>
<Separator.Root />

API 참조

Separator.Root

콘텐츠를 구분하는 데 쓰는 요소예요.

Property Type Description Details
orientation enum - 'horizontal' | 'vertical' The orientation of the separator.Default: 'horizontal'
decorative boolean Whether the separator is decorative or not, which will determine if it is announced by screen readers.Default: false
ref $bindable HTMLDivElement The underlying DOM element being rendered. You can bind to this to get a reference to the element.Default: null
children Snippet The children content to render.Default:  —— undefined
child Snippet - type SnippetProps = { props: Record<string, unknown>; }; Use render delegation to render your own element. See Child Snippet docs for more information.Default:  —— undefined
Data Attribute Value Description Details
data-orientation enum - 'horizontal' | 'vertical' The orientation of the separator.
data-separator-root '' Present on the root element.

더 알아보기 (Learn more)

Separator은 다른 폼 요소들과 잘 어울려서, 폼 안의 입력 구간을 나누거나 카드 사이에 경계를 넣을 때 함께 쓰기 좋아요. 방향성 데이터 속성(data-orientation)을 활용해 레이아웃에 맞게 스타일을 입혀 보세요. 다른 시각적 구분이 필요하다면 Toolbar나 Tabs 같은 구조 컴포넌트와 조합해도 자연스럽습니다.