Bootstrap Right-Click Navigation Menu
- Package: BRC JS
- Version: v1.4.0
- Copyright: 2026
JosebaMirena.com - License:
MIT License - Author: Joseba Mirena (@joseba-mirena)
A lightweight, zero-dependency JavaScript module that adds a customizable right-click navigation menu to your Bootstrap website. The menu automatically syncs with your existing navbar structure, supports RTL languages, and respects your theme's CSS variables.
- π― No Code Duplication - Automatically builds menu from your existing Bootstrap navbar
- π¨ Theme Aware - Uses Bootstrap CSS variables, supports custom color schemes
- π RTL Support - Full right-to-left language support
- βΏ Accessible - ARIA labels, keyboard navigation, screen reader friendly
- π Smart Positioning - Automatically positions menu where most space is available
- π¨ Customizable - Easy to style with CSS variables or configuration options
- β‘ Lightweight - No external dependencies, just 8.5 kB vanilla JavaScript
<script src="https://opensource.josebamirena.com/brc/1.4.0/dist/brc.min.js"
integrity="sha384-kJGHY9/CJpLc2cVklwerRBVLBsqBws9DuUwgNfX+LAYB+UyKW/1+/wdzMzkS6koM"
crossorigin="anonymous">
</script> <script>
BootstrapRightClickNav.init();
</script> <script>
// With custom options
BootstrapRightClickNav.init({
minWidth: '250px',
borderColor: 'var(--color-primary, #ff2c6e)',
activeColor: 'var(--color-secondary, #2ecc71)',
debug: true
});
</script>| Option | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | true |
Enable/disable the right-click menu functionality |
injectCSS |
boolean | true |
Automatically inject required CSS styles |
injectHTML |
boolean | true |
Automatically inject menu HTML structure |
minWidth |
string | '200px' |
Minimum width of the menu (can be any CSS width value) |
zIndex |
number | 10000 |
Z-index for menu stacking context |
menuId |
string | 'bootstrap-rightclick-nav' |
ID attribute for the menu element |
excludeElements |
array | ['input', 'textarea', '[contenteditable="true"]'] |
Elements where right-click is disabled (supports CSS selectors) |
debug |
boolean | false |
Enable console logging for debugging |
navSelector |
string | '.navbar-nav' |
CSS selector to find your navigation element |
borderColor |
string | 'var(--color-tertiary, var(--bs-primary))' |
Menu border color (CSS color value) |
activeColor |
string | 'var(--color-primary, var(--bs-primary))' |
Background color for active menu items |
<script>
// Initialize the menu
BootstrapRightClickNav.init(options);
// Enable the menu
BootstrapRightClickNav.enable();
// Disable the menu
BootstrapRightClickNav.disable();
// Hide the menu if visible
BootstrapRightClickNav.hide();
// Update menu content (useful after dynamic nav changes)
BootstrapRightClickNav.update();
// Check if menu is visible
const isVisible = BootstrapRightClickNav.isVisible();
// Update configuration
BootstrapRightClickNav.setConfig({ minWidth: '300px' });
// Completely destroy the menu (removes events and elements)
BootstrapRightClickNav.destroy();
</script> /* Override default colors */
:root {
--color-primary: #ff2c6e; /* Active item background */
--color-tertiary: #3498db; /* Menu border */
} /* Or customize via configuration */
BootstrapRightClickNav.init({
borderColor: '#00d4ff',
activeColor: '#ff2c6e'
}); <!-- Add this class to elements where you want to disable right-click -->
<div class="no-context-menu">
<!-- Right-click disabled here -->
</div> // Or configure excluded elements
BootstrapRightClickNav.init({
excludeElements: ['input', 'textarea', '.no-menu', '#special-element']
});- Added missing element right-click exclusion handling
- Added support for any anchor link (
#top,#section, etc.) - Color-coded debug console logs (
[BRC] info/warn/error)
- Optimized variables to reduce code weight
- Smooth scroll for any anchor link (
#top,#section) - Menu now closes before smooth scroll executes
- Simplified injection logic
- Touch device detection (not needed -
contextmenudoesn't fire on touch)
- Right-click menu syncing with Bootstrap navbar
- RTL language support
- ARIA accessibility attributes
- Public API:
init(),enable(),disable(),hide(),update(),destroy(),isVisible(),setConfig()
Try BRC JS live on my website:
π BRC JS Demo
Right-click anywhere on this website (except on the cookie modal) to see the menu in action.