Skip to content
ui8kit

primitive / kit

Kit Progress

UI8Kit 3 Progress primitive (unstyled), from @ui8kit/registry

Install

npx ui8kit add kit-progress

Pulls in: utils

Preview

No static preview for this item: it needs content or a parent that this page cannot supply. The code is below.

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 kit-progress
kit/ui/progress/Progress.svelte
<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
  Progress renders a native progress element; children are the fallback text.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type ProgressProps = {
    class?: string;
    children?: Snippet;
    [key: string]: unknown;
  };
</script>

<script lang="ts">
  import { progressClasses } from "./progress.shared";
  import { safeRest } from "../../utils/expr";

  let {
    class: className,
    children,
    ...rawRest
  }: ProgressProps = $props();

  const rest = $derived(safeRest(rawRest, { blank: ["max", "aria-label"] }));
  const cls = $derived(progressClasses({ className }));
</script>

<progress {...(cls ? { class: cls } : {})} {...rest}>
  {@render children?.()}
</progress>
kit/ui/progress/progress.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.progress — shared TypeScript contract (types + classes helpers)

import { cn } from "../../utils";

/** Progress renders a native progress element; children are the fallback text. */
export type ProgressBaseProps = {

};

export type ProgressClassesInput = {
  className?: string;
};

/** Compose Progress classes without rendering — the cross-runtime `asChild` substitute. */
export function progressClasses(input: ProgressClassesInput = {}): string {
  return cn(input.className);
}

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 kit-progress
kit/ui/progress/progress.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.progress — shared TypeScript contract (types + classes helpers)

import { cn } from "../../utils";

/** Progress renders a native progress element; children are the fallback text. */
export type ProgressBaseProps = {

};

export type ProgressClassesInput = {
  className?: string;
};

/** Compose Progress classes without rendering — the cross-runtime `asChild` substitute. */
export function progressClasses(input: ProgressClassesInput = {}): string {
  return cn(input.className);
}
kit/ui/progress/progress.tsx
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
 * Progress is native task progress (value/max); omit value for indeterminate.
 */

import { forwardRef, type ReactNode, type ProgressHTMLAttributes } from "react";
import { progressClasses } from "./progress.shared";
import { safeRest } from "../../utils/expr";

/**
 * Progress renders a native progress element; children are the fallback text.
 */
export type ProgressProps = Omit<ProgressHTMLAttributes<HTMLProgressElement>, "className" | "children"> & {
  className?: string;
  children?: ReactNode;
};

export const Progress = forwardRef<HTMLProgressElement, ProgressProps>(function Progress(
  { className, children, ...rawRest },
  ref
) {
  const rest = safeRest(rawRest, { blank: ["max", "aria-label"] });
  const cls = progressClasses({ className });
  return (
    <progress ref={ref} className={cls || undefined} {...rest}>
      {children}
    </progress>
  );
});
Progress.displayName = "Progress";

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 kit-progress
kit/ui/progress/Progress.vue
<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
  Progress renders a native progress element; children are the fallback text.
-->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import { progressClasses } from "./progress.shared";
import { safeRest } from "../../utils/expr";

defineOptions({ name: "Progress", inheritAttrs: false });

const attrs = useAttrs();
const callerClass = computed(() => attrs.class as string | undefined);
const restAttrs = computed(() => {
  const { class: _class, ...restEntries } = attrs;
  return safeRest(restEntries, { blank: ["max", "aria-label"] });
});
const cls = computed(() => progressClasses({ className: callerClass.value }));
</script>

<template>
  <progress :class="cls || undefined" v-bind="restAttrs">
    <slot />
  </progress>
</template>
kit/ui/progress/progress.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.progress — shared TypeScript contract (types + classes helpers)

import { cn } from "../../utils";

/** Progress renders a native progress element; children are the fallback text. */
export type ProgressBaseProps = {

};

export type ProgressClassesInput = {
  className?: string;
};

/** Compose Progress classes without rendering — the cross-runtime `asChild` substitute. */
export function progressClasses(input: ProgressClassesInput = {}): string {
  return cn(input.className);
}

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 kit-progress
kit/ui/progress/progress.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.progress — shared TypeScript contract (types + classes helpers)

import { cn } from "../../utils";

/** Progress renders a native progress element; children are the fallback text. */
export type ProgressBaseProps = {

};

export type ProgressClassesInput = {
  className?: string;
};

/** Compose Progress classes without rendering — the cross-runtime `asChild` substitute. */
export function progressClasses(input: ProgressClassesInput = {}): string {
  return cn(input.className);
}
kit/ui/progress/progress.solid.tsx
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
 * Progress is native task progress (value/max); omit value for indeterminate.
 */

import { splitProps, type JSX, type Component } from "solid-js";
import { progressClasses } from "./progress.shared";
import { safeRest } from "../../utils/expr";

/**
 * Progress renders a native progress element; children are the fallback text.
 */
export type ProgressProps = Omit<JSX.ProgressHTMLAttributes<HTMLProgressElement>, "class" | "className" | "children"> & {
  class?: string;
  className?: string;
  children?: JSX.Element;
};

