Create placeholder content while loading data.
import { Skeleton } from '@fluxui-dev/react';<Skeleton.Group animate="shimmer" className="flex items-center gap-4"> <Skeleton className="size-10 rounded-full" /> <div className="flex-1"> <Skeleton.Line /> <Skeleton.Line className="w-1/2" /> </div></Skeleton.Group>
Create a loading state for a single line of text. Skeleton.Line occupies the full line-height of text while rendering a slimmer bar, giving it the visual proportions of real text.
<Skeleton.Group animate="shimmer"> <Skeleton.Line className="mb-2 w-1/4" /> <Skeleton.Line /> <Skeleton.Line /> <Skeleton.Line className="w-3/4" /></Skeleton.Group>
Use the animate prop to add an animation to the skeleton.
<Skeleton /><Skeleton animate="shimmer" /><Skeleton animate="pulse" />
Here are some examples of different ways you can use the skeleton component.
Use the skeleton component to create a loading state for a table.
<Skeleton.Group animate="shimmer"> <table className="w-full text-left text-sm"> <thead> <tr> <th>Customer</th> <th>Date</th> <th>Status</th> <th>Amount</th> </tr> </thead> <tbody> {orders.map((order) => ( <tr key={order}> <td> <div className="flex items-center gap-2"> <Skeleton className="rounded-full size-5" /> <div className="flex-1"> <Skeleton.Line style={{ width: `${50 + Math.random() * 50}%` }} /> </div> </div> </td> <td> <Skeleton.Line /> </td> <td> <Skeleton.Line /> </td> <td> <Skeleton.Line /> </td> </tr> ))} </tbody> </table></Skeleton.Group>
Use the skeleton component to create a loading state for a chart.
import { Card, Heading, Skeleton, Text } from '@fluxui-dev/react';<Card className="dark:bg-zinc-800"> <div className="flex flex-col gap-6"> <div className="flex gap-12"> <div> <Text>Today</Text> <Heading size="xl" className="mt-2 tabular-nums">$---</Heading> <Text className="mt-2 tabular-nums">-:-- PM</Text> </div> <div> <Text>Yesterday</Text> <Heading size="lg" className="mt-2 tabular-nums">$---</Heading> </div> </div> <Skeleton animate="shimmer" className="aspect-[4/1] size-full rounded-lg" /> </div></Card>
|
Prop
|
Description
|
|---|---|
| animate |
Animation style for the skeleton. Options: shimmer, pulse. Defaults to no animation, or to the enclosing Skeleton.Group's.
|
| children |
Content rendered inside the placeholder.
|
|
CSS Variable
|
Description
|
|---|---|
| --flux-shimmer-color |
The background color used for the shimmer animation. Defaults to white in light mode and zinc-900 in dark mode. Set this to match your page's background color to prevent the shimmer from showing through gaps between skeleton elements.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-skeleton |
Applied to the root element for styling and identification.
|
|
Prop
|
Description
|
|---|---|
| size |
Size of the line. Options: base, lg. Defaults to base.
|
| animate |
Animation style for the skeleton. Options: shimmer, pulse. Defaults to no animation. Can be inherited from a parent Skeleton.Group.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-skeleton-line |
Applied to the root element for styling and identification.
|
|
Prop
|
Description
|
|---|---|
| animate |
Animation style for all skeleton elements within the group. Options: shimmer, pulse. Defaults to no animation. Inherited by child Skeleton and Skeleton.Line components that set none of their own.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-skeleton-group |
Applied to the root element for styling and identification.
|