How to make loading effect in layout
Create a loading effect in layout from NuxtJS 3.
2 Replies
Hi @Adnan Erlansyah. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To create a loading effect in a layout in Nuxt 3, you can use the built-in
- Add
<NuxtLoadingIndicator />
component. This component displays a progress bar between page navigations and can be added directly to your app.vue
or any layout file. Here’s how you can do it:
Example in app.vue
or a layout file:
You can customize the loading indicator using its props, such as color
, height
, duration
, and more. For advanced control, you can use the useLoadingIndicator
composable to manually start or finish the loading state, or to tie the loading state to custom events (like waiting for images or API calls to finish) Nuxt Loading Indicator Docs.
Customizing the loading indicator:
If you want to trigger the loading effect manually (for example, when waiting for images or other resources), you can use the useLoadingIndicator
composable:
This approach allows you to control exactly when the loading effect appears and disappears, making it suitable for more complex loading scenarios Nuxt Loading Indicator Composable.
Summary:- Add
<NuxtLoadingIndicator />
to your layout or app.vue
.
- Customize it with props as needed.
- For manual control, use the useLoadingIndicator
composable.
For more details and advanced usage, see the official documentation: Nuxt Loading Indicator.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1079709612078534676> Kapa.ai is still learning and improving, please let me know how I did by reacting below.