Examples
Skeleton
A placeholder in the shape of content that's still loading. It pulses gently, so the screen shows its layout before the data arrives.
import { Skeleton } from 'patine-ui';
Loading…
<VStack gap="sm" style={{ maxWidth: 380, width: '100%' }}> <Card style={{ overflow: 'hidden' }} aria-busy={loading}> <CardContent style={{ paddingTop: 16, gap: 12 }}> <HStack gap="md" align="center"> {loading ? <Skeleton width={40} height={40} radius="full" /> : <Avatar name="Maya Cohen" src="https://picsum.photos/id/64/160/160" />} <VStack gap="xs" style={{ flex: 1 }}> {loading ? <Skeleton width="50%" /> : <Text weight="medium">Maya Cohen</Text>} {loading ? <Skeleton width="30%" height={12} /> : <Text size="sm" color="textSecondary">2 hours ago</Text>} </VStack> </HStack> {loading ? ( <VStack gap="sm"> <Skeleton /> <Skeleton width="80%" /> </VStack> ) : ( <Text>Golden hour at the falls. Worth the 6am start ☀️</Text> )} {loading ? <Skeleton height={180} radius="md" /> : <Image source={{ uri: 'https://picsum.photos/id/1018/760/360' }} style={{ height: 180, borderRadius: 12 }} alt="Mountains at sunrise" />} </CardContent> </Card> <Button variant="outline" onPress={() => setLoading(true)} disabled={loading}>Reload</Button> </VStack>
Try the props
widthheightradius<Skeleton width={240} />
Example: a weather card
A weather widget while the forecast loads: the skeleton has the card's real shape, the big temperature, the line under it and the hourly row, so nothing moves when the data arrives.
Loading…
<VStack gap="sm" style={{ width: '100%', maxWidth: 340 }}> <Box border radius="lg" padding="lg" gap="md" aria-busy={loading}> <VStack gap="xs"> {loading ? <Skeleton width={110} height={44} /> : <Text size="3xl" weight="semibold">14°</Text>} {loading ? <Skeleton width="60%" height={14} /> : <Text color="textSecondary">Lisbon · Sunny, rain after 4 pm</Text>} </VStack> <HStack justify="space-between"> {HOURS.map((h) => ( <VStack key={h.at} gap="xs" align="center"> {loading ? <Skeleton width={28} height={12} /> : <Text size="xs" color="textSecondary">{h.at}</Text>} {loading ? <Skeleton width={24} height={24} radius="full" /> : <Icon name={h.icon} color={h.icon === 'sun' ? 'warning' : 'textSecondary'} />} {loading ? <Skeleton width={24} height={14} /> : <Text size="sm">{h.t}°</Text>} </VStack> ))} </HStack> </Box> <Button variant="outline" disabled={loading} onPress={() => setLoading(true)}> Refresh </Button> </VStack>
Shapes
width and height take points or percentages; radius takes a step, 'full' for a circle or pill, or points.
Loading…
<HStack gap="md" align="center" wrap> <Skeleton width={48} height={48} radius="full" /> <Skeleton width={64} height={64} radius="md" /> <Skeleton width={96} height={32} radius="full" /> <Skeleton width={140} height={16} /> <Skeleton width={80} height={80} radius={0} /> </HStack>
A list loading
Repeat the row's shape a few times. Vary the widths a little so it doesn't look like a barcode.
Loading…
<VStack gap="lg" style={{ maxWidth: 380, width: '100%' }} aria-busy accessibilityLabel="Loading contacts"> {WIDTHS.map((width, i) => ( <HStack key={i} gap="md" align="center"> <Skeleton width={40} height={40} radius="full" /> <VStack gap="xs" style={{ flex: 1 }}> <Skeleton width={width} /> <Skeleton width="35%" height={12} /> </VStack> <Skeleton width={56} height={28} radius="full" /> </HStack> ))} </VStack>
A product grid loading
Loading…
<HStack gap="md" wrap> {[0, 1, 2].map((i) => ( <VStack key={i} gap="sm" style={{ width: 120 }}> <Skeleton height={120} radius="md" /> <Skeleton width="85%" /> <Skeleton width="40%" height={14} /> </VStack> ))} </HStack>
Accessibility
Skeletons are hidden from screen readers. Mark the region that's loading with aria-busy so assistive technology knows to wait, and the pulse stops when the OS asks to reduce motion.
Props
Skeleton also takes View props.
| Prop | Type | Default | Description |
|---|---|---|---|
width | DimensionValue | '100%' | Points or a percentage. |
height | DimensionValue | 16 | About a line of text by default. |
radius | 'sm' | 'md' | 'lg' | 'full' | number | 'sm' | A radius step, full for a circle or pill, or points. |
theme | DeepPartial<Theme> | — | Theme override. |