Skeleton
Use to show a placeholder while content is loading.
import { css } from 'remix/component'
import { Skeleton } from '#app/ui/skeleton.tsx'
const line = css({ height: '1rem' })import { css } from 'remix/component'
import { Skeleton } from '#app/ui/skeleton.tsx'
const line = css({ height: '1rem' })
export function SkeletonDemo() {
return () => (
<div
mix={css({
display: 'flex',
alignItems: 'center',
'& > :not(:last-child)': { marginInlineEnd: '1rem' },
})}
>
<Skeleton mix={css({ height: '3rem', width: '3rem', borderRadius: '9999px' })} />
<div mix={css({ '& > :not(:last-child)': { marginBottom: '0.5rem' } })}>
<Skeleton mix={[line, css({ width: '250px' })]} />
<Skeleton mix={[line, css({ width: '200px' })]} />
</div>
</div>
)
}Installation
$ bunx --bun shadcn@latest add https://www.shadcn-remix.com/r/skeleton.json$ npx shadcn@latest add https://www.shadcn-remix.com/r/skeleton.json$ pnpm dlx shadcn@latest add https://www.shadcn-remix.com/r/skeleton.json$ yarn dlx shadcn@latest add https://www.shadcn-remix.com/r/skeleton.jsonInstall the following dependencies:
$ bun add remix$ npm install remix$ pnpm add remix$ yarn add remixCopy and paste the following code into your project.
import { css, type Handle, type Props } from 'remix/component'
const skeletonStyles = css({
animation: 'pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
borderRadius: 'calc(var(--radius) - 2px)',
backgroundColor: 'var(--accent)',
})
export function Skeleton(handle: Handle<Props<'div'>>) {
return () => {
let { mix, ...props } = handle.props
return <div data-slot="skeleton" {...props} mix={[skeletonStyles, mix]} />
}
}Update the import paths to match your project setup.
Usage
import { css } from 'remix/component'
import { Skeleton } from '#app/ui/skeleton.tsx'<Skeleton mix={css({ height: '20px', width: '100px', borderRadius: '9999px' })} />Examples
Card
styleName="radix-nova"
import { css } from 'remix/component'
import { Skeleton } from '#app/ui/skeleton.tsx'
const line = css({ height: '1rem' })import { css } from 'remix/component'
import { Skeleton } from '#app/ui/skeleton.tsx'
const line = css({ height: '1rem' })
export function SkeletonCard() {
return () => (
<div
mix={css({
display: 'flex',
flexDirection: 'column',
'& > :not(:last-child)': { marginBottom: '0.75rem' },
})}
>
<Skeleton
mix={css({ height: '125px', width: '250px', borderRadius: 'calc(var(--radius) + 4px)' })}
/>
<div mix={css({ '& > :not(:last-child)': { marginBottom: '0.5rem' } })}>
<Skeleton mix={[line, css({ width: '250px' })]} />
<Skeleton mix={[line, css({ width: '200px' })]} />
</div>
</div>
)
}API Reference
Skeleton
| Prop | Type | Default |
|---|---|---|
mix | MixValue | - |