ToggleButtonGroup
ToggleButtonGroup 컴포넌트는 토글 버튼 그룹을 만드는 데 사용해요. 여러 버튼 중 하나 또는 여러 개를 동시에 활성 상태로 유지하는 선택형 그룹이 필요할 때 쓰기 좋아요.
출처: 문서
본문
사용법 (Usage)
import { ToggleButtonGroup } from '@primereact/ui/togglebuttongroup';
<ToggleButtonGroup></ToggleButtonGroup>
예시 (Examples)
기본 (Basic)
한 번에 하나 이상 활성화할 수 있는 토글 버튼 그룹이에요.
제어 (Controlled)
value와 onValueChange 속성으로 ToggleButton.Group의 상태를 제어할 수 있어요.
다중 선택 (Multiple)
ToggleButton.Group은 기본적으로 항목 하나만 선택할 수 있어요. multiple 옵션을 설정하면 여러 항목을 선택할 수 있어요. 다중 선택의 경우 model 속성은 배열이어야 해요.
크기 (Sizes)
ToggleButton.Group은 size 속성으로 기본 크기 대신 small과 large 크기를 제공해요.
유동 (Fluid)
fluid를 활성화하면 ToggleButtonGroup이 부모 컨테이너의 전체 너비를 차지하면서 버튼들을 균등하게 분배해요.
무효 (Invalid)
invalid prop으로 무효 상태를 표시해서 검증 실패를 나타낼 수 있어요. 이 스타일은 폼 검증 라이브러리와 통합할 때 유용해요.
비활성화 (Disabled)
disabled가 있으면 요소 전체를 편집하거나 포커스할 수 없어요. 일부 옵션은 각각의 disabled 속성으로 비활성화할 수도 있어요.
관련 문서 (Related)
서브 컴포넌트 (Sub-Components)
ToggleButtonRoot, ToggleButtonIndicator, ToggleButtonGroup 컴포넌트 문서는 Primitive API에서 확인하세요.
훅 (Hooks)
useToggleButton, useToggleButtonGroup 훅 문서는 Headless API에서 확인하세요.
접근성 (Accessibility)
WAI-ARIA 준수 세부사항과 키보드 지원은 ToggleButton Primitive에서 확인하세요.
테마 (Theming)
CSS 클래스 (CSS Classes)
styled 모드에서 사용하는 클래스 이름 목록이에요.
| ClassName | Description |
|---|---|
| p-togglebutton | Class name of the root element |
| p-togglebutton-content | Class name of the content element |
| ClassName | Description |
|---|---|
| p-togglebutton-group | Class name of the root element |
디자인 토큰 (Design Tokens)
디자인 토큰 목록이에요.
| Token | CSS Variable | Description |
|---|---|---|
| togglebutton.padding | --p-togglebutton-padding | Padding of root |
| togglebutton.border.radius | --p-togglebutton-border-radius | Border radius of root |
| togglebutton.gap | --p-togglebutton-gap | Gap of root |
| togglebutton.font.size | --p-togglebutton-font-size | Font size of root |
| togglebutton.font.weight | --p-togglebutton-font-weight | Font weight of root |
| togglebutton.disabled.background | --p-togglebutton-disabled-background | Disabled background of root |
| togglebutton.disabled.border.color | --p-togglebutton-disabled-border-color | Disabled border color of root |
| togglebutton.disabled.color | --p-togglebutton-disabled-color | Disabled color of root |
| togglebutton.invalid.border.color | --p-togglebutton-invalid-border-color | Invalid border color of root |
| togglebutton.focus.ring.width | --p-togglebutton-focus-ring-width | Focus ring width of root |
| togglebutton.focus.ring.style | --p-togglebutton-focus-ring-style | Focus ring style of root |
| togglebutton.focus.ring.color | --p-togglebutton-focus-ring-color | Focus ring color of root |
| togglebutton.focus.ring.offset | --p-togglebutton-focus-ring-offset | Focus ring offset of root |
| togglebutton.focus.ring.shadow | --p-togglebutton-focus-ring-shadow | Focus ring shadow of root |
| togglebutton.transition.duration | --p-togglebutton-transition-duration | Transition duration of root |
| togglebutton.sm.font.size | --p-togglebutton-sm-font-size | Sm font size of root |
| togglebutton.sm.padding | --p-togglebutton-sm-padding | Sm padding of root |
| togglebutton.lg.font.size | --p-togglebutton-lg-font-size | Lg font size of root |
| togglebutton.lg.padding | --p-togglebutton-lg-padding | Lg padding of root |
| togglebutton.background | --p-togglebutton-background | Background of root |
| togglebutton.checked.background | --p-togglebutton-checked-background | Checked background of root |
| togglebutton.hover.background | --p-togglebutton-hover-background | Hover background of root |
| togglebutton.border.color | --p-togglebutton-border-color | Border color of root |
| togglebutton.color | --p-togglebutton-color | Color of root |
| togglebutton.hover.color | --p-togglebutton-hover-color | Hover color of root |
| togglebutton.checked.color | --p-togglebutton-checked-color | Checked color of root |
| togglebutton.checked.border.color | --p-togglebutton-checked-border-color | Checked border color of root |
| togglebutton.icon.disabled.color | --p-togglebutton-icon-disabled-color | Disabled color of icon |
| togglebutton.icon.color | --p-togglebutton-icon-color | Color of icon |
| togglebutton.icon.hover.color | --p-togglebutton-icon-hover-color | Hover color of icon |
| togglebutton.icon.checked.color | --p-togglebutton-icon-checked-color | Checked color of icon |
| togglebutton.content.padding | --p-togglebutton-content-padding | Padding of content |
| togglebutton.content.border.radius | --p-togglebutton-content-border-radius | Border radius of content |
| togglebutton.content.checked.shadow | --p-togglebutton-content-checked-shadow | Checked shadow of content |
| togglebutton.content.sm.padding | --p-togglebutton-content-sm-padding | Sm padding of content |
| togglebutton.content.lg.padding | --p-togglebutton-content-lg-padding | Lg padding of content |
| togglebutton.content.checked.background | --p-togglebutton-content-checked-background | Checked background of content |
더 알아보기 (Learn more)
- ToggleButton 서브 컴포넌트의 세부 API를 Primitive 문서에서 살펴보세요.
multiple과fluid를 조합해 다양한 선택형 툴바를 만들어 보세요.