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

TreeSelect (트리 셀렉트)

원문 보기 위키 갱신

TreeSelect는 계층 구조 데이터에서 항목을 고르는 폼 컴포넌트예요. 트리 형태로 펼쳐진 옵션 목록에서 하나 또는 여러 노드를 선택하게 할 수 있죠.

출처: 문서

본문

가져오기 (Import)

import TreeSelect from 'primevue/treeselect';

접근성 (Accessibility)

스크린 리더

컴포넌트를 설명하는 값은 aria-labelledby 또는 aria-label props로 제공할 수 있어요. treeselect 요소는 combobox role을 가지고, 여기에 aria-haspopup과 aria-expanded 속성이 함께 붙어요. combobox와 팝업 사이의 관계는 팝업의 id를 참조하는 aria-controls로 만들어지죠. 팝업 목록은 combobox 요소의 aria-controls 속성이 참조하는 id를 가지며, role로는 tree를 사용해요.

각 목록 항목은 treeitem role에 aria-label, aria-selected, aria-expanded 속성을 함께 가져요. 체크박스 선택 모드에서는 aria-selected 대신 aria-checked가 사용되고요. 체크박스와 토글 아이콘은 스크린 리더에서 숨겨져요. 대신 treeitem role과 속성을 가진 부모 요소가 리더와 키보드 지원을 담당하죠. treenode의 컨테이너 요소는 group role을 가지고, aria-setsize, aria-posinset, aria-level 속성은 자동으로 계산되어 각 treeitem에 추가돼요.

닫힌 상태 키보드 지원에서는 tab 키가 treeselect 요소로 포커스를 옮기고, space 키가 팝업을 열어 선택된 treenode로 시각 포커스를 옮겨요. 선택된 노드가 없으면 첫 번째 treenode가 포커스를 받죠. down arrow도 팝업을 열어 선택된 옵션으로 포커스를 옮기는데, 없으면 첫 번째 옵션이 포커스를 받아요.

팝업 키보드 지원에서는 tab 키가 페이지 탭 시퀀스의 다음 포커스 가능 요소로, shift + tab은 이전 포커스 가능 요소로 포커스를 옮겨요. enter와 space는 포커스된 옵션을 선택하고, 단일 선택 모드일 때는 팝업을 닫죠. escape는 팝업을 닫고 포커스를 treeselect 요소로 돌려 보내요. down arrow는 다음 treenode로, up arrow는 이전 treenode로 포커스를 옮기고요. right arrow는 노드가 닫혀 있으면 노드를 열고, 그렇지 않으면 첫 번째 자식 노드로 포커스를 옮겨요. left arrow는 노드가 열려 있으면 노드를 닫고, 그렇지 않으면 부모 노드로 포커스를 옮기죠.

<span id="dd1">Options</span>
<TreeSelect aria-labelledby="dd1" />

<TreeSelect aria-label="Options" />

기본 (Basic)

TreeSelect는 v-model 속성으로 양방향 값 바인딩을 하고, options 컬렉션과 함께 사용해요. 내부적으로 Tree 컴포넌트를 사용하기 때문에 options 모델은 TreeNode API 기반이에요. 단일 선택 모드에서는 값 바인딩이 노드의 key 값이어야 해요.

<TreeSelect v-model="selectedValue" :options="nodes" placeholder="Select Item" class="md:w-80 w-full" />

체크박스 (Checkbox)

selectionMode를 checkbox로 설정하면 체크박스로 여러 노드를 선택할 수 있어요. 체크박스 선택 모드에서 값 바인딩은 key-value 쌍이어야 하는데, key는 노드의 key고 value는 checked와 partialChecked 속성으로 노드의 선택 상태를 나타내는 객체예요.

<TreeSelect v-model="selectedValue" :options="nodes" selectionMode="checkbox" placeholder="Select Item" class="md:w-80 w-full" />
Composition API 예제
<template>
    <div class="card flex justify-center">
        <TreeSelect v-model="selectedValue" :options="nodes" selectionMode="checkbox" placeholder="Select Item" class="md:w-80 w-full" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

지우기 아이콘 (Clear Icon)

