Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to add a loading component #2668

Open
hywax opened this issue Nov 17, 2024 · 0 comments
Open

Proposal to add a loading component #2668

hywax opened this issue Nov 17, 2024 · 0 comments
Labels

Comments

@hywax
Copy link

hywax commented Nov 17, 2024

For what version of Nuxt UI are you suggesting this?

v3.0.0-alpha.x

Description

In certain situations, it’s necessary to display a loading indicator, but not all components currently include this feature. It would be helpful to have a composable and directive for such cases.

How it should work

A semi-transparent overlay should be rendered over the target, containing a loading icon.

How to use

Composable useLoading

<script setup lang="ts">
const layout = ref<HTMLDivElement | null>(null)
const { start, stop } = useLoading(layout)

function startLoading() {
  start()
  setTimeout(stop, 2000)
}
</script>

<template>
  <div ref="layout">
    ...
  </div>
  <UButton @click="startLoading">Show loading</UButton>
</template>

Directive v-loading

<script setup lang="ts">
const isLoading = ref(false)
</script>

<template>
  <div v-loading="isLoading">
    ...
  </div>
</template>

Additional context

Here’s how it’s implemented in other libraries:

@hywax hywax added enhancement New feature or request triage labels Nov 17, 2024
@benjamincanac benjamincanac added v3 #1289 feature and removed enhancement New feature or request triage labels Nov 18, 2024 — with Volta.net
@hywax hywax mentioned this issue Nov 18, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants