Skeleton
A placeholder while content loads.
<skeleton.Skeleton class="h-4 w-40" />Installation
Run the command in the app module.
gx add skeletonThe command writes these files.
| File | Path in the app |
|---|---|
Skeleton.gx |
ui/skeleton/Skeleton.gx |
Skeleton.fixtures.go |
ui/skeleton/Skeleton.fixtures.go |
Copy each file to its path in the app. Change each import of a registry package to the path of that package in the app.
package skeleton
props {
// Class adds classes to the root element.
Class string = ""
// Attrs adds HTML attributes to the root element.
Attrs gx.Attrs = nil
}
<div data-slot="skeleton" class={gx.Cx("animate-pulse rounded-md bg-accent", p.Class)} {...p.Attrs}></div>package skeleton
import "github.com/alternayte/gx"
var SkeletonFixtures = gx.Fixtures[SkeletonProps]{
"Line": {Class: "h-4 w-40"},
"Circle": {Class: "size-10 rounded-full"},
"Card": {Class: "h-24 w-60"},
}The theme must define these tokens: --accent.
Usage
<skeleton.Skeleton class="h-4 w-40" />The skeleton uses the accent colour and a pulse.
Examples
Line
<skeleton.Skeleton class="h-4 w-40" />Circle
<skeleton.Skeleton class="size-10 rounded-full" />Card
<skeleton.Skeleton class="h-24 w-60" />API reference
A tag sets a prop by its name with a lower-case first letter: Class is class.
skeleton.Skeleton
| Prop | Type | Default | Description |
|---|---|---|---|
Class |
string |
"" |
Class adds classes to the root element. |
Attrs |
gx.Attrs |
nil |
Attrs adds HTML attributes to the root element. |
Do and do not
Do
- Match the size of the content that replaces it.
- Use two or three skeletons for a list.
Don't
- Do not leave a skeleton on the page after the load finishes.
- Do not show a skeleton for longer than a moment.
Keyboard
| Key | Action |
|---|---|
| None | The component is static. |