Text
Text primitive
Install
npx ui8kit add textPulls in: kit-text, recipes, utils
Preview
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 textcompose/Text.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Text: Text + recipe text. -->
<script lang="ts">
import type { ComponentProps, Snippet } from "svelte";
import Prim from "../kit/ui/text/Text.svelte";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
let { "size": v_size, "weight": v_weight, tag, class: className, children, ...rest }: Omit<ComponentProps<typeof Prim>, "tag"> & { "size"?: string | number; "weight"?: string | number; tag?: string | number; class?: string; children?: Snippet } = $props();
const cls = $derived(cn(rc("text", { "size": v_size, "weight": v_weight }), className));
</script>
<Prim tag={(tag ?? "p") as never} class={cls} {...rest}>{@render children?.()}</Prim>
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 textcompose/text.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Text as Prim } from "../kit/ui/text/text";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type TextProps = Omit<ComponentProps<typeof Prim>, "tag" | "size" | "weight"> & { "size"?: string | number; "weight"?: string | number; tag?: string; className?: string };
/** Text: Text + recipe text. */
export function Text({ "size": v_size, "weight": v_weight, tag, className, ...rest }: TextProps) {
return <Prim tag={(tag ?? "p") as never} className={cn(rc("text", { "size": v_size, "weight": v_weight }), className)} {...rest} />;
}
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 textcompose/Text.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Text: Text + recipe text. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/text/Text.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
defineOptions({ name: "Text", inheritAttrs: false });
const props = defineProps<{ "size"?: string | number; "weight"?: string | number; tag?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
const { class: _class, ...r } = attrs;
return r;
});
const cls = computed(() => cn(rc("text", { "size": props["size"], "weight": props["weight"] }), attrs.class as string | undefined));
const tagValue = computed(() => (props.tag ?? "p"));
</script>
<template>
<Prim :tag="tagValue as never" :class="cls" v-bind="rest"><slot /></Prim>
</template>
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 textcompose/text.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 { Text as Prim } from "../kit/ui/text/text.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type TextProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className" | "size" | "weight"> & { "size"?: string | number; "weight"?: string | number; tag?: string; class?: string; className?: string };
/** Text: Text + recipe text. */
export function Text(props: TextProps) {
const [local, rest] = splitProps(props, ["size", "weight", "tag", "class", "className"]);
return <Prim tag={(local.tag ?? "p") as never} class={cn(rc("text", { "size": local["size"], "weight": local["weight"] }), local.class ?? local.className)} {...rest} />;
}
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 textcompose/text.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/text"
// TextProps: Text: Text + recipe text.
type TextProps struct {
Size string
Weight string
text.TextProps
}
func textInner(p TextProps) text.TextProps {
in := p.TextProps
in.Class = Join(Rc("text", map[string]string{"size": p.Size, "weight": p.Weight}), p.TextProps.Class)
in.Tag = Or(in.Tag, "p")
return in
}
// Text renders Text with the composition classes.
templ Text(p TextProps) {
@text.Text(textInner(p)) {
{ children... }
}
}
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 textcompose/Text.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Text: Text + recipe text. Params: size, weight, tag, class, attrs + the params of Text. #}
{% include 'ui/text/Text.html.twig' with compose_props('Text', _context) only %}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 textcompose/Text.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Text: Text + recipe text. *}
{parameters
string $class = '',
string $tag = '',
array $attrs = [],
string $children = '',
$size = null,
$weight = null,
}
{include '../ui/text/Text.latte', ...\CodegenX\Compose\Latte\Compose::props('Text', ['class' => $class, 'tag' => $tag, 'attrs' => $attrs, 'children' => $children, 'size' => $size, 'weight' => $weight])}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 textcompose/text.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
Text: Text + recipe text. Props (p): Size, Weight, Tag, Class, Attrs + the props of Text. -#}
{%- with p = compose_props('Text', p) %}{% include 'ui/text/text.html.j2' %}{% endwith %}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.
Text renders the requested text element (default p).
| Prop | Type | Default | Description |
|---|---|---|---|
| tag | string | - | HTML5 text tag (default p) |