A custom Lightning Web Component (LWC) navigation solution for Salesforce Experience Cloud (formerly Community Cloud) that provides enhanced sub-page navigation capabilities with dynamic highlighting and menu management.
- 🎯 Dynamic Navigation Menus: Fetch and display navigation menu items dynamically using Apex controllers
- 🔍 Active Page Highlighting: Automatically highlights the current page in the navigation menu
- 📱 Responsive Design: Built-in responsive styling for mobile and desktop views
- 🌲 Hierarchical Menus: Support for parent-child menu item relationships
- 🎨 Multiple Navigation Styles: Includes both bulleted and child menu item components
- ⚡ Performance Optimized: Uses cacheable Apex methods and reactive LWC patterns
- 🛠️ CMS Components: Includes additional CMS utility components for content management
bulletedSubPageNav: Main sub-page navigation component with bulleted list stylingsubPageNav: Vertical navigation component with support for menu labels and hierarchical itemsbulletedNavItem: Individual navigation item with stylingchildNavMenuItem: Child navigation menu item componentchildSubPageItem: Sub-page child item component
cmsAutoMarginComp: Auto-margin utility component for CMS layoutscmsNewsRTEComp: Rich text editor component for news content
- Salesforce CLI installed
- VS Code with Salesforce Extensions (recommended)
- A Salesforce org with Experience Cloud enabled
-
Clone this repository:
git clone https://github.com/Robotghost718/lwcSubPageNavigation.git cd lwcSubPageNavigation -
Authenticate with your Salesforce org:
sf org login web -a YourOrgAlias
-
Deploy the components:
sf project deploy start
-
Create a scratch org:
sf org create scratch -f config/project-scratch-def.json -a lwcNavScratch
-
Push the source:
sf project deploy start -o lwcNavScratch
-
Open the scratch org:
sf org open -o lwcNavScratch
- In your Salesforce org, go to Setup > Digital Experiences > Settings
- Create or edit a Navigation Menu
- Add menu items with labels and targets
- Open Experience Builder for your site
- Drag the bulletedSubPageNav component onto your page
- Configure the component properties:
- Link Set Master Label: The name of your navigation menu
- Add Home Menu Item: Toggle to include/exclude home link
- Include Image URLs: Enable if using images in menu items
NavigationMenuItemsControllerApex classNavigationLinkSetPickListApex class (if using the picklist feature)
| Property | Type | Description | Default |
|---|---|---|---|
linkSetMasterLabel |
String | Navigation menu name | Required |
addHomeMenuItem |
Boolean | Include home link | false |
includeImageUrls |
Boolean | Fetch image URLs | false |
npm installnpm run test:unitnpm run lintnpm run prettierlwcSubPageNavigation/
├── force-app/main/default/
│ ├── classes/ # Apex controllers and tests
│ └── lwc/ # Lightning Web Components
├── config/ # Scratch org definitions
├── .github/ # GitHub templates and workflows
└── package.json # Node.js dependencies
The project includes comprehensive test coverage:
-
Apex Tests:
NavigationMenuItemsControllerTest.clsNavigationLinkSetPickListTest.cls
-
Jest Tests: LWC unit tests can be run with
npm run test:unit
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Salesforce Extensions Documentation
- Salesforce CLI Setup Guide
- Lightning Web Components Developer Guide
- Experience Cloud Documentation
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ⚡ using Salesforce Lightning Web Components