Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useNProgress.md
1---2category: '@Integrations'3---45# useNProgress67Reactive wrapper for [`nprogress`](https://github.com/rstacruz/nprogress).89## Install1011```bash12npm i nprogress@^013```1415## Usage1617```ts {6}18import { useNProgress } from '@vueuse/integrations/useNProgress'1920const { isLoading } = useNProgress()2122function toggle() {23isLoading.value = !isLoading.value24}25```2627### Passing a progress percentage2829You can pass a percentage to indicate where the bar should start from.3031```ts {3}32import { useNProgress } from '@vueuse/integrations/useNProgress'3334const { progress } = useNProgress(0.5)3536function done() {37progress.value = 1.038}39```4041> To change the progress percentage, set `progress.value = n`, where n is a number between 0..1.4243### Customization4445Just edit [nprogress.css](https://github.com/rstacruz/nprogress/blob/master/nprogress.css) to your liking. Tip: you probably only want to find and replace occurrences of #29d.4647You can [configure](https://github.com/rstacruz/nprogress#configuration) it by passing an object as a second parameter.4849```ts {4}50import { useNProgress } from '@vueuse/integrations/useNProgress'5152useNProgress(null, {53minimum: 0.1,54// ...55})56```5758## Type Declarations5960```ts61export type UseNProgressOptions = Partial<NProgressOptions>62export interface UseNProgressReturn {63isLoading: WritableComputedRef<boolean, boolean>64progress: Ref<number | null | undefined>65start: () => NProgress66done: (force?: boolean) => NProgress67remove: () => void68}69/**70* Reactive progress bar.71*72* @see https://vueuse.org/useNProgress73*/74export declare function useNProgress(75currentProgress?: MaybeRefOrGetter<number | null | undefined>,76options?: UseNProgressOptions,77): UseNProgressReturn78```79