2.0.0 • Published 1 year ago

@georapbox/skeleton-placeholder-element v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

npm version npm license

<skeleton-placeholder>

A custom element that acts as a placeholder to indicate that some content will eventually be rendered.

API documentation Demo

Install

$ npm install --save @georapbox/skeleton-placeholder-element

Usage

Script

import { SkeletonPlaceholder } from './node_modules/@georapbox/skeleton-placeholder-element/dist/skeleton-placeholder.js';

// Manually define the element.
SkeletonPlaceholder.defineCustomElement();

Alternatively, you can import the automatically defined custom element.

import './node_modules/@georapbox/skeleton-placeholder-element/dist/skeleton-placeholder-defined.js';

Markup

<skeleton-placeholder effect="wave" variant="pill"></skeleton-placeholder>

API

Properties

NameReflectsTypeDefaultDescription
effect'none' \| 'wave' \| 'fade''none'Optional. Determines the animation effect the skeleton element will use.
variant'circle' \| 'rect' \| 'pill'nullOptional. Determines the skeleton's variations. This is just a set of predefined border-radius values. For more flexibility, you can use the --border-radius custom CSS property.

All of the above properties reflect their values as HTML attributes to keep the element's DOM representation in sync with its JavaScript state.

Slots

NameDescription
(default)It can be used in the rare scenario that you might need to render something inside the placeholder element, such as an image, etc. Check the slot example demo.

CSS Parts

NameDescription
wrapperThe skeleton's internal wrapper element.
placeholderThe skeleton's placeholder element.

CSS Custom Properties

NameDescription
--border-radiusThe element's border radius.
--colorThe color of the element.
--wave-colorThe color of the wave effect.

Changelog

For API updates and breaking changes, check the CHANGELOG.

Browser support

Browsers without native custom element support require a polyfill.

  • Firefox
  • Chrome
  • Microsoft Edge
  • Safari

License

The MIT License (MIT)