Kit Meter
UI8Kit 3 Meter primitive (unstyled), from @ui8kit/registry
Install
npx ui8kit add kit-meterPulls 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-cdnnpx ui8kit add kit-meter<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
Meter renders a native meter; children are the fallback text.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
export type MeterProps = {
class?: string;
children?: Snippet;
[key: string]: unknown;
};
</script>
<script lang="ts">
import { meterClasses } from "./meter.shared";
import { safeRest } from "../../utils/expr";
let {
class: className,
children,
...rawRest
}: MeterProps = $props();
const rest = $derived(safeRest(rawRest, { blank: ["min", "max", "low", "high", "optimum", "aria-label"] }));
const cls = $derived(meterClasses({ className }));
</script>
<meter {...(cls ? { class: cls } : {})} {...rest}>
{@render children?.()}
</meter>
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.meter — shared TypeScript contract (types + classes helpers)
import { cn } from "../../utils";
/** Meter renders a native meter; children are the fallback text. */
export type MeterBaseProps = {
};
export type MeterClassesInput = {
className?: string;
};
/** Compose Meter classes without rendering — the cross-runtime `asChild` substitute. */
export function meterClasses(input: MeterClassesInput = {}): string {
return cn(input.className);
}
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-cdnnpx ui8kit add kit-meter// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.meter — shared TypeScript contract (types + classes helpers)
import { cn } from "../../utils";
/** Meter renders a native meter; children are the fallback text. */
export type MeterBaseProps = {
};
export type MeterClassesInput = {
className?: string;
};
/** Compose Meter classes without rendering — the cross-runtime `asChild` substitute. */
export function meterClasses(input: MeterClassesInput = {}): string {
return cn(input.className);
}
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
* Meter is a native gauge for a known range (value/min/max).
*/
import { forwardRef, type ReactNode, type MeterHTMLAttributes } from "react";
import { meterClasses } from "./meter.shared";
import { safeRest } from "../../utils/expr";
/**
* Meter renders a native meter; children are the fallback text.
*/
export type MeterProps = Omit<MeterHTMLAttributes<HTMLMeterElement>, "className" | "children"> & {
className?: string;
children?: ReactNode;
};
export const Meter = forwardRef<HTMLMeterElement, MeterProps>(function Meter(
{ className, children, ...rawRest },
ref
) {
const rest = safeRest(rawRest, { blank: ["min", "max", "low", "high", "optimum", "aria-label"] });
const cls = meterClasses({ className });
return (
<meter ref={ref} className={cls || undefined} {...rest}>
{children}
</meter>
);
});
Meter.displayName = "Meter";
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-cdnnpx ui8kit add kit-meter<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
Meter renders a native meter; children are the fallback text.
-->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import { meterClasses } from "./meter.shared";
import { safeRest } from "../../utils/expr";
defineOptions({ name: "Meter", 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: ["min", "max", "low", "high", "optimum", "aria-label"] });
});
const cls = computed(() => meterClasses({ className: callerClass.value }));
</script>
<template>
<meter :class="cls || undefined" v-bind="restAttrs">
<slot />
</meter>
</template>
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.meter — shared TypeScript contract (types + classes helpers)
import { cn } from "../../utils";
/** Meter renders a native meter; children are the fallback text. */
export type MeterBaseProps = {
};
export type MeterClassesInput = {
className?: string;
};
/** Compose Meter classes without rendering — the cross-runtime `asChild` substitute. */
export function meterClasses(input: MeterClassesInput = {}): string {
return cn(input.className);
}
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-cdnnpx ui8kit add kit-meter// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.meter — shared TypeScript contract (types + classes helpers)
import { cn } from "../../utils";
/** Meter renders a native meter; children are the fallback text. */
export type MeterBaseProps = {
};
export type MeterClassesInput = {
className?: string;
};
/** Compose Meter classes without rendering — the cross-runtime `asChild` substitute. */
export function meterClasses(input: MeterClassesInput = {}): string {
return cn(input.className);
}
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
* Meter is a native gauge for a known range (value/min/max).
*/
import { splitProps, type JSX, type Component } from "solid-js";
import { meterClasses } from "./meter.shared";
import { safeRest } from "../../utils/expr";
/**
* Meter renders a native meter; children are the fallback text.
*/
export type MeterProps = Omit<JSX.MeterHTMLAttributes<HTMLMeterElement>, "class" | "className" | "children"> & {
class?: string;
className?: string;
children?: JSX.Element;
};
export const Meter: Component<MeterProps> = (props) => {
const [local, rest] = splitProps(props, ["class", "className", "children"]);
const cls = () => meterClasses({ className: local.class ?? local.className });
return (
<meter {...(cls() ? { class: cls() } : {})} {...safeRest(rest, { blank: ["min", "max", "low", "high", "optimum", "aria-label"] })}>
{local.children}
</meter>
);
};
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-cdnnpx ui8kit add kit-meter// Code generated by @ui8kit/codegen. DO NOT EDIT.
/*
Meter is a native gauge for a known range (value/min/max).
*/
package meter
import (
uiutils "github.com/ui8kit/codegen/generated/templ/utils"
)
// MeterProps configures Meter.
type MeterProps struct {
// Class — token class names supplied by the consumer
Class string
Value *string
Min string
Max string
Low string
High string
Optimum string
AriaLabel string
Attrs templ.Attributes
}
// MeterClasses composes Meter classes without rendering —
// the server-composition escape hatch for custom root elements (no asChild in templ).
func MeterClasses(p MeterProps) string {
return uiutils.Cn(p.Class)
}
// Meter renders the Meter contract.
templ Meter(p MeterProps) {
<meter
if MeterClasses(p) != "" {
class={ MeterClasses(p) }
}
if !uiutils.HasAttr(p.Attrs, "value") {
if p.Value != nil {
value={ *p.Value }
}
}
if !uiutils.HasAttr(p.Attrs, "min") {
if uiutils.IsSetStr(p.Min) {
min={ p.Min }
}
}
if !uiutils.HasAttr(p.Attrs, "max") {
if uiutils.IsSetStr(p.Max) {
max={ p.Max }
}
}
if !uiutils.HasAttr(p.Attrs, "low") {
if uiutils.IsSetStr(p.Low) {
low={ p.Low }
}
}
if !uiutils.HasAttr(p.Attrs, "high") {
if uiutils.IsSetStr(p.High) {
high={ p.High }
}
}
if !uiutils.HasAttr(p.Attrs, "optimum") {
if uiutils.IsSetStr(p.Optimum) {
optimum={ p.Optimum }
}
}
if !uiutils.HasAttr(p.Attrs, "aria-label") {
if uiutils.IsSetStr(p.AriaLabel) {
aria-label={ p.AriaLabel }
}
}
{ uiutils.RestAttrs(p.Attrs, false, "min", "max", "low", "high", "optimum", "aria-label")... }
>
{ children... }
</meter>
}
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-cdnnpx ui8kit add kit-meter{# Code generated by @ui8kit/codegen. DO NOT EDIT. #}
{# Meter — Meter renders a native meter; children are the fallback text. #}
{# @param class (string) #}
{# @param value (string) #}
{# @param min (string) #}
{# @param max (string) #}
{# @param low (string) #}
{# @param high (string) #}
{# @param optimum (string) #}
{# @param ariaLabel (string) #}
{# @param attrs (attrs) #}
{# @param children (children) #}
{% set class = class|default('') %}
{% set value = value ?? null %}
{% set min = min ?? null %}
{% set max = max ?? null %}
{% set low = low ?? null %}
{% set high = high ?? null %}
{% set optimum = optimum ?? null %}
{% set ariaLabel = ariaLabel ?? null %}
{% set attrs = attrs|default([]) %}
{% set children = children|default('') %}
<meter{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('meterClasses', {'class': class, 'value': value, 'min': min, 'max': max, 'low': low, 'high': high, 'optimum': optimum, 'ariaLabel': ariaLabel})), 'value': value, 'min': ui8kit_or_null(min), 'max': ui8kit_or_null(max), 'low': ui8kit_or_null(low), 'high': ui8kit_or_null(high), 'optimum': ui8kit_or_null(optimum), 'aria-label': ui8kit_or_null(ariaLabel)}, attrs, false, ['min', 'max', 'low', 'high', 'optimum', 'aria-label']) }}>{{ children|raw }}</meter>
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-cdnnpx ui8kit add kit-meter{* Code generated by @ui8kit/codegen. DO NOT EDIT. *}
{* Meter — Meter renders a native meter; children are the fallback text. *}
{parameters
string $class = '',
?string $value = null,
?string $min = null,
?string $max = null,
?string $low = null,
?string $high = null,
?string $optimum = null,
?string $ariaLabel = null,
array $attrs = [],
string $children = '',
}
<meter n:attr="[
'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::meterClasses(['class' => $class, 'value' => $value, 'min' => $min, 'max' => $max, 'low' => $low, 'high' => $high, 'optimum' => $optimum, 'ariaLabel' => $ariaLabel])),
'value' => $value,
'min' => \UI8Kit\Latte\Rt::orNull($min),
'max' => \UI8Kit\Latte\Rt::orNull($max),
'low' => \UI8Kit\Latte\Rt::orNull($low),
'high' => \UI8Kit\Latte\Rt::orNull($high),
'optimum' => \UI8Kit\Latte\Rt::orNull($optimum),
'aria-label' => \UI8Kit\Latte\Rt::orNull($ariaLabel),
...\UI8Kit\Latte\Rt::restAttrs($attrs, false, ['min', 'max', 'low', 'high', 'optimum', 'aria-label']),
]">{$children|noescape}</meter>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-cdnnpx ui8kit add kit-meter{#- Code generated by @ui8kit/codegen. DO NOT EDIT.
Meter: Meter renders a native meter; children are the fallback text.
Props (p): Class (string), Value (string), Min (string), Max (string), Low (string), High (string), Optimum (string), AriaLabel (string), Attrs (attrs), Children (children).
children: TRUSTED HTML printed with |safe — never pass unescaped user input.
Classes without rendering: meter_classes(p) (no asChild in Jinja2). -#}
<meter
{%- with cls = meter_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'], {}), 'min') %}{%- if ui_is_set_str(p['Min']) %} min="{{ p['Min'] }}"{%- 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'], {}), 'low') %}{%- if ui_is_set_str(p['Low']) %} low="{{ p['Low'] }}"{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'high') %}{%- if ui_is_set_str(p['High']) %} high="{{ p['High'] }}"{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'optimum') %}{%- if ui_is_set_str(p['Optimum']) %} optimum="{{ p['Optimum'] }}"{%- 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, ['min', 'max', 'low', 'high', 'optimum', 'aria-label']) }}
>{{ children|default('', true)|safe }}</meter>
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.