diff --git a/apps/www/src/app/examples/page.tsx b/apps/www/src/app/examples/page.tsx index 5eb06a1d6..58fde5848 100644 --- a/apps/www/src/app/examples/page.tsx +++ b/apps/www/src/app/examples/page.tsx @@ -14,6 +14,7 @@ import { IconButton, Indicator, InputField, + Navbar, Popover, RangePicker, Search, @@ -153,6 +154,76 @@ const Page = () => { /* comment */ /* ---------- __ */`} + {/* Navbar Examples */} + + Navbar Examples + + + + + Basic Navbar: + + + + Explore + + + + ) => + setSearch1(e.target.value) + } + onClear={() => setSearch1('')} + size='small' + style={{ width: '200px' }} + /> + + + + + + + + Sticky Navbar: + + + + Sticky Navigation + + + + + + + + + + + { You can filter team members by: - diff --git a/apps/www/src/content/docs/components/navbar/demo.ts b/apps/www/src/content/docs/components/navbar/demo.ts new file mode 100644 index 000000000..99c61e1a3 --- /dev/null +++ b/apps/www/src/content/docs/components/navbar/demo.ts @@ -0,0 +1,137 @@ +'use client'; + +export const preview = { + type: 'code', + code: ` + + + Explore + + + + + + + ` +}; + +export const stickyDemo = { + type: 'code', + tabs: [ + { + name: 'Default', + code: ` + + + Navigation + + + + + + + ` + }, + { + name: 'Sticky', + code: ` + + + Navigation + + + + + + + ` + } + ] +}; + +export const sectionsDemo = { + type: 'code', + tabs: [ + { + name: 'Start Only', + code: ` + + + Brand Name + + ` + }, + { + name: 'End Only', + code: ` + + + + + + ` + }, + { + name: 'Both Sections', + code: ` + + + Explore + + + + + + ` + } + ] +}; + +export const accessibilityDemo = { + type: 'code', + tabs: [ + { + name: 'Custom aria-label', + code: ` + + + Brand + + + + + ` + }, + { + name: 'With aria-labelledby', + code: ` + <> + + + Brand + + + + + + ` + }, + { + name: 'Section Labels', + code: ` + + + Brand + + + + + + ` + } + ] +}; diff --git a/apps/www/src/content/docs/components/navbar/index.mdx b/apps/www/src/content/docs/components/navbar/index.mdx new file mode 100644 index 000000000..25b754341 --- /dev/null +++ b/apps/www/src/content/docs/components/navbar/index.mdx @@ -0,0 +1,82 @@ +--- +title: Navbar +description: A horizontal navigation bar component with flexible left and right sections for building site headers and navigation. +--- + +import { + preview, + stickyDemo, + sectionsDemo, + accessibilityDemo, +} from "./demo.ts"; + + + +## Usage + +```tsx +import { Navbar } from "@raystack/apsara"; +``` + +## Component Structure + +The Navbar component uses a composite pattern, providing modular sub-components for flexible navigation layouts: + +- `Navbar` - Root container that wraps the navigation bar +- `Navbar.Start` - Left section container for brand, logo, or primary navigation +- `Navbar.End` - Right section container for actions, search, or secondary navigation + +## Navbar Props + + + +### Navbar.Start Props + +The start section is a container component that accepts all `div` props. It's commonly used for brand logos, primary navigation links, or page titles. + + + +### Navbar.End Props + +The end section is a container component that accepts all `div` props. It's commonly used for search inputs, action buttons, user menus, or secondary navigation. + + + +## Examples + +### Sticky Navigation + +The Navbar can be made sticky to remain visible at the top of the viewport when scrolling. + + + +### Section Layouts + +You can use either or both sections depending on your needs. The sections automatically position themselves with proper spacing. + + + +### Accessibility + +The Navbar supports custom ARIA labels for better screen reader support. You can provide descriptive labels for the entire navbar or individual sections. + + + +## Accessibility + +The Navbar implements the following accessibility features: + +- Proper ARIA roles and attributes + - `role="navigation"` for the main navbar + - `role="group"` for Start and End sections when `aria-label` is provided + - Customizable `aria-label` and `aria-labelledby` support + +- Semantic HTML + - Uses `