@ltns/use-skeleton v0.0.6
@ltns/use-skeleton is a React hook used to display skeleton placeholders where content needs to wait for loading.
https://github.com/willltns/use-skeleton/assets/35132956/da5932ed-0981-403c-ad07-d0e6d85a55ed
Install
npm i @ltns/use-skeleton
# or
yarn add @ltns/use-skeletonUsage
import useSkeleton from '@ltns/use-skeleton';
const [ref, setAnimate, animate] = useSkeleton('& > *');
return (
<div ref={ref}>
{animate ? 'Loading...' : null}
<div>Set the width of the element.</div>
<span style={{ display: 'inline-flex' }}>Or use mocking text to expand the width of the element.</span>
</div>
);
CSS Modulesshould be enabled.The skeleton inline element's
displaytype should not beinline(the default for inline elements.), set it toinline-flexorinline-block.Use the
CSS Variablesfeature for custom styling:--ltns-skeleton-bg-color,--ltns-skeleton-sk-color,--ltns-skeleton-anim-str.
transformanimation is better thanbackground-positionanimation in rendering performance.This package distributed with ESNext language level and ES modules system. It means that depending on your browser target you might need to transpile it. Every major bundler provides a way to transpile
node_modulesfully or partially. Address your bundler documentation for more details.