Skip to content
ui8kit

primitive / kit

Kit Text

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

Install

npx ui8kit add kit-text

Pulls in: kit-slot, 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-text
kit/ui/text/Text.svelte
<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
  Text renders the requested text element (default p).
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type TextProps = {
    tag?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote" | "figcaption" | "pre" | "code" | "small" | "strong" | "em" | "time" | "legend" | "del" | "ins";
    class?: string;
    children?: Snippet;
    [key: string]: unknown;
  };
</script>

<script lang="ts">
  import { textClasses } from "./text.shared";
  import { safeRest } from "../../utils/expr";
  import { resolveTag, TagGroup } from "../../utils/tags";

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

  const rest = $derived(safeRest(rawRest));
  const cls = $derived(textClasses({ className }));
  const resolvedTagValue = $derived(resolveTag(tag, "p", TagGroup.Text));
</script>

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

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

/** Text renders the requested text element (default p). */
export type TextBaseProps = {
  tag?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote" | "figcaption" | "pre" | "code" | "small" | "strong" | "em" | "time" | "legend" | "del" | "ins";
};

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

/** Compose Text classes without rendering — the cross-runtime `asChild` substitute. */
export function textClasses(input: TextClassesInput = {}): 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-text
kit/ui/text/text.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.text — shared TypeScript contract (types + classes helpers)

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

/** Text renders the requested text element (default p). */
export type TextBaseProps = {
  tag?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote" | "figcaption" | "pre" | "code" | "small" | "strong" | "em" | "time" | "legend" | "del" | "ins";
};

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

/** Compose Text classes without rendering — the cross-runtime `asChild` substitute. */
export function textClasses(input: TextClassesInput = {}): string {
  return cn(input.className);
}
kit/ui/text/text.tsx
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
 * Text is the polymorphic text primitive. `tag` accepts HTML5 text elements
 * only (p, span, h1–h6, blockquote, code, …); anything else falls back to p.
 */

import { forwardRef, type ReactNode, type HTMLAttributes, type ElementType, type Ref } from "react";
import { textClasses } from "./text.shared";
import { safeRest } from "../../utils/expr";
import { resolveTag, TagGroup } from "../../utils/tags";
import { Slot } from "../slot/slot";

/**
 * Text renders the requested text element (default p).
 */
export type TextProps = Omit<HTMLAttributes<HTMLElement>, "className" | "children" | "tag"> & {
  tag?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote" | "figcaption" | "pre" | "code" | "small" | "strong" | "em" | "time" | "legend" | "del" | "ins";
  className?: string;
  children?: ReactNode;
  asChild?: boolean;
};

export const Text = forwardRef<HTMLElement, TextProps>(function Text(
  { tag, className, children, asChild, ...rawRest },
  ref
) {
  const rest = safeRest(rawRest);
  const cls = textClasses({ className });
  const resolvedTagValue = resolveTag(tag, "p", TagGroup.Text);
  const Tag = resolvedTagValue as ElementType;
  if (asChild) {
    return (
      <Slot ref={ref} className={cls} {...rest}>
        {children}
      </Slot>
    );
  }
  return (
    <Tag ref={ref as Ref<HTMLElement>} className={cls || undefined} {...rest}>
      {children}
    </Tag>
  );
});
Text.displayName = "Text";

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-text
kit/ui/text/Text.vue
<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
  Text renders the requested text element (default p).
-->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import { textClasses } from "./text.shared";
import { safeRest } from "../../utils/expr";
import { resolveTag, TagGroup } from "../../utils/tags";

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

const props = defineProps<{
  tag?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote" | "figcaption" | "pre" | "code" | "small" | "strong" | "em" | "time" | "legend" | "del" | "ins";
}>();

const attrs = useAttrs();
const callerClass = computed(() => attrs.class as string | undefined);
const restAttrs = computed(() => {
  const { class: _class, ...restEntries } = attrs;
  return safeRest(restEntries);
});
const cls = computed(() => textClasses({ className: callerClass.value }));
const resolvedTagValue = computed(() => resolveTag(props.tag, "p", TagGroup.Text));
</script>

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

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

