Navigation progress bar component for React applications with Mantine UI framework integration
npx @tessl/cli install tessl/npm-mantine--nprogress@8.2.0Mantine Navigation Progress is a React library that provides a navigation progress bar component for indicating page loading or navigation status in web applications. It integrates seamlessly with the Mantine UI framework and offers both declarative React component patterns and imperative control methods for maximum flexibility in implementation.
npm install @mantine/nprogress @mantine/core @mantine/hooksimport { NavigationProgress } from "@mantine/nprogress";
import { startNavigationProgress, completeNavigationProgress } from "@mantine/nprogress";For CommonJS:
const { NavigationProgress, startNavigationProgress, completeNavigationProgress } = require("@mantine/nprogress");import { NavigationProgress, startNavigationProgress, completeNavigationProgress } from "@mantine/nprogress";
import "@mantine/nprogress/styles.css";
// Add the component to your app
function App() {
return (
<div>
<NavigationProgress />
{/* Your app content */}
</div>
);
}
// Control progress programmatically
function handleNavigation() {
startNavigationProgress();
// Simulate async operation
setTimeout(() => {
completeNavigationProgress();
}, 2000);
}Mantine Navigation Progress is built around several key components:
Main React component for rendering the navigation progress bar with full customization options including colors, sizing, portal rendering, and z-index control.
function NavigationProgress(props: NavigationProgressProps): JSX.Element;
interface NavigationProgressProps extends ElementProps<'div'> {
store?: NprogressStore;
initialProgress?: number;
color?: MantineColor;
size?: number;
stepInterval?: number;
withinPortal?: boolean;
portalProps?: Omit<BasePortalProps, 'withinPortal'>;
zIndex?: React.CSSProperties['zIndex'];
}Core store system providing state management for progress tracking, with hooks for React integration and state subscription.
type NprogressStore = MantineStore<NprogressState>;
interface NprogressState {
mounted: boolean;
progress: number;
interval: number;
step: number;
stepInterval: number;
timeouts: number[];
}
function createNprogressStore(): NprogressStore;
function useNprogress(store: NprogressStore): NprogressState;Action functions for programmatic control of progress state, enabling integration with routing libraries and custom navigation flows.
function startNavigationProgress(): void;
function stopNavigationProgress(): void;
function setNavigationProgress(value: number): void;
function incrementNavigationProgress(): void;
function decrementNavigationProgress(): void;
function completeNavigationProgress(): void;
function resetNavigationProgress(): void;
function cleanupNavigationProgress(): void;Factory functions for creating isolated progress store instances, useful for multiple independent progress bars or complex applications.
function createNprogress(): readonly [NprogressStore, ActionsObject];
interface ActionsObject {
start(): void;
stop(): void;
reset(): void;
set(value: number): void;
increment(): void;
decrement(): void;
complete(): void;
cleanup(): void;
}type MantineColor = string;
interface ElementProps<T extends keyof HTMLElementTagNameMap>
extends React.ComponentPropsWithoutRef<T> {}
interface BasePortalProps {
withinPortal?: boolean;
target?: HTMLElement | string;
children: React.ReactNode;
}