Skip to content
ui8kit

primitive / primitives

Skeleton

Skeleton primitive

Install

npx ui8kit add skeleton

Pulls in: kit-box, recipes, utils

Preview

shape: line
shape: block

Code

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdn
npx ui8kit add skeleton
compose/Skeleton.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Skeleton: Box <div> + recipe skeleton. -->
<script lang="ts">
  import type { ComponentProps, Snippet } from "svelte";
  import Prim from "../kit/ui/box/Box.svelte";
  import { cn } from "../kit/utils";
  import { rc } from "./recipes";

  let { "shape": v_shape, class: className, children, ...rest }: Omit<ComponentProps<typeof Prim>, "tag"> & { "shape"?: string | number; class?: string; children?: Snippet } = $props();
  const cls = $derived(cn(rc("skeleton", { "shape": v_shape }), className));
</script>

<Prim tag={"div" as never} class={cls} aria-hidden="true" {...rest}>{@render children?.()}</Prim>

Svelte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdn
npx ui8kit add skeleton
compose/skeleton.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Box as Prim } from "../kit/ui/box/box";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

export type SkeletonProps = Omit<ComponentProps<typeof Prim>, "tag" | "shape"> & { "shape"?: string | number; className?: string };

/** Skeleton: Box <div> + recipe skeleton. */
export function Skeleton({ "shape": v_shape, className, ...rest }: SkeletonProps) {
  return <Prim tag={"div" as never} className={cn(rc("skeleton", { "shape": v_shape }), className)} aria-hidden="true" {...rest} />;
}

React registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdn
npx ui8kit add skeleton
compose/Skeleton.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Skeleton: Box <div> + recipe skeleton. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/box/Box.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

defineOptions({ name: "Skeleton", inheritAttrs: false });
const props = defineProps<{ "shape"?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
  const { class: _class, ...r } = attrs;
  return r;
});
const cls = computed(() => cn(rc("skeleton", { "shape": props["shape"] }), attrs.class as string | undefined));
const tagValue = computed(() => "div");
</script>

<template>
  <Prim :tag="tagValue as never" :class="cls" aria-hidden="true" v-bind="rest"><slot /></Prim>
</template>

Vue registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdn
npx ui8kit add skeleton
compose/skeleton.solid.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import { splitProps, type ComponentProps } from "solid-js";
import { Box as Prim } from "../kit/ui/box/box.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

export type SkeletonProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className" | "shape"> & { "shape"?: string | number; class?: string; className?: string };

/** Skeleton: Box <div> + recipe skeleton. */
export function Skeleton(props: SkeletonProps) {
  const [local, rest] = splitProps(props, ["shape", "class", "className"]);
  return <Prim tag={"div" as never} class={cn(rc("skeleton", { "shape": local["shape"] }), local.class ?? local.className)} aria-hidden="true" {...rest} />;
}

Solid registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdn
npx ui8kit add skeleton
compose/skeleton.templ
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.

package compose

import "github.com/ui8kit/codegen/generated/templ/ui/box"

// SkeletonProps: Skeleton: Box <div> + recipe skeleton.
type SkeletonProps struct {
	Shape string
	box.BoxProps
}

func skeletonInner(p SkeletonProps) box.BoxProps {
	in := p.BoxProps
	in.Class = Join(Rc("skeleton", map[string]string{"shape": p.Shape}), p.BoxProps.Class)
	in.Tag = "div"
	in.Attrs = WithAttrs(in.Attrs, map[string]string{"aria-hidden": "true"})
	return in
}

// Skeleton renders Box with the composition classes.
templ Skeleton(p SkeletonProps) {
	@box.Box(skeletonInner(p)) {
		{ children... }
	}
}

templ registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdn
npx ui8kit add skeleton
compose/Skeleton.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Skeleton: Box <div> + recipe skeleton. Params: shape, class, attrs + the params of Box. #}
{% include 'ui/box/Box.html.twig' with compose_props('Skeleton', _context) only %}

Twig registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdn
npx ui8kit add skeleton
compose/Skeleton.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Skeleton: Box <div> + recipe skeleton. *}
{parameters
  string $class = '',
  string $tag = '',
  array $attrs = [],
  string $children = '',
  $shape = null,
}
{include '../ui/box/Box.latte', ...\CodegenX\Compose\Latte\Compose::props('Skeleton', ['class' => $class, 'tag' => $tag, 'attrs' => $attrs, 'children' => $children, 'shape' => $shape])}

Latte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdn
npx ui8kit add skeleton
compose/skeleton.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
    Skeleton: Box <div> + recipe skeleton. Props (p): Shape, Class, Attrs + the props of Box. -#}
{%- with p = compose_props('Skeleton', p) %}{% include 'ui/box/box.html.j2' %}{% endwith %}

Jinja2 registry item (JSON)

Props

Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.

No props.