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

SpeedDial

원문 보기 위키 갱신

복합 구성(compound composition)을 갖춘, 스타일 없고 접근 가능한 스피드 다이얼 컴포넌트예요.

출처: 문서

본문

기능 (Features)

  • 하위 컴포넌트 구성 API: Root, Trigger, List, Item, Action
  • 네 가지 레이아웃 타입: 선형(linear), 원형(circle), 반원(semi-circle), 사분원(quarter-circle)
  • 선형 및 방사형 배치를 위한 여덟 가지 방향 옵션
  • 항목별 설정 가능한 지연(staggered) 전환 지연
  • 외부 클릭 시 자동 닫힘

사용법 (Usage)

import { SpeedDial } from 'primereact/speeddial';
<SpeedDial.Root>
    <SpeedDial.Trigger></SpeedDial.Trigger>
    <SpeedDial.List>
        <SpeedDial.Item index={0}>
            <SpeedDial.Action></SpeedDial.Action>
        </SpeedDial.Item>
    </SpeedDial.List>
</SpeedDial.Root>

동작 (Behavior)

다형적 렌더링 (Polymorphic Rendering)

as를 사용해 하위 컴포넌트가 렌더링할 HTML 요소를 바꿀 수 있어요.

<SpeedDial.Root as="nav">
    <SpeedDial.Trigger as="div">...</SpeedDial.Trigger>
    <SpeedDial.List as="div">
        <SpeedDial.Item as="div" index={0}>
            <SpeedDial.Action as="a" href="/edit">
                ...
            </SpeedDial.Action>
        </SpeedDial.Item>
    </SpeedDial.List>
</SpeedDial.Root>

기본 요소: Root=div, Trigger=button, List=ul, Item=li, Action=button.

렌더 함수 자식 (Render Function Children)

Item은 컴포넌트 인스턴스에 접근할 수 있는 렌더 함수를 children으로 받아요.

<SpeedDial.Item index={0}>{(instance) => <button>{instance.speeddial?.state.visible ? 'Open' : 'Closed'}</button>}</SpeedDial.Item>

Pass Through

<DocPTViewer name="speeddial-pt" components={['SpeedDialRoot']} />

API

SpeedDialRoot

Attribute Value
data-scope "speeddial"
data-part "root"
Label Type Description
root SpeedDialRootPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.
trigger SpeedDialRootPassThroughType<HTMLAttributes> Used to pass attributes to the trigger's DOM element.
list SpeedDialRootPassThroughType<HTMLAttributes> Used to pass attributes to the list's DOM element.
item SpeedDialRootPassThroughType<HTMLAttributes> Used to pass attributes to the item's DOM element.
action SpeedDialRootPassThroughType<HTMLAttributes> Used to pass attributes to the action's DOM element.

SpeedDialTrigger

Attribute Value
data-scope "speeddial"
data-part "trigger"
data-open Present when menu is open
data-closed Present when menu is closed
Label Type Description
root SpeedDialTriggerPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

SpeedDialList

Attribute Value
data-scope "speeddial"
data-part "list"
Label Type Description
root SpeedDialListPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

SpeedDialItem

Attribute Value
data-scope "speeddial"
data-part "item"
data-active Present when item is focused
Label Type Description
root SpeedDialItemPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

SpeedDialAction

Attribute Value
data-scope "speeddial"
data-part "action"
Label Type Description
root SpeedDialActionPassThroughType<HTMLAttributes> Used to pass attributes to the root's DOM element.

접근성 (Accessibility)

스크린 리더 (Screen Reader)

트리거 버튼은 버튼과 팝업 메뉴 사이의 관계를 정의하는 aria-haspopup, aria-expanded, aria-controls를 포함해요. 팝업 목록은 role="menu"를 사용하며 각 액션은 role="menuitem"을 가져요. 각 Action에 접근 가능한 이름을 주려면 aria-label을 사용하세요.

메뉴 버튼 키보드 지원 (Menu Button Keyboard Support)

Key Function
enter Toggles the visibility of the menu.
space Toggles the visibility of the menu.
down arrow Opens the menu and moves focus to the first item.
up arrow Opens the menu and moves focus to the last item.
right arrow Opens the menu and moves focus to the last item.
left arrow Opens the menu and moves focus to the first item.
escape Closes the menu.

메뉴 키보드 지원 (Menu Keyboard Support)

Key Function
enter Activates the menuitem, closes the menu and sets focus on the menu button.
space Activates the menuitem, closes the menu and sets focus on the menu button.
escape Closes the menu and sets focus on the menu button.
arrow keys Navigates between the menu items.
home Moves focus to the first item.
end Moves focus to the last item.

더 알아보기 (Learn more)