Skeleton Loader
A shimmering placeholder shown while content is loading.
A shimmering placeholder shown while content is loading. Compose it from the exported registry parts so local content and behaviour stay in the application while the visual contract stays token-driven.
newt-skeletonimport { Skeleton } from "@/registry/bases/newt/ui/skeleton"
export default function SkeletonDemo() {
return (
<div className="flex w-full max-w-sm gap-3">
<Skeleton variant="avatar" />
<div className="flex flex-1 flex-col gap-1.5">
<Skeleton variant="title" />
<Skeleton variant="text" className="w-[80%]" />
</div>
</div>
)
}<script setup lang="ts">
import { Skeleton } from "~~/registry/bases/newt/ui/skeleton"
</script>
<template>
<div class="flex w-full max-w-sm gap-3">
<Skeleton variant="avatar" />
<div class="flex flex-1 flex-col gap-1.5">
<Skeleton variant="title" />
<Skeleton variant="text" class="w-[80%]" />
</div>
</div>
</template>Installation
npx newtui@latest add skeletonnpx shadcn@latest add @newtui/skeletonnpx shadcn-vue@latest add @newtui/skeletonpnpm dlx newtui@latest add skeletonpnpm dlx shadcn@latest add @newtui/skeletonpnpm dlx shadcn-vue@latest add @newtui/skeletonyarn dlx newtui@latest add skeletonyarn dlx shadcn@latest add @newtui/skeletonyarn dlx shadcn-vue@latest add @newtui/skeletonbunx newtui@latest add skeletonbunx shadcn@latest add @newtui/skeletonbunx shadcn-vue@latest add @newtui/skeletondeno run -A npm:newtui@latest add skeletondeno run -A npm:shadcn@latest add @newtui/skeletondeno run -A npm:shadcn-vue@latest add @newtui/skeletonvlx newtui@latest add skeletonvlx shadcn@latest add @newtui/skeletonvlx shadcn-vue@latest add @newtui/skeletonvp dlx newtui@latest add skeletonvp dlx shadcn@latest add @newtui/skeletonvp dlx shadcn-vue@latest add @newtui/skeletonnubx newtui@latest add skeletonnubx shadcn@latest add @newtui/skeletonnubx shadcn-vue@latest add @newtui/skeletonnlx newtui@latest add skeletonnlx shadcn@latest add @newtui/skeletonnlx shadcn-vue@latest add @newtui/skeletonupx newtui@latest add skeletonupx shadcn@latest add @newtui/skeletonupx shadcn-vue@latest add @newtui/skeleton- newtui
- shadcn
- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
The shadcn CLI needs the @newtui registry in your components.json. Set it up.
Install the dependencies
npm install class-variance-authoritypnpm add class-variance-authorityyarn add class-variance-authoritybun add class-variance-authoritydeno add npm:class-variance-authorityvlt install class-variance-authorityvp add class-variance-authoritynub add class-variance-authorityni class-variance-authorityupm add class-variance-authority- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
Copy the source into your project
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react"
import { cn } from "@/lib/utils"
const skeletonVariants = cva(
"animate-[newt-skeleton-shimmer_1.6s_ease-in-out_infinite] rounded-[var(--newt-radius-sm)] bg-[linear-gradient(90deg,var(--newt-bg-elevated)_25%,var(--newt-bg-hover)_50%,var(--newt-bg-elevated)_75%)] bg-[length:200%_100%] motion-reduce:animate-none motion-reduce:opacity-60",
{
variants: {
variant: {
default: "",
text: "h-[14px]",
avatar: "h-10 w-10 rounded-full",
title: "h-5 w-[40%]",
},
},
defaultVariants: {
variant: "default",
},
}
)
export interface SkeletonProps
extends React.ComponentProps<"div">, VariantProps<typeof skeletonVariants> {}
const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>(
({ className, variant, ...props }, ref) => (
<>
<style>{`@keyframes newt-skeleton-shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}`}</style>
<div
ref={ref}
aria-hidden="true"
data-variant={variant ?? "default"}
className={cn(skeletonVariants({ variant }), className)}
{...props}
/>
</>
)
)
Skeleton.displayName = "Skeleton"
export { Skeleton, skeletonVariants }<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
import { skeletonVariants, type SkeletonVariants } from "."
const props = defineProps<{
class?: HTMLAttributes["class"]
variant?: SkeletonVariants["variant"]
}>()
</script>
<template>
<div
aria-hidden="true"
:data-variant="props.variant ?? 'default'"
:class="cn(skeletonVariants({ variant: props.variant }), props.class)"
/>
</template>
<style>
@keyframes newt-skeleton-shimmer {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
</style>import { cva, type VariantProps } from "class-variance-authority"
export { default as Skeleton } from "./Skeleton.vue"
export const skeletonVariants = cva(
"animate-[newt-skeleton-shimmer_1.6s_ease-in-out_infinite] rounded-[var(--newt-radius-sm)] bg-[linear-gradient(90deg,var(--newt-bg-elevated)_25%,var(--newt-bg-hover)_50%,var(--newt-bg-elevated)_75%)] bg-[length:200%_100%] motion-reduce:animate-none motion-reduce:opacity-60",
{
variants: {
variant: {
default: "",
text: "h-[14px]",
avatar: "h-10 w-10 rounded-full",
title: "h-5 w-[40%]",
},
},
defaultVariants: {
variant: "default",
},
}
)
export type SkeletonVariants = VariantProps<typeof skeletonVariants>Update the import paths
The files import @/lib/utils and sibling components through the aliases in your components.json. Point them at wherever those live in your project.
No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Skeleton Loader to your React project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.
No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Skeleton Loader to your Vue project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.
Usage
import { Skeleton } from "@/components/ui/skeleton"
export function Example() {
return <Skeleton />
}<script setup lang="ts">
import { Skeleton } from "@/components/ui/skeleton"
</script>
<template>
<Skeleton />
</template>Examples
Variants
avatar, title and text come with a size. default has none and takes its shape from the classes you pass, which is how to stand in for an image or a whole block.
newt-skeletonimport { Skeleton } from "@/registry/bases/newt/ui/skeleton"
/* `default` has no size of its own: it takes whatever shape the classes give it. */
export default function SkeletonVariantsDemo() {
return (
<div className="flex w-full max-w-sm flex-col gap-4">
<div className="flex items-center gap-3">
<span className="w-14 shrink-0 text-xs text-newt-text-muted">
avatar
</span>
<Skeleton variant="avatar" />
</div>
<div className="flex items-center gap-3">
<span className="w-14 shrink-0 text-xs text-newt-text-muted">
title
</span>
<div className="flex-1">
<Skeleton variant="title" />
</div>
</div>
<div className="flex items-center gap-3">
<span className="w-14 shrink-0 text-xs text-newt-text-muted">text</span>
<div className="flex-1">
<Skeleton variant="text" />
</div>
</div>
<div className="flex items-center gap-3">
<span className="w-14 shrink-0 text-xs text-newt-text-muted">
default
</span>
<div className="flex-1">
<Skeleton className="h-20 w-full rounded-md" />
</div>
</div>
</div>
)
}<script setup lang="ts">
import { Skeleton } from "~~/registry/bases/newt/ui/skeleton"
</script>
<template>
<!-- `default` has no size of its own: it takes whatever shape the classes give it. -->
<div class="flex w-full max-w-sm flex-col gap-4">
<div class="flex items-center gap-3">
<span class="w-14 shrink-0 text-xs text-newt-text-muted">avatar</span>
<Skeleton variant="avatar" />
</div>
<div class="flex items-center gap-3">
<span class="w-14 shrink-0 text-xs text-newt-text-muted">title</span>
<div class="flex-1">
<Skeleton variant="title" />
</div>
</div>
<div class="flex items-center gap-3">
<span class="w-14 shrink-0 text-xs text-newt-text-muted">text</span>
<div class="flex-1">
<Skeleton variant="text" />
</div>
</div>
<div class="flex items-center gap-3">
<span class="w-14 shrink-0 text-xs text-newt-text-muted">default</span>
<div class="flex-1">
<Skeleton class="h-20 w-full rounded-md" />
</div>
</div>
</div>
</template>In a card
Build the placeholder with the same layout as the content it replaces, so nothing moves when the content arrives.
newt-skeletonimport { Card } from "@/registry/bases/newt/ui/card"
import { Skeleton } from "@/registry/bases/newt/ui/skeleton"
/* The placeholder keeps the card's real layout, so nothing jumps on arrival. */
export default function SkeletonCardDemo() {
return (
<Card className="flex w-full max-w-sm flex-col gap-3">
<Skeleton className="h-28 w-full rounded-md" />
<Skeleton variant="title" />
<div className="flex flex-col gap-1.5">
<Skeleton variant="text" />
<Skeleton variant="text" className="w-[70%]" />
</div>
</Card>
)
}<script setup lang="ts">
import { Card } from "~~/registry/bases/newt/ui/card"
import { Skeleton } from "~~/registry/bases/newt/ui/skeleton"
</script>
<template>
<!-- The placeholder keeps the card's real layout, so nothing jumps on arrival. -->
<Card class="flex w-full max-w-sm flex-col gap-3">
<Skeleton class="h-28 w-full rounded-md" />
<Skeleton variant="title" />
<div class="flex flex-col gap-1.5">
<Skeleton variant="text" />
<Skeleton variant="text" class="w-[70%]" />
</div>
</Card>
</template>Loading state
Swap the skeleton for the content when it is ready. A skeleton is hidden from screen readers, so set aria-busy on the region while it is shown.
newt-skeleton"use client"
import * as React from "react"
import { Avatar } from "@/registry/bases/newt/ui/avatar"
import { Button } from "@/registry/bases/newt/ui/button"
import { Skeleton } from "@/registry/bases/newt/ui/skeleton"
/*
* A skeleton is hidden from screen readers, so the region says it is busy
* with `aria-busy` while the placeholder stands in for the message.
*/
export default function SkeletonLoadingDemo() {
const [loading, setLoading] = React.useState(true)
return (
<div className="flex w-full max-w-sm flex-col items-start gap-4">
<div aria-busy={loading} className="flex w-full gap-3">
{loading ? (
<>
<Skeleton variant="avatar" />
<div className="flex flex-1 flex-col gap-1.5">
<Skeleton variant="title" />
<Skeleton variant="text" className="w-[80%]" />
</div>
</>
) : (
<>
<Avatar aria-hidden="true">M</Avatar>
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
<span className="text-sm font-semibold text-newt-text-primary">
Mira Okafor
</span>
<span className="text-sm text-newt-text-secondary">
The reading list for next month is pinned.
</span>
</div>
</>
)}
</div>
<Button
size="sm"
variant="secondary"
onClick={() => setLoading((current) => !current)}
>
{loading ? "Show the message" : "Show the placeholder"}
</Button>
</div>
)
}<script setup lang="ts">
import { ref } from "vue"
import { Avatar } from "~~/registry/bases/newt/ui/avatar"
import { Button } from "~~/registry/bases/newt/ui/button"
import { Skeleton } from "~~/registry/bases/newt/ui/skeleton"
/*
* A skeleton is hidden from screen readers, so the region says it is busy
* with `aria-busy` while the placeholder stands in for the message.
*/
const loading = ref(true)
</script>
<template>
<div class="flex w-full max-w-sm flex-col items-start gap-4">
<div :aria-busy="loading" class="flex w-full gap-3">
<template v-if="loading">
<Skeleton variant="avatar" />
<div class="flex flex-1 flex-col gap-1.5">
<Skeleton variant="title" />
<Skeleton variant="text" class="w-[80%]" />
</div>
</template>
<template v-else>
<Avatar aria-hidden="true">M</Avatar>
<div class="flex min-w-0 flex-1 flex-col gap-0.5">
<span class="text-sm font-semibold text-newt-text-primary">
Mira Okafor
</span>
<span class="text-sm text-newt-text-secondary">
The reading list for next month is pinned.
</span>
</div>
</template>
</div>
<Button size="sm" variant="secondary" @click="loading = !loading">
{{ loading ? "Show the message" : "Show the placeholder" }}
</Button>
</div>
</template>API reference
Skeleton
children / default slot?React.ReactNode / Vue slot
Content rendered inside the component.
React.ReactNode / Vue slotclassName / class?string
Additional classes merged with the component defaults.
stringThe registry exports Skeleton. Parts without a table accept the native attributes for the element they render; React uses className, while Vue uses class and fallthrough attributes.
Accessibility
Preserve the native semantics of the rendered elements and pass through ARIA attributes when the surrounding context needs a label or description. Any interactive child needs a visible focus indicator, and meaning must not rely on colour alone.
Tokens
Skeleton Loader reads its colours, radii and motion from the --newt-* tokens installed with the library. Override a token and every component that reads it follows, including this one — see the token layer. In the plain HTML and CSS distribution the same component is newt-skeleton.
--newt-bg-elevated--newt-bg-hover--newt-radius-sm