export const Progress: Component<ProgressProps> = (props) => {
  const [local, rest] = splitProps(props, ["class", "className", "children"]);
  const cls = () => progressClasses({ className: local.class ?? local.className });
  return (
    <progress {...(cls() ? { class: cls() } : {})} {...safeRest(rest, { blank: ["max", "aria-label"] })}>
      {local.children}
    </progress>
  );
};

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 kit-progress
ui/progress/progress.templ
// Code generated by @ui8kit/codegen. DO NOT EDIT.

/*
Progress is native task progress (value/max); omit value for indeterminate.
*/

package progress

import (
	uiutils "github.com/ui8kit/codegen/generated/templ/utils"
)

// ProgressProps configures Progress.
type ProgressProps struct {
	// Class — token class names supplied by the consumer
	Class string
	Value *string
	Max string
	AriaLabel string
	Attrs templ.Attributes
}

// ProgressClasses composes Progress classes without rendering —
// the server-composition escape hatch for custom root elements (no asChild in templ).
func ProgressClasses(p ProgressProps) string {
	return uiutils.Cn(p.Class)
}

// Progress renders the Progress contract.
templ Progress(p ProgressProps) {
	<progress
		if ProgressClasses(p) != "" {
			class={ ProgressClasses(p) }
		}
		if !uiutils.HasAttr(p.Attrs, "value") {
			if p.Value != nil {
				value={ *p.Value }
			}
		}
		if !uiutils.HasAttr(p.Attrs, "max") {
			if uiutils.IsSetStr(p.Max) {
				max={ p.Max }
			}
		}
		if !uiutils.HasAttr(p.Attrs, "aria-label") {
			if uiutils.IsSetStr(p.AriaLabel) {
				aria-label={ p.AriaLabel }
			}
		}
		{ uiutils.RestAttrs(p.Attrs, false, "max", "aria-label")... }
	>
		{ children... }
	</progress>
}

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 kit-progress
ui/progress/Progress.html.twig
{# Code generated by @ui8kit/codegen. DO NOT EDIT. #}
{# Progress — Progress renders a native progress element; children are the fallback text. #}
{# @param class (string) #}
{# @param value (string) #}
{# @param max (string) #}
{# @param ariaLabel (string) #}
{# @param attrs (attrs) #}
{# @param children (children) #}
{% set class = class|default('') %}
{% set value = value ?? null %}
{% set max = max ?? null %}
{% set ariaLabel = ariaLabel ?? null %}
{% set attrs = attrs|default([]) %}
{% set children = children|default('') %}
<progress{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('progressClasses', {'class': class, 'value': value, 'max': max, 'ariaLabel': ariaLabel})), 'value': value, 'max': ui8kit_or_null(max), 'aria-label': ui8kit_or_null(ariaLabel)}, attrs, false, ['max', 'aria-label']) }}>{{ children|raw }}</progress>

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 kit-progress
ui/progress/Progress.latte
{* Code generated by @ui8kit/codegen. DO NOT EDIT. *}
{* Progress — Progress renders a native progress element; children are the fallback text. *}
{parameters
  string $class = '',
  ?string $value = null,
  ?string $max = null,
  ?string $ariaLabel = null,
  array $attrs = [],
  string $children = '',
}
<progress n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::progressClasses(['class' => $class, 'value' => $value, 'max' => $max, 'ariaLabel' => $ariaLabel])),
  'value' => $value,
  'max' => \UI8Kit\Latte\Rt::orNull($max),
  'aria-label' => \UI8Kit\Latte\Rt::orNull($ariaLabel),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs, false, ['max', 'aria-label']),
]">{$children|noescape}</progress>

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 kit-progress
ui/progress/progress.html.j2
{#- Code generated by @ui8kit/codegen. DO NOT EDIT.
    Progress: Progress renders a native progress element; children are the fallback text.
    Props (p): Class (string), Value (string), Max (string), AriaLabel (string), Attrs (attrs), Children (children).
    children: TRUSTED HTML printed with |safe — never pass unescaped user input.
    Classes without rendering: progress_classes(p) (no asChild in Jinja2). -#}
<progress
  {%- with cls = progress_classes(p) %}{%- if cls %} class="{{ cls }}"{%- endif %}{%- endwith %}
  {%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'value') %}{%- if p['Value'] is defined and p['Value'] is not none %} value="{{ p['Value'] }}"{%- endif %}{%- endif %}
  {%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'max') %}{%- if ui_is_set_str(p['Max']) %} max="{{ p['Max'] }}"{%- endif %}{%- endif %}
  {%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'aria-label') %}{%- if ui_is_set_str(p['AriaLabel']) %} aria-label="{{ p['AriaLabel'] }}"{%- endif %}{%- endif %}
  {{ ui_attr_html(ui_def(p['Attrs'], {}), false, ['max', 'aria-label']) }}
>{{ children|default('', true)|safe }}</progress>

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 data for this item.