showClear를 활성화하면 TreeSelect를 초기화하는 지우기 아이콘이 추가돼요.

<TreeSelect v-model="selectedValue" :options="nodes" placeholder="Select Item" class="md:w-80 w-full" />
Composition API 예제
<template>
    <div class="card flex justify-center">
        <TreeSelect v-model="selectedValue" :options="nodes" placeholder="Select Item" class="md:w-80 w-full" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

비활성화 (Disabled)

disabled 속성이 있으면 요소를 편집하거나 포커스할 수 없어요.

<TreeSelect v-model="selectedValue" disabled class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" />
Composition API 예제
<template>
    <div class="card flex justify-center">
        <TreeSelect v-model="selectedValue" disabled class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

채움 스타일 (Filled)

variant 속성을 filled로 지정하면 기본 outlined 스타일보다 시각적으로 강조된 모습으로 컴포넌트를 표시해요.

<TreeSelect v-model="selectedValue" variant="filled" :options="nodes" placeholder="Select Item" class="md:w-80 w-full" />
Composition API 예제
<template>
    <div class="card flex justify-center">
        <TreeSelect v-model="selectedValue" variant="filled" :options="nodes" placeholder="Select Item" class="md:w-80 w-full" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

필터링 (Filter)

filter 속성을 추가하면 필터링이 활성화돼요. 기본적으로 노드의 label 속성으로 텍스트 필드의 값을 비교하는데, 검색에 사용할 필드를 바꾸고 싶으면 filterBy 속성을 정의하면 돼요. 그리고 filterMode로 필터링 전략을 지정할 수 있죠. lenient 모드에서는 쿼리가 노드와 일치할 때 그 노드의 모든 하위 항목이 포함되기 때문에 자식들을 더 검색하지 않아요. 반면 strict 모드에서는 쿼리가 노드와 일치해도 모든 하위 항목에 대해 필터링을 계속해요.

<TreeSelect v-model="selectedValue" filter filterMode="lenient" :options="nodes" placeholder="Select Item" class="md:w-80 w-full" />
<TreeSelect v-model="selectedValue" filter filterMode="strict" :options="nodes" placeholder="Select Item" class="md:w-80 w-full" />
Composition API 예제
<template>
    <div class="card flex flex-wrap justify-center items-end gap-4">
        <TreeSelect v-model="selectedValue" filter filterMode="lenient" :options="nodes" placeholder="Select Item" class="md:w-80 w-full" />
        <TreeSelect v-model="selectedValue" filter filterMode="strict" :options="nodes" placeholder="Select Item" class="md:w-80 w-full" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue = ref(null);
const selectedValue2 = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

플로팅 레이블 (Float Label)

포커스가 가면 입력 필드 위에 플로팅 레이블이 나타나요. 자세한 내용은 FloatLabel 문서를 참고하세요.

<FloatLabel class="w-full md:w-80">
    <TreeSelect v-model="value1" inputId="over_label" :options="nodes" class="w-full" />
    <label for="over_label">Over Label</label>
</FloatLabel>

<FloatLabel class="w-full md:w-80" variant="in">
    <TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" variant="filled" />
    <label for="in_label">In Label</label>
</FloatLabel>

<FloatLabel class="w-full md:w-80" variant="on">
    <TreeSelect v-model="value3" inputId="on_label" :options="nodes" class="w-full" />
    <label for="on_label">On Label</label>
</FloatLabel>
Composition API 예제
<template>
    <div class="card flex flex-wrap justify-center items-end gap-4">
        <FloatLabel class="w-full md:w-80">
            <TreeSelect v-model="value1" inputId="over_label" :options="nodes" class="w-full" />
            <label for="over_label">Over Label</label>
        </FloatLabel>

        <FloatLabel class="w-full md:w-80" variant="in">
            <TreeSelect v-model="value2" inputId="in_label" :options="nodes" class="w-full" variant="filled" />
            <label for="in_label">In Label</label>
        </FloatLabel>

        <FloatLabel class="w-full md:w-80" variant="on">
            <TreeSelect v-model="value3" inputId="on_label" :options="nodes" class="w-full" />
            <label for="on_label">On Label</label>
        </FloatLabel>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const value1 = ref(null);
