FloatingBar
FloatingBar는 하단에 고정되어 주요 액션을 포함하는 컴포넌트입니다.import { FloatingBar } from '@vapor-ui/core';
export default function Default() {
return (
<FloatingBar.Root>
<FloatingBar.Trigger>Open Floating Bar</FloatingBar.Trigger>
<FloatingBar.Popup>This is the floating bar content.</FloatingBar.Popup>
</FloatingBar.Root>
);
}Examples
Actions
FloatingBar는 다양한 액션 요소를 담을 수 있습니다.
import { Box, Button, FloatingBar } from '@vapor-ui/core';
export default function WithActions() {
return (
<FloatingBar.Root>
<FloatingBar.Trigger render={<Button />}>Open FloatingBar</FloatingBar.Trigger>
<FloatingBar.Popup>
<Button colorPalette="primary">Select All</Button>
<Box width="1px" backgroundColor="$gray-300" style={{ alignSelf: 'stretch' }} />
<Button colorPalette="danger">Delete</Button>
</FloatingBar.Popup>
</FloatingBar.Root>
);
}Controlled
FloatingBar는 제어 형태로 사용되어, 여러 상태를 동시에 관리할 수 있습니다.
import { useState } from 'react';
import {
Badge,
Box,
Button,
Checkbox,
Field,
FloatingBar,
IconButton,
Text,
VStack,
} from '@vapor-ui/core';
import { CloseOutlineIcon } from '@vapor-ui/icons';
const options = [
{ id: 'item1', label: 'First Item', defaultChecked: false },
{ id: 'item2', label: 'Second Item', defaultChecked: false },
{ id: 'item3', label: 'Third Item', defaultChecked: false },
];
export default function Controlled() {
const [selectedItems, setSelectedItems] = useState(() =>
Object.fromEntries(options.map((option) => [option.id, option.defaultChecked])),
);
const selectedCount = Object.values(selectedItems).filter(Boolean).length;
const [open, setOpen] = useState(selectedCount > 0);
const handleItemChange = (itemId: string, isChecked: boolean) => {
setSelectedItems((prev) => {
const newSelectedItems = { ...prev, [itemId]: isChecked };
const newSelectedCount = Object.values(newSelectedItems).filter(Boolean).length;
setOpen(newSelectedCount > 0);
return newSelectedItems;
});
};
const handleSelectAll = () => {
setSelectedItems(Object.fromEntries(options.map((option) => [option.id, true])));
setOpen(true);
};
const handleClearAll = () => {
setSelectedItems(Object.fromEntries(options.map((option) => [option.id, false])));
setOpen(false);
};
return (
<>
<Text render={<div />} marginBottom="$200">
Select options below to see the FloatingBar.
</Text>
<VStack justifyContent="center">
{options.map((option) => (
<Field.Root
key={option.id}
display="flex"
flexDirection="row"
alignItems="center"
gap="$100"
>
<Checkbox.Root
checked={selectedItems[option.id]}
onCheckedChange={(checked) => handleItemChange(option.id, checked)}
/>
<Field.Label>{option.label}</Field.Label>
</Field.Root>
))}
</VStack>
<FloatingBar.Root open={open} onOpenChange={setOpen}>
<FloatingBar.Popup>
<Badge colorPalette="primary">{selectedCount} Selected</Badge>
<Box width="1px" backgroundColor="$gray-300" style={{ alignSelf: 'stretch' }} />
<Button colorPalette="primary" onClick={handleSelectAll}>
Select All
</Button>
<Button colorPalette="danger" onClick={handleClearAll}>
Delete
</Button>
<FloatingBar.Close
render={
<IconButton
aria-label="close floating-bar"
variant="ghost"
colorPalette="secondary"
/>
}
>
<CloseOutlineIcon />
</FloatingBar.Close>
</FloatingBar.Popup>
</FloatingBar.Root>
</>
);
}Props Table
FloatingBar.Root
FloatingBar의 루트 컨테이너로, 전체 FloatingBar 컴포넌트의 상태와 동작을 관리합니다.
Loading component documentation...
FloatingBar.Trigger
FloatingBar를 여는 트리거 요소입니다.
Loading component documentation...
FloatingBar.Close
FloatingBar를 닫는 버튼 컴포넌트입니다.
Loading component documentation...
FloatingBar.Popup
FloatingBar의 실제 콘텐츠를 담는 컨테이너입니다. Portal과 Positioner를 조합하여 구성됩니다.
Loading component documentation...
FloatingBar.PortalPrimitive
FloatingBar를 DOM의 다른 위치에 렌더링하는 포털 컴포넌트입니다.
Loading component documentation...
FloatingBar.PositionerPrimitive
FloatingBar의 위치를 설정하는 컴포넌트입니다.
Loading component documentation...
FloatingBar.PopupPrimitive
FloatingBar의 실제 팝업 콘텐츠 영역입니다.
Loading component documentation...