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

Vue Fieldset 컴포넌트

원문 보기 위키 갱신

Fieldset은 콘텐츠 토글 기능을 갖춘 그룹핑 컴포넌트예요. 관련 입력이나 설명을 하나의 테두리로 묶고, 필요하면 접었다 폈다 할 수 있어요.

출처: 문서

본문

Vue Fieldset Component

Fieldset is a grouping component with a content toggle feature.

Import

import Fieldset from 'primevue/fieldset';

Accessibility

Screen Reader Fieldset 컴포넌트는 시맨틱 fieldset 요소를 사용해요. toggleable 옵션이 활성화되면 legend 요소 안에 button 요소가 포함되는데, 이 버튼은 콘텐츠 섹션의 id를 정의하는 aria-controls와 가시성 상태를 위한 aria-expanded를 가져요. 버튼을 읽을 값은 기본적으로 legend 프로퍼티의 값이고, toggleButtonProps 프로퍼티로 aria-label 또는 aria-labelledby를 정의해 커스터마이징할 수 있어요. 콘텐츠는 region을 사용하고, 콘텐츠 토글 버튼의 aria-controls와 일치하는 id와 헤더의 id를 가리키는 aria-labelledby를 정의해요. Content Toggle Button Keyboard Support Key Function tab 페이지 탭 순서에서 다음 포커스 가능 요소로 포커스를 옮겨요. shift + tab 페이지 탭 순서에서 이전 포커스 가능 요소로 포커스를 옮겨요. enter 콘텐츠 가시성을 토글해요. space 콘텐츠 가시성을 토글해요.

Basic

간단한 Fieldset은 legend 프로퍼티와 자식 콘텐츠로 만들어요.

<Fieldset legend="Header">
    <p class="m-0">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
</Fieldset>

Template

legend 섹션은 템플릿으로 커스텀 콘텐츠를 넣어 꾸밀 수 있어요.

<Fieldset>
    <template #legend>
        <div class="flex items-center pl-2">
            <Avatar image="/images/avatar/amyelsner.png" shape="circle" />
            <span class="font-bold p-2">Amy Elsner</span>
        </div>
    </template>
    <p class="m-0">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
</Fieldset>
Composition API Example
<template>
    <div class="card">
        <Fieldset>
            <template #legend>
                <div class="flex items-center pl-2">
                    <Avatar image="https://primefaces.org/cdn/primevue/images/avatar/amyelsner.png" shape="circle" />
                    <span class="font-bold p-2">Amy Elsner</span>
                </div>
            </template>
            <p class="m-0">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
                Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
            </p>
        </Fieldset>
    </div>
</template>

<script setup>
<\/script>

Toggleable

toggleable 옵션을 활성화하면 fieldset의 콘텐츠를 펼치고 접을 수 있어요.

<Fieldset legend="Header" :toggleable="true">
    <p class="m-0">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
        consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
</Fieldset>
Composition API Example
<template>
    <div class="card">
        <Fieldset legend="Header" :toggleable="true">
            <p class="m-0">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
                Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
            </p>
        </Fieldset>
    </div>
</template>

<script setup>
<\/script>

Fieldset

Props

Name Type Default Description
legend string - Header text of the fieldset.
toggleable boolean false When specified, content can toggled by clicking the legend.
collapsed boolean false Defines the default visibility state of the content.
toggleButtonProps AnchorHTMLAttributes - Used to pass the custom value to read for the AnchorHTMLAttributes inside the component.
dt any - It generates scoped CSS variables using design tokens for the component.
pt PassThrough - Used to pass attributes to DOM elements inside the component.
ptOptions any - Used to configure passthrough(pt) options of the component.
unstyled boolean false When enabled, it removes component related styles in the core.

Slots

Name Parameters Description
default Function

Pass Through Options

Name Type Description
root FieldsetPassThroughOptionType Used to pass attributes to the root's DOM element.
legend FieldsetPassThroughOptionType Used to pass attributes to the legend's DOM element.
toggleButton FieldsetPassThroughOptionType Used to pass attributes to the toggle button's DOM element.
toggleIcon FieldsetPassThroughOptionType Used to pass attributes to the toggle icon's DOM element.
legendLabel FieldsetPassThroughOptionType Used to pass attributes to the legend label's DOM element.
contentContainer FieldsetPassThroughOptionType Used to pass attributes to the content container's DOM element.
contentWrapper FieldsetPassThroughOptionType Used to pass attributes to the content wrapper DOM element.
content FieldsetPassThroughOptionType Used to pass attributes to the content's DOM element.
hooks any Used to manage all lifecycle hooks.
transition FieldsetPassThroughTransitionType Used to control Vue Transition API.

Theming

CSS Classes

Class Description
p-fieldset Class name of the root element
p-fieldset-legend Class name of the legend element
p-fieldset-legend-label Class name of the legend label element
p-fieldset-toggle-icon Class name of the toggle icon element
p-fieldset-content-container Class name of the content container element
p-fieldset-content Class name of the content element

Design Tokens

Token CSS Variable Description
fieldset.background --p-fieldset-background Background of root
fieldset.border.color --p-fieldset-border-color Border color of root
fieldset.border.radius --p-fieldset-border-radius Border radius of root
fieldset.color --p-fieldset-color Color of root
fieldset.padding --p-fieldset-padding Padding of root
fieldset.transition.duration --p-fieldset-transition-duration Transition duration of root
fieldset.legend.background --p-fieldset-legend-background Background of legend
fieldset.legend.hover.background --p-fieldset-legend-hover-background Hover background of legend
fieldset.legend.color --p-fieldset-legend-color Color of legend
fieldset.legend.hover.color --p-fieldset-legend-hover-color Hover color of legend
fieldset.legend.border.radius --p-fieldset-legend-border-radius Border radius of legend
fieldset.legend.border.width --p-fieldset-legend-border-width Border width of legend
fieldset.legend.border.color --p-fieldset-legend-border-color Border color of legend
fieldset.legend.padding --p-fieldset-legend-padding Padding of legend
fieldset.legend.gap --p-fieldset-legend-gap Gap of legend
fieldset.legend.font.weight --p-fieldset-legend-font-weight Font weight of legend
fieldset.legend.focus.ring.width --p-fieldset-legend-focus-ring-width Focus ring width of legend
fieldset.legend.focus.ring.style --p-fieldset-legend-focus-ring-style Focus ring style of legend
fieldset.legend.focus.ring.color --p-fieldset-legend-focus-ring-color Focus ring color of legend
fieldset.legend.focus.ring.offset --p-fieldset-legend-focus-ring-offset Focus ring offset of legend
fieldset.legend.focus.ring.shadow --p-fieldset-legend-focus-ring-shadow Focus ring shadow of legend
fieldset.toggle.icon.color --p-fieldset-toggle-icon-color Color of toggle icon
fieldset.toggle.icon.hover.color --p-fieldset-toggle-icon-hover-color Hover color of toggle icon
fieldset.content.padding --p-fieldset-content-padding Padding of content

더 알아보기 (Learn more)