const value2 = ref(null);
const value3 = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

전체 너비 (Fluid)

fluid prop을 true로 설정하면 컴포넌트가 컨테이너의 전체 너비를 차지해요.

<TreeSelect v-model="selectedValue" :options="nodes" placeholder="Select Item" fluid />
Composition API 예제
<template>
    <div class="card">
        <TreeSelect v-model="selectedValue" :options="nodes" placeholder="Select Item" fluid />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

폼 (Forms)

TreeSelect는 v-model 속성과 함께 사용해요.

<Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex flex-col gap-4 w-full md:w-80">
    <div class="flex flex-col gap-1">
        <TreeSelect name="node" :options="nodes" placeholder="Select Item" fluid />
        <Message v-if="$form.node?.invalid" severity="error" size="small" variant="simple">{{ $form.node.error?.message }}</Message>
    </div>
    <Button type="submit" severity="secondary" label="Submit" />
</Form>
Composition API 예제
<template>
    <div class="card flex justify-center">
        <Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex flex-col gap-4 w-full md:w-80">
            <div class="flex flex-col gap-1">
                <TreeSelect name="node" :options="nodes" placeholder="Select Item" fluid />
                <Message v-if="$form.node?.invalid" severity="error" size="small" variant="simple">{{ $form.node.error?.message }}</Message>
            </div>
            <Button type="submit" severity="secondary" label="Submit" />
        </Form>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import { zodResolver } from '@primevue/forms/resolvers/zod';
import { useToast } from "primevue/usetoast";
import { z } from 'zod';
import { NodeService } from '/service/NodeService';

const toast = useToast();
const initialValues = ref({
    node: null
});
const resolver = ref(zodResolver(
    z.object({
        node: z.union([z.record(z.boolean()), z.literal(null)]).refine((obj) => obj !== null && Object.keys(obj).length > 0, { message: 'Selection is required.' })
    })
));

const onFormSubmit = ({ valid }) => {
    if (valid) {
        toast.add({ severity: 'success', summary: 'Form is submitted.', life: 3000 });
    }
};
<\/script>

Ifta 레이블 (Ifta Label)

IftaLabel은 입력 필드 안쪽 위에 붙는 레이블을 만들 때 사용해요. 자세한 내용은 IftaLabel 문서를 참고하세요.

<IftaLabel class="w-full md:w-80">
    <TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" variant="filled" />
    <label for="t_file">File</label>
</IftaLabel>
Composition API 예제
<template>
    <div class="card flex justify-center">
        <IftaLabel class="w-full md:w-80">
            <TreeSelect v-model="selectedValue" inputId="t_file" :options="nodes" class="w-full" variant="filled" />
            <label for="t_file">File</label>
        </IftaLabel>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

유효하지 않은 상태 (Invalid)

invalid prop을 사용하면 검증 실패를 알리는 유효하지 않은 상태가 표시돼요. 폼 검증 라이브러리와 통합할 때 이 스타일을 활용할 수 있죠.

<TreeSelect v-model="selectedValue1" :invalid="Object.keys(selectedValue1).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" />
<TreeSelect v-model="selectedValue2" :invalid="Object.keys(selectedValue2).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" variant="filled" />
Composition API 예제
<template>
    <div class="card flex flex-wrap justify-center gap-4">
        <TreeSelect v-model="selectedValue1" :invalid="Object.keys(selectedValue1).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" />
        <TreeSelect v-model="selectedValue2" :invalid="Object.keys(selectedValue2).length === 0" class="md:w-80 w-full" :options="nodes" placeholder="TreeSelect" variant="filled" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue1 = ref({});
const selectedValue2 = ref({});

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

지연 로딩 (Lazy)

거대한 데이터를 다룰 때는 지연 로딩이 유용해요. 이 예제에서는 loading 속성과 node-expand 메서드로 노드를 필요할 때 동적으로 불러오죠.

