Skeleton
Text initial loading
tsx
import React from 'react';
import { Text } from '@semcore/ui/typography';
import { Flex } from '@semcore/ui/flex-box';
import Button from '@semcore/ui/button';
import Skeleton from '@semcore/ui/skeleton';
const Demo = () => {
const [loading, setLoading] = React.useState(false);
return (
<>
<Flex gap={2} mb={3}>
<Button onClick={() => setLoading(true)}>Load data</Button>
<Button onClick={() => setLoading(false)}>Stop loading</Button>
</Flex>
<Flex role='status' aria-live='polite' h={80}>
{!loading && (
<Text size={200}>
The Egyptian pyramids are ancient masonry structures located in Egypt. Sources cite at
least 118 identified "Egyptian" pyramids. Approximately 80 pyramids were built within
the Kingdom of Kush, now located in the modern country of Sudan.
</Text>
)}
<Skeleton hidden={!loading}>
<Skeleton.Text amount={2} />
<Skeleton.Text y='40' width='60%' />
</Skeleton>
</Flex>
</>
);
};
export default Demo;
Usage with other elements
tsx
import React from 'react';
import Skeleton from '@semcore/ui/skeleton';
const Demo = () => {
return (
<Skeleton>
<circle cx='30' cy='30' r='30' />
<rect x='70' y='0' rx='4' ry='4' width='20%' height='38' />
<rect x='70' y='50' rx='4' ry='4' width='60%' height='8' />
<rect x='0' y='70' rx='4' ry='4' height='250' width='100%' />
</Skeleton>
);
};
export default Demo;
Skeleton examples for charts
Use h={100}
and w={100}
to adjust the height and width of the skeleton.
tsx
import React from 'react';
import Card from '@semcore/ui/card';
import {
LineChartSkeleton,
AreaChartSkeleton,
BarChartSkeleton,
CompactHorizontalBarChartSkeleton,
VennChartSkeleton,
ScatterPlotChartSkeleton,
BubbleChartSkeleton,
RadialTreeChartSkeleton,
HistogramChartSkeleton,
DonutChartSkeleton,
} from '@semcore/ui/skeleton';
const Demo = () => {
return (
<>
<Card mb={5}>
<Card.Header>
<Card.Title>LineChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<LineChartSkeleton />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>LineChart skeleton (type=monotone)</Card.Title>
</Card.Header>
<Card.Body>
<LineChartSkeleton type='monotone' />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>AreaChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<AreaChartSkeleton />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>AreaChart skeleton (type=monotone)</Card.Title>
</Card.Header>
<Card.Body>
<AreaChartSkeleton type='monotone' />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>BarChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<BarChartSkeleton />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>BarChart skeleton (layout=vertical)</Card.Title>
</Card.Header>
<Card.Body>
<BarChartSkeleton layout='vertical' />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>CompactHorizontalBarChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<CompactHorizontalBarChartSkeleton />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>HistogramChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<HistogramChartSkeleton />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>HistogramChart skeleton (layout=vertical)</Card.Title>
</Card.Header>
<Card.Body>
<HistogramChartSkeleton layout='vertical' />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>DonutChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<DonutChartSkeleton />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>DonutChart skeleton (halfsize)</Card.Title>
</Card.Header>
<Card.Body>
<DonutChartSkeleton halfsize />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>ScatterPlotChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<ScatterPlotChartSkeleton />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>BubbleChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<BubbleChartSkeleton />
</Card.Body>
</Card>
<Card mb={5}>
<Card.Header>
<Card.Title>VennChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<VennChartSkeleton />
</Card.Body>
</Card>
<Card>
<Card.Header>
<Card.Title>RadialTreeChart skeleton</Card.Title>
</Card.Header>
<Card.Body>
<RadialTreeChartSkeleton />
</Card.Body>
</Card>
</>
);
};
export default Demo;