NavigationMenu
NavigationMenu 컴포넌트는 웹사이트의 주요 네비게이션 영역을 구성하 는 데 사용됩니다. 드롭다운 메뉴와 링크 목록을 포함할 수 있으며, 사용자가 웹사이트의 다양한 섹션으로 쉽게 이동할 수 있도록 도와줍니다.
기본 사용법
기본적인 네비게이션 메뉴 구현 예시입니다.
import { NavigationMenu } from 'react-common-components-library';
function BasicExample() {
return (
<NavigationMenu
items={[
{
label: 'Getting started',
content: {
title: 'Introduction',
description: 'Re-usable components built using Radix UI and Tailwind CSS',
links: [
{
title: 'Introduction',
description: 'Re-usable components built using Radix UI and Tailwind CSS',
href: '/docs/introduction',
},
{
title: 'Installation',
description: 'How to install dependencies and structure your app.',
href: '/docs/installation',
},
{
title: 'Typography',
description: 'Styles for headings, paragraphs, lists...etc',
href: '/docs/typography',
},
],
},
active: true,
},
{
label: 'Components',
content: {
links: [
{
title: 'Accordion',
description: 'A vertically stacked set of interactive headings.',
href: '/docs/components/accordion',
},
{
title: 'Alert Dialog',
description: 'A modal dialog that interrupts the user with important content.',
href: '/docs/components/alert-dialog',
},
{
title: 'Button',
description: 'Displays a button or a component that looks like a button.',
href: '/docs/components/button',
},
],
},
},
{
label: 'Documentation',
content: {
links: [
{
title: 'API Reference',
description: 'Complete API reference for all components.',
href: '/docs/api-reference',
},
{
title: 'Styling Guide',
description: 'Learn how to customize the look and feel of components.',
href: '/docs/styling-guide',
},
],
},
},
{
label: 'Blog',
href: '/blog',
},
]}
/>
);
}
커스텀 콘텐츠 사용
네비게이션 메뉴의 드롭다운에 커스텀 콘텐츠를 추가할 수 있습니다.
import { NavigationMenu } from 'react-common-components-library';
function CustomContentExample() {
return (
<NavigationMenu
items={[
{
label: 'Getting started',
href: '/getting-started',
},
{
label: 'Components',
content: {
customContent: (
<div style={{ padding: '20px', maxWidth: '800px', margin: '0 auto' }}>
<h2>Component Categories</h2>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '16px' }}>
<div style={{ background: '#F3F4F6', padding: '16px', borderRadius: '8px' }}>
<h3>Layout</h3>
<ul>
<li>Container</li>
<li>Box</li>
<li>Grid</li>
<li>Stack</li>
</ul>
</div>
<div style={{ background: '#F3F4F6', padding: '16px', borderRadius: '8px' }}>
<h3>Forms</h3>
<ul>
<li>Input</li>
<li>Checkbox</li>
<li>Select</li>
<li>Radio</li>
</ul>
</div>
<div style={{ background: '#F3F4F6', padding: '16px', borderRadius: '8px' }}>
<h3>Feedback</h3>
<ul>
<li>Alert</li>
<li>Toast</li>
<li>Progress</li>
<li>Skeleton</li>
</ul>
</div>
</div>
</div>
),
},
},
{
label: 'Blog',
href: '/blog',
},
]}
/>
);
}
단순 링크 사용
드롭다운 없이 단순 링크만 사용할 수도 있습니다.
import { NavigationMenu } from 'react-common-components-library';
function SimpleLinksExample() {
return (
<NavigationMenu
items={[
{
label: 'Home',
href: '/',
},
{
label: 'About',
href: '/about',
},
{
label: 'Services',
href: '/services',
},
{
label: 'Contact',
href: '/contact',
},
]}
/>
);
}
너비 조정
NavigationMenu의 너비를 조정할 수 있습니다.
import { NavigationMenu } from 'react-common-components-library';
function WidthExample() {
return (
<NavigationMenu
width="800px"
items={[
{
label: 'Home',
href: '/',
},
{
label: 'About',
href: '/about',
},
{
label: 'Services',
href: '/services',
},
{
label: 'Contact',
href: '/contact',
},
]}
/>
);
}
API 참조
NavigationMenu
속성 | 타입 | 기본값 | 설명 |
---|---|---|---|
items | NavigationItemProps[] | 필수 | 네비게이션 메뉴 항목 목록 |
className | string | '' | 네비게이션 메뉴에 적용할 추가 CSS 클래스 |
style | React.CSSProperties | - | 네비게이션 메뉴에 적용할 스타일 |
width | string | '100%' | 네비게이션 메뉴의 너비 |
NavigationItemProps
속성 | 타입 | 기본값 |
---|