<TreeSelect v-model="selectedValue" loadingMode="icon" :options="nodes" @node-expand="onNodeExpand" placeholder="Select Item" class="md:w-80 w-full" />
Composition API 예제
<template>
    <div class="card">
        <TreeSelect v-model="selectedValue" loadingMode="icon" :options="nodes" @node-expand="onNodeExpand" placeholder="Select Item" class="md:w-80 w-full" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';

const nodes = ref(null);
const selectedValue = ref(null);

onMounted(() => {
    nodes.value = initiateNodes();

    setTimeout(() => {
        nodes.value.map((node) => (node.loading = false));
    }, 2000);
});

const onNodeExpand = (node) => {
    if (!node.children) {
        node.loading = true;

        setTimeout(() => {
            let _node = { ...node };

            _node.children = [];

            for (let i = 0; i < 3; i++) {
                _node.children.push({
                    key: node.key + '-' + i,
                    label: 'Lazy ' + node.label + '-' + i
                });
            }

            nodes.value[parseInt(node.key, 10)] = { ..._node, loading: false };
        }, 500);
    }
};

const initiateNodes = () => {
    return [
        {
            key: '0',
            label: 'Node 0',
            leaf: false,
            loading: true
        },
        {
            key: '1',
            label: 'Node 1',
            leaf: false,
            loading: true
        },
        {
            key: '2',
            label: 'Node 2',
            leaf: false,
            loading: true
        }
    ];
};
<\/script>

다중 선택 (Multiple)

selectionMode를 multiple로 설정하면 여러 노드를 선택할 수 있어요. 기본적으로 다중 선택 모드에서는 기존 선택에 추가할 때 metaKey 누름(예: ⌘)이 필요 없어요. 선택적인 metaKeySelection을 설정하면 동작이 바뀌어서, 새 노드를 선택하려면 meta 키를 누르고 있어야 하죠. 참고로 터치 지원 기기에서는 TreeSelect가 항상 metaKey를 무시해요. 다중 선택 모드에서 값 바인딩은 key-value 쌍이어야 하고, key는 노드의 key, value는 선택 여부를 나타내는 boolean이에요.

<TreeSelect v-model="selectedValue" :options="nodes" selectionMode="multiple" display="chip" :maxSelectedLabels="3" placeholder="Select Items" class="md:w-80 w-full" />
Composition API 예제
<template>
    <div class="card flex justify-center">
        <TreeSelect v-model="selectedValue" :options="nodes" selectionMode="multiple" display="chip" :maxSelectedLabels="3" placeholder="Select Items" class="md:w-80 w-full" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

크기 (Sizes)

TreeSelect는 기본 크기 외에 small과 large 크기를 선택할 수 있게 제공해요.

<TreeSelect v-model="value1" :options="nodes" size="small" placeholder="Small" class="md:w-80 w-full" />
<TreeSelect v-model="value2" :options="nodes" placeholder="Normal" class="md:w-80 w-full" />
<TreeSelect v-model="value3" :options="nodes" size="large" placeholder="Large" class="md:w-80 w-full" />
Composition API 예제
<template>
    <div class="card flex flex-col items-center gap-4">
        <TreeSelect v-model="value1" :options="nodes" size="small" placeholder="Small" class="md:w-80 w-full" />
        <TreeSelect v-model="value2" :options="nodes" placeholder="Normal" class="md:w-80 w-full" />
        <TreeSelect v-model="value3" :options="nodes" size="large" placeholder="Large" class="md:w-80 w-full" />
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const value1 = ref(null);
const value2 = ref(null);
const value3 = ref(null);
const nodes = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

템플릿 (Template)

TreeSelect는 템플릿을 통한 커스터마이징을 위해 여러 슬롯을 제공해요.

<TreeSelect v-model="selectedValue" :options="nodes" placeholder="Select Item" class="md:w-80 w-full">
    <template #dropdownicon>
        <i class="pi pi-search" />
    </template>
    <template #header>
        <div class="font-medium px-3 py-2">Available Files</div>
    </template>
    <template #footer>
        <div class="px-3 pt-1 pb-2 flex justify-between">
            <Button label="Add New" severity="secondary" text size="small" icon="pi pi-plus" />
            <Button label="Remove All" severity="danger" text size="small" icon="pi pi-plus" />
        </div>
    </template>