/** Text renders the requested text element (default p). */
export type TextBaseProps = {
  tag?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote" | "figcaption" | "pre" | "code" | "small" | "strong" | "em" | "time" | "legend" | "del" | "ins";
};

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

/** Compose Text classes without rendering — the cross-runtime `asChild` substitute. */
export function textClasses(input: TextClassesInput = {}): 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-text
kit/ui/text/text.shared.ts
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.text — shared TypeScript contract (types + classes helpers)

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

/** Text renders the requested text element (default p). */
export type TextBaseProps = {
  tag?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote" | "figcaption" | "pre" | "code" | "small" | "strong" | "em" | "time" | "legend" | "del" | "ins";
};

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

/** Compose Text classes without rendering — the cross-runtime `asChild` substitute. */
export function textClasses(input: TextClassesInput = {}): string {
  return cn(input.className);
}
kit/ui/text/text.solid.tsx
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
 * Text is the polymorphic text primitive. `tag` accepts HTML5 text elements
 * only (p, span, h1–h6, blockquote, code, …); anything else falls back to p.
 */

import { splitProps, type JSX, type Component } from "solid-js";
import { Dynamic } from "solid-js/web";
import { textClasses } from "./text.shared";
import { safeRest } from "../../utils/expr";
import { resolveTag, TagGroup } from "../../utils/tags";

/**
 * Text renders the requested text element (default p).
 */
export type TextProps = Omit<JSX.HTMLAttributes<HTMLElement>, "class" | "className" | "children" | "tag"> & {
  tag?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "blockquote" | "figcaption" | "pre" | "code" | "small" | "strong" | "em" | "time" | "legend" | "del" | "ins";
  class?: string;
  className?: string;
  children?: JSX.Element;
};

export const Text: Component<TextProps> = (props) => {
  const [local, rest] = splitProps(props, ["tag", "class", "className", "children"]);
  const resolvedTagValue = () => resolveTag(local.tag, "p", TagGroup.Text);
  const cls = () => textClasses({ className: local.class ?? local.className });
  return (
    <Dynamic component={resolvedTagValue()} {...(cls() ? { class: cls() } : {})} {...safeRest(rest)}>
      {local.children}
    </Dynamic>
  );
};

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

/*
Text is the polymorphic text primitive. `tag` accepts HTML5 text elements
only (p, span, h1–h6, blockquote, code, …); anything else falls back to p.
*/

package text

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

// TextProps configures Text.
type TextProps struct {
	// Class — token class names supplied by the consumer
	Class string
	// Tag — HTML5 text tag (default p)
	Tag string
	Attrs templ.Attributes
}

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

