Skeleton
adn-ui/skeletonFreeComponent
Displays placeholder content while data is loading.
Live preview
live · rendered by the registry
Rendered by adn-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.awaiden.com/r/skeleton.jsonSource
1"use client";23import "./skeleton.css";4import type React from "react";5import { cn } from "tailwind-variants";67import { SkeletonContext, useSkeletonContext } from "./skeleton.context";8import { skeletonVariants, type SkeletonVariants } from "./skeleton.variants";910export type SkeletonProps = SkeletonVariants & React.HTMLAttributes<HTMLDivElement>;1112export const SkeletonRoot = ({13 children,14 className,15 variant,16 animation,17 shape,18 size,19 ...props20}: SkeletonProps) => {21 const slots = skeletonVariants({ variant, animation, shape, size });2223 return (24 <SkeletonContext.Provider value={{ slots }}>25 <div className={cn(slots.root(), className)} {...props}>26 {children}27 </div>28 </SkeletonContext.Provider>29 );30};3132export const Skeleton = SkeletonRoot;3334export type SkeletonTextProps = SkeletonProps & {35 lines?: number;36 lastLineWidth?: string;37 gap?: string;38};3940export const SkeletonText = ({41 lines = 3,42 lastLineWidth = "60%",43 className,44 variant,45 animation,46 shape = "rounded",47 size = "sm",48 ...props49}: SkeletonTextProps) => {50 const { slots } = useSkeletonContext();5152 return (53 <div className={cn(slots.text(), className)} {...props}>54 {Array.from({ length: lines }).map((_, index) => (55 <SkeletonRoot56 key={index}57 variant={variant}58 animation={animation}59 shape={shape}60 size={size}61 style={index === lines - 1 && lastLineWidth ? { width: lastLineWidth } : undefined}62 className="w-full"63 />64 ))}65 </div>66 );67};6869export type SkeletonAvatarProps = SkeletonProps;7071export const SkeletonAvatar = ({72 className,73 variant,74 animation,75 shape = "circle",76 size = "md",77 ...props78}: SkeletonAvatarProps) => {79 const sizeClasses = {80 xs: "h-6 w-6",81 sm: "h-8 w-8",82 md: "h-10 w-10",83 lg: "h-12 w-12",84 xl: "h-16 w-16",85 };8687 const chosenSizeClass = sizeClasses[size as keyof typeof sizeClasses] || "h-10 w-10";8889 return (90 <SkeletonRoot91 variant={variant}92 animation={animation}93 shape={shape}94 className={cn(chosenSizeClass, "shrink-0", className)}95 {...props}96 />97 );98};99100export type SkeletonButtonProps = SkeletonProps;101102export const SkeletonButton = ({103 className,104 variant,105 animation,106 shape = "rounded",107 size = "md",108 ...props109}: SkeletonButtonProps) => {110 const sizeClasses = {111 xs: "h-7 w-16",112 sm: "h-8 w-20",113 md: "h-10 w-24",114 lg: "h-11 w-28",115// … truncated
What it pulls in
npm packages
Files it writes
More from adn-ui
All 46 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | adn-ui | Components | Free | 2 deps · 5 files | |
| Alert Dialogalert-dialog | adn-ui | Components | Free | 2 deps · 5 files | |
| Aspect Ratioaspect-ratio | adn-ui | Components | Free | 1 dep · 5 files | |
| Autocompleteautocomplete | adn-ui | Components | Free | 2 deps · 5 files | |
| Avataravatar | adn-ui | Components | Free | 2 deps · 5 files | |
| Badgebadge | adn-ui | Components | Free | 1 dep · 5 files | |
| Breadcrumbbreadcrumb | adn-ui | Components | Free | 1 dep · 5 files | |
| Buttonbutton | adn-ui | Components | Free | 1 dep · 4 files |
