A custom element that acts as a placeholder to indicate that some content will eventually be rendered.
MIT License
A custom element that acts as a placeholder to indicate that some content will eventually be rendered.
npm install --save @georapbox/skeleton-placeholder-element
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';
<skeleton-placeholder effect="wave" variant="pill"></skeleton-placeholder>
By default, the component is style-free to remain as less opinionated as possible. However, you can style the various elements of the component using CSS Parts and CSS Custom Properties provided for this purpose.
Name | Reflects | Type | Required | Default | Description |
---|---|---|---|---|---|
effect |
✓ | 'none' | 'wave' | 'fade' |
- | 'none' |
The animation effect the skeleton element will use. |
variant |
✓ | 'circle' | 'rect' | 'pill' |
- | "" |
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. |
Name | Description |
---|---|
(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. |
Name | Description |
---|---|
wrapper |
The skeleton's internal wrapper element. |
placeholder |
The skeleton's placeholder element. |
Name | Description |
---|---|
--border-radius |
The border radius of the placeholder element. |
--color |
The color of the placeholder element. |
--wave-color |
The color of the wave effect. |
Name | Type | Description | Arguments |
---|---|---|---|
defineCustomElement |
Static | Defines/registers the custom element with the name provided. If no name is provided, the default name is used. The method checks if the element is already defined, hence will skip trying to redefine it. | elementName='skeleton-placeholder' |
For API updates and breaking changes, check the CHANGELOG.
The project requires Node.js
and npm
to be installed on your environment. Preferrably, use nvm Node Version Manager and use the version of Node.js specified in the .nvmrc
file by running nvm use
.
Install the project dependencies by running the following command.
npm install
Watch for changes and start a development server by running the following command.
npm start
Lint the code by running the following command.
npm run lint
Run the tests by running any of the following commands.
npm test
npm run test:watch # watch mode
Create a production build by running the following command.
npm run build