// Text renders the Text contract.
templ Text(p TextProps) {
	switch uiutils.ResolveTag(p.Tag, "p", uiutils.TagGroupText) {
	case "span":
		<span
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</span>
	case "h1":
		<h1
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</h1>
	case "h2":
		<h2
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</h2>
	case "h3":
		<h3
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</h3>
	case "h4":
		<h4
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</h4>
	case "h5":
		<h5
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</h5>
	case "h6":
		<h6
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</h6>
	case "blockquote":
		<blockquote
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</blockquote>
	case "figcaption":
		<figcaption
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</figcaption>
	case "pre":
		<pre
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</pre>
	case "code":
		<code
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</code>
	case "small":
		<small
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</small>
	case "strong":
		<strong
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</strong>
	case "em":
		<em
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</em>
	case "time":
		<time
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</time>
	case "legend":
		<legend
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</legend>
	case "del":
		<del
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</del>
	case "ins":
		<ins
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</ins>
	default:
		<p
			if TextClasses(p) != "" {
				class={ TextClasses(p) }
			}
			{ uiutils.RestAttrs(p.Attrs, false)... }
		>
			{ children... }
		</p>
	}
}

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-text
ui/text/Text.html.twig
{# Code generated by @ui8kit/codegen. DO NOT EDIT. #}
{# Text — Text renders the requested text element (default p). #}
{# @param class (string) #}
{# @param tag (string) #}
{# @param attrs (attrs) #}
{# @param children (children) #}
{% set class = class|default('') %}
{% set tag = tag|default('') %}
{% set attrs = attrs|default([]) %}
{% set children = children|default('') %}
{% set uiTag = ui8kit_resolve_tag(tag, 'p', 'Text') %}
{% if (uiTag is same as('span')) %}<span{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</span>{% elseif (uiTag is same as('h1')) %}<h1{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</h1>{% elseif (uiTag is same as('h2')) %}<h2{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</h2>{% elseif (uiTag is same as('h3')) %}<h3{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</h3>{% elseif (uiTag is same as('h4')) %}<h4{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</h4>{% elseif (uiTag is same as('h5')) %}<h5{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</h5>{% elseif (uiTag is same as('h6')) %}<h6{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</h6>{% elseif (uiTag is same as('blockquote')) %}<blockquote{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</blockquote>{% elseif (uiTag is same as('figcaption')) %}<figcaption{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</figcaption>{% elseif (uiTag is same as('pre')) %}<pre{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</pre>{% elseif (uiTag is same as('code')) %}<code{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</code>{% elseif (uiTag is same as('small')) %}<small{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</small>{% elseif (uiTag is same as('strong')) %}<strong{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</strong>{% elseif (uiTag is same as('em')) %}<em{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</em>{% elseif (uiTag is same as('time')) %}<time{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</time>{% elseif (uiTag is same as('legend')) %}<legend{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</legend>{% elseif (uiTag is same as('del')) %}<del{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</del>{% elseif (uiTag is same as('ins')) %}<ins{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</ins>{% else %}<p{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textClasses', {'class': class, 'tag': tag}))}, attrs) }}>{{ children|raw }}</p>{% endif %}

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-text
ui/text/Text.latte
{* Code generated by @ui8kit/codegen. DO NOT EDIT. *}
{* Text — Text renders the requested text element (default p). *}
{parameters
  string $class = '',
  string $tag = '',
  array $attrs = [],
  string $children = '',
}
{var $uiTag = \UI8Kit\Latte\Rt::resolveTag($tag, 'p', 'Text')}
{if ($uiTag === 'span')}<span n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</span>{elseif ($uiTag === 'h1')}<h1 n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</h1>{elseif ($uiTag === 'h2')}<h2 n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</h2>{elseif ($uiTag === 'h3')}<h3 n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</h3>{elseif ($uiTag === 'h4')}<h4 n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</h4>{elseif ($uiTag === 'h5')}<h5 n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</h5>{elseif ($uiTag === 'h6')}<h6 n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</h6>{elseif ($uiTag === 'blockquote')}<blockquote n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</blockquote>{elseif ($uiTag === 'figcaption')}<figcaption n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</figcaption>{elseif ($uiTag === 'pre')}<pre n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</pre>{elseif ($uiTag === 'code')}<code n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</code>{elseif ($uiTag === 'small')}<small n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</small>{elseif ($uiTag === 'strong')}<strong n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</strong>{elseif ($uiTag === 'em')}<em n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</em>{elseif ($uiTag === 'time')}<time n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</time>{elseif ($uiTag === 'legend')}<legend n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</legend>{elseif ($uiTag === 'del')}<del n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</del>{elseif ($uiTag === 'ins')}<ins n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</ins>{else}<p n:attr="[
  'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textClasses(['class' => $class, 'tag' => $tag])),
  ...\UI8Kit\Latte\Rt::restAttrs($attrs),
]">{$children|noescape}</p>{/if}

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-text
ui/text/text.html.j2
{#- Code generated by @ui8kit/codegen. DO NOT EDIT.
    Text: Text renders the requested text element (default p).
    Props (p): Class (string), Tag (string), Attrs (attrs), Children (children).
    children: TRUSTED HTML printed with |safe — never pass unescaped user input.
    Classes without rendering: text_classes(p) (no asChild in Jinja2). -#}
{%- set tag1 = ui_resolve_tag(ui_def(p['Tag'], ''), 'p', ['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'figcaption', 'pre', 'code', 'small', 'strong', 'em', 'time', 'legend', 'del', 'ins']) %}<{{ tag1 }}
  {%- with cls = text_classes(p) %}{%- if cls %} class="{{ cls }}"{%- endif %}{%- endwith %}
  {{ ui_attr_html(ui_def(p['Attrs'], {})) }}
>{{ children|default('', true)|safe }}</{{ tag1 }}>

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.