diff --git a/packages/react/README.md b/packages/react/README.md new file mode 100644 index 0000000..314ad41 --- /dev/null +++ b/packages/react/README.md @@ -0,0 +1,45 @@ +# 🔄 Sync Skeleton for React ⚛️ + +A modern skeleton loader that supports syncing multiple elements' loading indicator at the same time. + + + +## Installation + +```tsx +import { useSkeletonSetup } from "@sync-skeleton/react" +// Required for usage +import "@sync-skeleton/core/skeleton.css" + +export function App() { + // Required in the root component for usage + useSkeletonSetup(); + + return ( + // ... + ) +} +``` + +## Usage + +```tsx +import { useSkeleton } from '@sync-skeleton/react' +import styles from './element.module.css' + +export function Element() { + // Use the hoof to get a ref to the element, this establishes the CSS properties needed for the class to work + const ourEl = useSkeleton() + + return ( + // Add the global `loading-skeleton` class to the element +
+ ) +} +``` + +## Caveats + +- `.loading-skeleton` elements must not have an `::after` pseudo-element +- `.loading-skeleton` elements must be `relative`ly or `absolute`ly positioned (defaulted to `relative` through our class) +- `.loading-skeleton` elements must have `overflow` set to `hidden` (defaulted through our class)