@quasarwork/qwik-city-nprogress
Version:
A simple Qwik City progress bar component using NProgress.
85 lines (58 loc) • 1.95 kB
Markdown
A simple [Qwik City][qwik-city] progress bar component using [Nprogress][nprogress].
```bash
yarn add @quasarwork/qwik-city-nprogress
```
The component leverages the property `isNavigating` from [@builder.io/qwik-city useLocation()][use-location] hook.
In order to use the component, you just need to add it in a `layout` component.
_It is recommended to add it to the top-level `layout` component, so that it will work through the whole site._
`src/routes/layout.tsx`
```typescript
import { QwikCityNprogress } from '@quasarwork/qwik-city-nprogress'
export default component$(() => {
return (
<>
<QwikCityNprogress />
<main class="py-8">
<Slot />
</main>
</>
)
})
```
You can use any configuration property from the original [Nprogress][nprogress] package (see [Nprogress configuration](https://github.com/rstacruz/nprogress#configuration)).
Two other properties have been added to make it easier to customize the look of the progress bar.
Type: `string`
Default: `undefined`
Keeping the property `undefined` means keeping the original color provided by [Nprogress][nprogress], which is `
Type: `string`
Default: `undefined`
Keeping the property `undefined` means keeping the original height provided by [Nprogress][nprogress], which is `2px`.
`src/routes/layout.tsx`
```typescript
import { QwikCityNprogress } from '@quasarwork/qwik-city-nprogress'
export default component$(() => {
return (
<>
<QwikCityNprogress
options={{
color: 'var(--primary-color)',
height: '4px',
}}
/>
<main class="py-8">
<Slot />
</main>
</>
)
})
```
[]: https://qwik.builder.io/
[]: https://ricostacruz.com/nprogress/
[]: https://qwik.builder.io/docs/api/#uselocation