import { Menu } from 'sud-ui';계층형 메뉴 구조가 필요할 때
아코디언 또는 팝오버 형태로 하위 메뉴를 표시하고 싶을 때
메뉴 항목의 선택 상태를 관리해야 할 때
수평 또는 수직으로 메뉴를 배치하고 싶을 때
import React from 'react';
import { Menu, toast } from 'sud-ui';
const BasicMenu = () => {
const items = [
{
key: "home",
label: "Home",
onClick: () => toast.info("Home clicked")
},
{
key: "components",
label: "Components",
children: [
{
key: "button",
label: "Button",
onClick: () => toast.info("Button clicked")
},
{
key: "input",
label: "Input",
onClick: () => toast.info("Input clicked")
}
]
},
{
key: "about",
label: "About",
onClick: () => toast.info("About clicked")
}
];
return <Menu items={items} />;
};
export default BasicMenu;import React from 'react';
import { Menu, toast } from 'sud-ui';
const HorizontalPopoverMenu = () => {
const items = [
{
key: "home",
label: "Home",
onClick: () => toast.info("Home clicked")
},
{
key: "components",
label: "Components",
children: [
{
key: "button",
label: "Button",
onClick: () => toast.info("Button clicked")
},
{
key: "input",
label: "Input",
onClick: () => toast.info("Input clicked")
}
]
},
{
key: "about",
label: "About",
onClick: () => toast.info("About clicked")
}
];
return <Menu items={items} expandType="popover" horizontal border />;
};
export default HorizontalPopoverMenu;import React from 'react';
import { Menu, toast } from 'sud-ui';
const CustomColorMenu = () => {
const items = [
{
key: "home",
label: "Home",
onClick: () => toast.info("Home clicked")
},
{
key: "components",
label: "Components",
children: [
{
key: "button",
label: "Button",
onClick: () => toast.info("Button clicked")
},
{
key: "input",
label: "Input",
onClick: () => toast.info("Input clicked")
}
]
},
{
key: "about",
label: "About",
onClick: () => toast.info("About clicked")
}
];
return (
<Menu
items={items}
colorType="sub"
selectedColor="purple"
selectedTextColor="white"
hoverColor="yellow"
hoverTextColor="black"
/>
);
};
export default CustomColorMenu;import React from 'react';
import { Menu, toast } from 'sud-ui';
const PopoverMenu = () => {
const items = [
{
key: "home",
label: "Home",
onClick: () => toast.info("Home clicked")
},
{
key: "components",
label: "Components",
children: [
{
key: "button",
label: "Button",
onClick: () => toast.info("Button clicked")
},
{
key: "input",
label: "Input",
onClick: () => toast.info("Input clicked")
}
]
},
{
key: "about",
label: "About",
onClick: () => toast.info("About clicked")
}
];
return <Menu items={items} expandType="popover" border />;
};
export default PopoverMenu;import React from 'react';
import { Menu, toast } from 'sud-ui';
const GroupMenu = () => {
const items = [
{
key: "general",
title: "General",
mode: "group",
children: [
{ key: "button", label: "Button" },
{ key: "icon", label: "Icon" }
]
},
{
key: "layout",
title: "Layout",
mode: "group",
children: [
{ key: "header", label: "Header" },
{ key: "footer", label: "Footer" }
]
}
];
return <Menu items={items} />;
};
export default GroupMenu;import React from 'react';
import { Menu, toast } from 'sud-ui';
const DividerMenu = () => {
const items = [
{
key: "home",
label: "Home",
onClick: () => toast.info("Home clicked")
},
{
key: "components",
label: "Components",
children: [
{
key: "button",
label: "Button",
onClick: () => toast.info("Button clicked")
},
{
key: "input",
label: "Input",
onClick: () => toast.info("Input clicked")
}
]
},
{
key: "about",
label: "About",
onClick: () => toast.info("About clicked")
}
];
return <Menu items={items} divider />;
};
export default DividerMenu;속성 이름 | 설명 | 타입 | 기본값 |
|---|
| items | 메뉴 항목 목록 (MenuItem[]) | MenuItem[] | [] |
| selectedKey | 현재 선택된 메뉴 항목의 key | string | - |
| defaultSelectedKey | 비제어형 메뉴의 초기 선택 key입니다. accordion과 popover 확장 방식 모두에 적용됩니다. | string | - |
| onSelect | 메뉴 항목 선택 시 호출되는 함수 (key: string) => void | (key: string) => void | - |
| expandType | 하위 메뉴 확장 방식 (MenuExpandType) | accordion | popover | accordion |
| horizontal | 메뉴를 수평으로 배치할지 여부 (expandType이 'popover'일 때만 동작) | boolean | false |
| selectedColor | 선택된 메뉴 항목의 배경색(palette값 또는 HEX code) | string | - |
| selectedTextColor | 선택된 메뉴 항목의 텍스트 색상(palette값 또는 HEX code) | string | - |
| hoverColor | 호버 시 메뉴 항목의 배경색(palette값 또는 HEX code) | string | - |
| hoverTextColor | 호버 시 메뉴 항목의 텍스트 색상(palette값 또는 HEX code) | string | - |
| divider | 메뉴 항목 사이에 구분선을 표시할지 여부 | boolean | false |
| dividerColor | 구분선의 색상(palette값 또는 HEX code) | string | - |
| colorType | 메뉴의 색상 테마 | default | primary | success | warning | danger | info | red | rose | coral | orange | volcano | apricot | yellow | gold | amber | green | lime | mint | blue | sky | cerulean | indigo | cobalt | navy | purple | plum | orchid | forest | sage | warm-gray | cool-gray | neutral | text | ghost | default |
| background | 메뉴의 배경색(palette값 또는 HEX code) | string | - |
| color | 메뉴의 텍스트 색상(palette값 또는 HEX code) | string | - |
| border | 메뉴의 테두리 표시 여부 | boolean | false |
| borderColor | 메뉴의 테두리 색상(palette값 또는 HEX code) | string | - |
| borderType | 메뉴의 테두리 스타일 | solid | dashed | dotted | double | groove | ridge | inset | outset | none | solid |
| borderWeight | 메뉴의 테두리 두께 | number | 1 |
| shape | 메뉴의 모양 | square | circle | rounded | capsule | rounded |
| shadow | 메뉴의 그림자 효과 | none | sm | md | lg | sm |
| placement | 팝오버 메뉴의 위치 (expandType이 'popover'일 때만 동작) | [ top | bottom | left | right , top | bottom | left | right ] | ['bottom', 'right'] |
| className | 추가 클래스명 | string | - |
| style | 추가 스타일 | CSSProperties | - |
| level | 메뉴의 중첩 레벨 | number | 0 |
| parentContentRef | 부모 컨텐츠 요소의 참조 | RefObject<HTMLElement> | - |