NProgress

Show feedback when switching pages and content is loading in the background.

NProgress can be helpful in single-page apps (SPA) to give a visual clue to users that something is happening when browsing, in case a page isn't preloaded and may take a moment to load.

Import#

import { NProgress, NProgressNextRouter } from '@saas-ui/react'

Usage#

Basic#

<Box position="relative" overflow="hidden" height="10px">
<NProgress isAnimating position="absolute" />
</Box>

Bar color#

<Box position="relative" overflow="hidden" height="10px">
<NProgress isAnimating colorScheme="teal" position="absolute" />
</Box>

Trigger#

function App() {
const [isAnimating, setAnimating] = useState(false)
return (
<Stack>
<Box>
<Button onClick={() => setAnimating(!isAnimating)}>
Toggle progress
</Button>
</Box>
<Box position="relative" overflow="hidden" height="10px">
<NProgress
isAnimating={isAnimating}
colorScheme="teal"
position="absolute"
/>
</Box>
</Stack>
)
}

Use with Next Router#

// _app.tsx
function App({ Component, pageProps }) {
return (
<Layout>
<NProgressNextRouter />
<Component {...pageProps} />
</Layout>
)
}

Props#

isAnimatingrequired

Description

Set to true to start the progress animation.

Type
boolean

Was this helpful?