nb-skeleton

This is a skeleton loader component for Vue.js 3+.

Loading component...

Installation

Yarn
yarn add @vlalg-nimbus/nb-loaders
NPM
npm install @vlalg-nimbus/nb-loaders

Usage

Vue 3
import { createApp } from 'vue'
import App from './App.vue'

import NbLoadersComponents from '@vlalg-nimbus/nb-loaders'
import "@vlalg-nimbus/nb-loaders/dist/style.css";

const app = createApp(App)
app.use(NbLoadersComponents)
app.mount('#app')
Nuxt 3
import NbLoadersComponents from '@vlalg-nimbus/nb-loaders'
import "@vlalg-nimbus/nb-loaders/dist/style.css";

export default defineNuxtPlugin(context => {
  context.vueApp.use(NbLoadersComponents)
})

To use, simply call the component, in this case it will be NbSkeleton or nb-skeleton.

Important: The NbSkeleton component uses position: absolute, so it must be placed inside a container element with position: relative and overflow: hidden. The container should also define the desired width and height for the skeleton.

Mode 1
<template>
  <div style="position: relative; overflow: hidden; width: 300px; height: 20px;">
    <NbSkeleton nb-id="skeleton-1" />
  </div>
</template>
Mode 2
<template>
  <div style="position: relative; overflow: hidden; width: 300px; height: 20px;">
    <nb-skeleton nb-id="skeleton-1" />
  </div>
</template>
Mode 3
<template>
  <div class="skeleton-container" style="position: relative; overflow: hidden; width: 300px; height: 20px;">
    <nb-skeleton nb-id="skeleton-1"></nb-skeleton>
  </div>
</template>

Preview & Playground

Select the component you want to edit/test

Loading Sandbox...

Props

Items with an (*) mean they are required

nameValue typeDefaultDescription
nbId (*)StringSets the id attribute to differentiate from other components
showBooleantrueDefines if the loader is visible
ariaLabelString'Alternate Text Button'Defines the aria-label attribute for screen readers
ariaAttrsObject{}Allows passing custom aria attributes as an object. Keys will automatically receive the aria- prefix
backgroundColorString'#e2e8f0'Defines the background color. Accepts Color name and Hex
gradientDirectionString'90deg'Defines the gradient direction (angle)
gradienteColorString'rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0)'Defines the gradient colors. Accepts a comma-separated list of colors
gradientAnimationDurationString'1.2s'Defines the animation duration for the gradient effect

Events

nameReturn typeDescription
clickednothingFired when the loader is clicked, returns nothing
changedvalueFired when the show prop changes, returns the new value