</TreeSelect>
Composition API 예제
<template>
    <div class="card flex justify-center">
        <TreeSelect v-model="selectedValue" :options="nodes" placeholder="Select Item" class="md:w-80 w-full">
            <template #dropdownicon>
                <i class="pi pi-search" />
            </template>
            <template #header>
                <div class="font-medium px-3 py-2">Available Files</div>
            </template>
            <template #footer>
                <div class="px-3 pt-1 pb-2 flex justify-between">
                    <Button label="Add New" severity="secondary" text size="small" icon="pi pi-plus" />
                    <Button label="Remove All" severity="danger" text size="small" icon="pi pi-plus" />
                </div>
            </template>
        </TreeSelect>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { NodeService } from './service/NodeService';

const nodes = ref(null);
const selectedValue = ref(null);

onMounted(() => {
    NodeService.getTreeNodes().then((data) => (nodes.value = data));
});
<\/script>

Tree Select

Props (속성)

이름 타입 기본값 설명
modelValue any - 컴포넌트의 값.
defaultValue any - modelValue로 제어되지 않을 때 입력의 기본 값.
name string - 요소의 name 속성. 주로 폼 제출에 사용돼요.
options TreeNode[] - treenode 배열.
expandedKeys any - 제어 모드에서 확장 상태를 나타내는 key 맵.
showClear boolean false 활성화하면 값을 지우는 지우기 아이콘이 표시돼요.
clearIcon string - 지우기 버튼에 표시할 아이콘.
scrollHeight string 20rem 뷰포트의 높이. 목록 높이가 이 값을 넘으면 스크롤바가 생겨요.
selectionMode HintedString<"single" | "multiple" | "checkbox"> - 선택 모드를 정의해요.
fluid boolean null 활성화하면 컨테이너 너비의 100%를 차지해요.
appendTo HTMLElement | HintedString<"body" | "self"> body 오버레이가 붙을 위치를 지정하는 유효한 쿼리 셀렉터 또는 HTMLElement.
display HintedString<"comma" | "chip"> comma 선택된 항목을 표시하는 방식을 정의해요.
selectedItemsLabel string null 최대 선택 레이블 수를 넘었을 때 표시할 레이블.
maxSelectedLabels number - 선택 항목 레이블을 최대 몇 개까지 보여줄지 정해요.
metaKeySelection boolean false 여러 항목을 선택하는 방식을 정의해요. true면 항목을 선택하거나 해제할 때 metaKey를 눌러야 하고, false면 각 항목을 개별적으로 토글할 수 있어요. 터치 지원 기기에서는 metaKeySelection이 자동으로 꺼져요.
loading boolean false 로딩 인디케이터를 표시할지 여부.
loadingIcon string - 트리가 로딩 중일 때 표시할 아이콘.
loadingMode HintedString<"mask" | "icon"> mask 로딩 모드 표시.
filter boolean false 지정하면 항목을 필터링하는 입력 필드를 표시해요.
filterBy string | Function label 필터링이 활성화되면 filterBy가 검색 대상 필드(쉼표로 구분)를 결정해요. 필드 이름 목록 대신 TreeNode를 받는 콜러블을 제공할 수도 있어요.
filterMode HintedString<"lenient" | "strict"> lenient 필터링 모드.
filterPlaceholder string - 필터 입력이 비어 있을 때 표시할 플레이스홀더 텍스트.
filterLocale string - 필터링에 사용할 로케일. 기본 로케일은 호스트 환경의 현재 로케일이에요.
emptyMessage string No available options 선택 가능한 옵션이 없을 때 표시할 텍스트. 기본값은 PrimeVue 로케일 설정의 값을 따라요.
placeholder string - 선택 항목이 없을 때 표시할 레이블.
size HintedString<"small" | "large"> - 컴포넌트의 크기를 정의해요.
invalid boolean false 있으면 컴포넌트가 유효하지 않은 상태 스타일을 가져야 함을 지정해요.
disabled boolean false 있으면 컴포넌트가 비활성화되어야 함을 지정해요.
variant null | HintedString<"outlined" | "filled"> null 컴포넌트의 입력 variant를 지정해요.
tabindex string - 탭 순서에서 요소의 인덱스.
inputId string - 내부 input 요소의 식별자.
inputClass string | object - 입력 필드의 스타일 클래스.
inputStyle object - 입력 필드의 인라인 스타일.
inputProps InputHTMLAttributes - HTMLInputElement의 모든 속성을 컴포넌트 안 포커스 가능한 input 요소로 전달해요.
panelClass any - 오버레이 패널의 스타일 클래스.
ariaLabelledby string - 값이 하나 이상의 요소 ID여야 하는 레이블과 컴포넌트 사이의 관계를 설정해요.
ariaLabel string - 컴포넌트에 이름을 붙이는 문자열 값을 설정해요.
formControl Record<string, any> - 폼 컨트롤 객체. 주로 검증과 폼 상태 처리에 사용돼요.
dt any - 컴포넌트의 디자인 토큰으로 스코프드 CSS 변수를 생성해요.
pt PassThrough - 컴포넌트 내부 DOM 요소로 속성을 전달해요.
ptOptions any - 컴포넌트의 passthrough(pt) 옵션을 설정해요.
unstyled boolean false 활성화하면 코어의 컴포넌트 관련 스타일을 제거해요.

패스스루 옵션 (Pass Through Options)

이름 타입 설명
root TreeSelectPassThroughOptionType root의 DOM 요소로 속성을 전달해요.
labelContainer TreeSelectPassThroughOptionType 레이블 컨테이너의 DOM 요소로 속성을 전달해요.
label TreeSelectPassThroughOptionType 레이블의 DOM 요소로 속성을 전달해요.
clearIcon TreeSelectPassThroughOptionType 지우기 아이콘의 DOM 요소로 속성을 전달해요.
chipItem TreeSelectPassThroughOptionType 칩의 DOM 요소로 속성을 전달해요.
pcChip any Chip 컴포넌트로 속성을 전달해요.
dropdown TreeSelectPassThroughOptionType 드롭다운의 DOM 요소로 속성을 전달해요.
dropdownIcon TreeSelectPassThroughOptionType 드롭다운 아이콘의 DOM 요소로 속성을 전달해요.
panel TreeSelectPassThroughOptionType 패널의 DOM 요소로 속성을 전달해요.
treeContainer TreeSelectPassThroughOptionType 트리 컨테이너의 DOM 요소로 속성을 전달해요.
pcTree any Tree 컴포넌트로 속성을 전달해요.
emptyMessage TreeSelectPassThroughOptionType 빈 메시지의 DOM 요소로 속성을 전달해요.
hiddenInputContainer TreeSelectPassThroughOptionType 숨겨진 input 컨테이너의 DOM 요소로 속성을 전달해요.
hiddenInput TreeSelectPassThroughOptionType 숨겨진 input의 DOM 요소로 속성을 전달해요.
hooks any 모든 라이프사이클 훅을 관리해요.
transition TreeSelectPassThroughTransitionType Vue Transition API를 제어해요.

테마 (Theming)

CSS 클래스 (CSS Classes)

클래스 설명
p-treeselect 루트 요소의 클래스 이름
p-treeselect-label-container 레이블 컨테이너 요소의 클래스 이름
p-treeselect-label 레이블 요소의 클래스 이름
p-select-clear-icon 지우기 아이콘 요소의 클래스 이름
p-treeselect-chip-item 칩 항목 요소의 클래스 이름
p-treeselect-chip 칩 요소의 클래스 이름
p-treeselect-dropdown 드롭다운 요소의 클래스 이름
p-treeselect-dropdown-icon 드롭다운 아이콘 요소의 클래스 이름
p-treeselect-overlay 패널 요소의 클래스 이름
p-treeselect-tree-container 트리 컨테이너 요소의 클래스 이름
p-treeselect-empty-message 빈 메시지 요소의 클래스 이름

디자인 토큰 (Design Tokens)

토큰 CSS 변수 설명
treeselect.background --p-treeselect-background 루트의 배경
treeselect.disabled.background --p-treeselect-disabled-background 루트의 비활성 배경
treeselect.filled.background --p-treeselect-filled-background 루트의 채움 배경
treeselect.filled.hover.background --p-treeselect-filled-hover-background 루트의 채움 호버 배경
treeselect.filled.focus.background --p-treeselect-filled-focus-background 루트의 채움 포커스 배경
treeselect.border.color --p-treeselect-border-color 루트의 테두리 색
treeselect.hover.border.color --p-treeselect-hover-border-color 루트의 호버 테두리 색
treeselect.focus.border.color --p-treeselect-focus-border-color 루트의 포커스 테두리 색
treeselect.invalid.border.color --p-treeselect-invalid-border-color 루트의 유효하지 않은 상태 테두리 색
treeselect.color --p-treeselect-color 루트의 색
treeselect.disabled.color --p-treeselect-disabled-color 루트의 비활성 색
treeselect.placeholder.color --p-treeselect-placeholder-color 루트의 플레이스홀더 색
treeselect.invalid.placeholder.color --p-treeselect-invalid-placeholder-color 루트의 유효하지 않은 상태 플레이스홀더 색
treeselect.shadow --p-treeselect-shadow 루트의 그림자
treeselect.padding.x --p-treeselect-padding-x 루트의 가로 패딩
treeselect.padding.y --p-treeselect-padding-y 루트의 세로 패딩
treeselect.border.radius --p-treeselect-border-radius 루트의 테두리 반경
treeselect.focus.ring.width --p-treeselect-focus-ring-width 루트의 포커스 링 두께
treeselect.focus.ring.style --p-treeselect-focus-ring-style 루트의 포커스 링 스타일
treeselect.focus.ring.color --p-treeselect-focus-ring-color 루트의 포커스 링 색
treeselect.focus.ring.offset --p-treeselect-focus-ring-offset 루트의 포커스 링 오프셋
treeselect.focus.ring.shadow --p-treeselect-focus-ring-shadow 루트의 포커스 링 그림자
treeselect.transition.duration --p-treeselect-transition-duration 루트의 전환 지속 시간
treeselect.sm.font.size --p-treeselect-sm-font-size 루트의 small 글자 크기
treeselect.sm.padding.x --p-treeselect-sm-padding-x 루트의 small 가로 패딩
treeselect.sm.padding.y --p-treeselect-sm-padding-y 루트의 small 세로 패딩
treeselect.lg.font.size --p-treeselect-lg-font-size 루트의 large 글자 크기
treeselect.lg.padding.x --p-treeselect-lg-padding-x 루트의 large 가로 패딩
treeselect.lg.padding.y --p-treeselect-lg-padding-y 루트의 large 세로 패딩
treeselect.dropdown.width --p-treeselect-dropdown-width 드롭다운의 너비
treeselect.dropdown.color --p-treeselect-dropdown-color 드롭다운의 색
treeselect.overlay.background --p-treeselect-overlay-background 오버레이의 배경
treeselect.overlay.border.color --p-treeselect-overlay-border-color 오버레이의 테두리 색
treeselect.overlay.border.radius --p-treeselect-overlay-border-radius 오버레이의 테두리 반경
treeselect.overlay.color --p-treeselect-overlay-color 오버레이의 색
treeselect.overlay.shadow --p-treeselect-overlay-shadow 오버레이의 그림자
treeselect.tree.padding --p-treeselect-tree-padding 트리의 패딩
treeselect.clear.icon.color --p-treeselect-clear-icon-color 지우기 아이콘의 색
treeselect.empty.message.padding --p-treeselect-empty-message-padding 빈 메시지의 패딩
treeselect.chip.border.radius --p-treeselect-chip-border-radius 칩의 테두리 반경

더 알아보기 (Learn more)

요약: TreeSelect는 v-model과 options 컬렉션을 기본으로 쓰고, selectionMode로 single·multiple·checkbox 선택 방식을 바꿀 수 있어요. 필터링, 지연 로딩, 템플릿 슬롯 같은 확장 기능은 위의 각 섹션 예제를 참고하세요.