Kit Textarea
UI8Kit 3 Textarea primitive (unstyled), from @ui8kit/registry
Install
npx ui8kit add kit-textareaPulls 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-textarea<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
Textarea renders a native textarea; Value is the initial content.
-->
<script lang="ts" module>
export type TextareaProps = {
value?: string;
required?: boolean;
disabled?: boolean;
readOnly?: boolean;
class?: string;
[key: string]: unknown;
};
</script>
<script lang="ts">
import { textareaClasses } from "./textarea.shared";
import { safeRest } from "../../utils/expr";
let {
value,
required,
disabled,
readOnly,
class: className,
...rawRest
}: TextareaProps = $props();
const rest = $derived(safeRest(rawRest, { blank: ["id", "name", "placeholder", "rows", "aria-invalid", "aria-describedby"] }));
const cls = $derived(textareaClasses({ className }));
</script>
<textarea {...(cls ? { class: cls } : {})} required={required || undefined} disabled={disabled || undefined} readonly={readOnly || undefined} {...rest}>{value}</textarea>
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.textarea — shared TypeScript contract (types + classes helpers)
import { cn } from "../../utils";
/** Textarea renders a native textarea; Value is the initial content. */
export type TextareaBaseProps = {
value?: string;
required?: boolean;
disabled?: boolean;
readOnly?: boolean;
};
export type TextareaClassesInput = {
className?: string;
};
/** Compose Textarea classes without rendering — the cross-runtime `asChild` substitute. */
export function textareaClasses(input: TextareaClassesInput = {}): 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-textarea// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.textarea — shared TypeScript contract (types + classes helpers)
import { cn } from "../../utils";
/** Textarea renders a native textarea; Value is the initial content. */
export type TextareaBaseProps = {
value?: string;
required?: boolean;
disabled?: boolean;
readOnly?: boolean;
};
export type TextareaClassesInput = {
className?: string;
};
/** Compose Textarea classes without rendering — the cross-runtime `asChild` substitute. */
export function textareaClasses(input: TextareaClassesInput = {}): string {
return cn(input.className);
}
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
* Textarea is a multi-line native text field.
*/
import { forwardRef, type TextareaHTMLAttributes } from "react";
import { textareaClasses } from "./textarea.shared";
import { safeRest } from "../../utils/expr";
/**
* Textarea renders a native textarea; Value is the initial content.
*/
export type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "className" | "children" | "value" | "required" | "disabled" | "readOnly"> & {
value?: string;
required?: boolean;
disabled?: boolean;
readOnly?: boolean;
className?: string;
};
export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(
{ value, required, disabled, readOnly, className, ...rawRest },
ref
) {
const rest = safeRest(rawRest, { blank: ["id", "name", "placeholder", "rows", "aria-invalid", "aria-describedby"] });
const cls = textareaClasses({ className });
return (
<textarea ref={ref} className={cls || undefined} required={required} disabled={disabled} readOnly={readOnly} {...rest} defaultValue={(value) ?? ""} />
);
});
Textarea.displayName = "Textarea";
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-textarea<!-- Code generated by @ui8kit/codegen. DO NOT EDIT. -->
<!--
Textarea renders a native textarea; Value is the initial content.
-->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import { textareaClasses } from "./textarea.shared";
import { safeRest } from "../../utils/expr";
defineOptions({ name: "Textarea", inheritAttrs: false });
const props = defineProps<{
value?: string;
required?: boolean;
disabled?: boolean;
readOnly?: boolean;
}>();
const attrs = useAttrs();
const callerClass = computed(() => attrs.class as string | undefined);
const restAttrs = computed(() => {
const { class: _class, ...restEntries } = attrs;
return safeRest(restEntries, { blank: ["id", "name", "placeholder", "rows", "aria-invalid", "aria-describedby"] });
});
const cls = computed(() => textareaClasses({ className: callerClass.value }));
</script>
<template>
<textarea :class="cls || undefined" :required="props.required || undefined" :disabled="props.disabled || undefined" :readonly="props.readOnly || undefined" v-bind="restAttrs" :value="(props.value) ?? ''" />
</template>
// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.textarea — shared TypeScript contract (types + classes helpers)
import { cn } from "../../utils";
/** Textarea renders a native textarea; Value is the initial content. */
export type TextareaBaseProps = {
value?: string;
required?: boolean;
disabled?: boolean;
readOnly?: boolean;
};
export type TextareaClassesInput = {
className?: string;
};
/** Compose Textarea classes without rendering — the cross-runtime `asChild` substitute. */
export function textareaClasses(input: TextareaClassesInput = {}): 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-textarea// Code generated by @ui8kit/codegen. DO NOT EDIT.
// ui.textarea — shared TypeScript contract (types + classes helpers)
import { cn } from "../../utils";
/** Textarea renders a native textarea; Value is the initial content. */
export type TextareaBaseProps = {
value?: string;
required?: boolean;
disabled?: boolean;
readOnly?: boolean;
};
export type TextareaClassesInput = {
className?: string;
};
/** Compose Textarea classes without rendering — the cross-runtime `asChild` substitute. */
export function textareaClasses(input: TextareaClassesInput = {}): string {
return cn(input.className);
}
// Code generated by @ui8kit/codegen. DO NOT EDIT.
/**
* Textarea is a multi-line native text field.
*/
import { createEffect, splitProps, type JSX, type Component } from "solid-js";
import { textareaClasses } from "./textarea.shared";
import { safeRest } from "../../utils/expr";
/**
* Textarea renders a native textarea; Value is the initial content.
*/
export type TextareaProps = Omit<JSX.TextareaHTMLAttributes<HTMLTextAreaElement>, "class" | "className" | "children" | "value" | "required" | "disabled" | "readOnly"> & {
value?: string;
required?: boolean;
disabled?: boolean;
readOnly?: boolean;
class?: string;
className?: string;
};
export const Textarea: Component<TextareaProps> = (props) => {
const [local, rest] = splitProps(props, ["value", "required", "disabled", "readOnly", "class", "className"]);
const cls = () => textareaClasses({ className: local.class ?? local.className });
return (
<textarea {...(cls() ? { class: cls() } : {})} required={local.required || undefined} disabled={local.disabled || undefined} readonly={local.readOnly || undefined} {...safeRest(rest, { blank: ["id", "name", "placeholder", "rows", "aria-invalid", "aria-describedby"] })} ref={(el) => createEffect(() => { el.value = (local.value) ?? ""; })}>{(local.value) ?? ""}</textarea>
);
};
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-textarea// Code generated by @ui8kit/codegen. DO NOT EDIT.
/*
Textarea is a multi-line native text field.
*/
package textarea
import (
uiutils "github.com/ui8kit/codegen/generated/templ/utils"
)
// TextareaProps configures Textarea.
type TextareaProps struct {
// Class — token class names supplied by the consumer
Class string
ID string
Name string
// Value — initial content
Value string
Placeholder string
Rows string
Required bool
Disabled bool
ReadOnly bool
AriaInvalid string
AriaDescribedBy string
Attrs templ.Attributes
}
// TextareaClasses composes Textarea classes without rendering —
// the server-composition escape hatch for custom root elements (no asChild in templ).
func TextareaClasses(p TextareaProps) string {
return uiutils.Cn(p.Class)
}
// Textarea renders the Textarea contract.
templ Textarea(p TextareaProps) {
<textarea
if TextareaClasses(p) != "" {
class={ TextareaClasses(p) }
}
if !uiutils.HasAttr(p.Attrs, "id") {
if uiutils.IsSetStr(p.ID) {
id={ p.ID }
}
}
if !uiutils.HasAttr(p.Attrs, "name") {
if uiutils.IsSetStr(p.Name) {
name={ p.Name }
}
}
if !uiutils.HasAttr(p.Attrs, "placeholder") {
if uiutils.IsSetStr(p.Placeholder) {
placeholder={ p.Placeholder }
}
}
if !uiutils.HasAttr(p.Attrs, "rows") {
if uiutils.IsSetStr(p.Rows) {
rows={ p.Rows }
}
}
if !uiutils.HasAttr(p.Attrs, "required") {
required?={ p.Required }
}
if !uiutils.HasAttr(p.Attrs, "disabled") {
disabled?={ p.Disabled }
}
if !uiutils.HasAttr(p.Attrs, "readonly") {
readonly?={ p.ReadOnly }
}
if !uiutils.HasAttr(p.Attrs, "aria-invalid") {
if uiutils.IsSetStr(p.AriaInvalid) {
aria-invalid={ p.AriaInvalid }
}
}
if !uiutils.HasAttr(p.Attrs, "aria-describedby") {
if uiutils.IsSetStr(p.AriaDescribedBy) {
aria-describedby={ p.AriaDescribedBy }
}
}
{ uiutils.RestAttrs(p.Attrs, false, "id", "name", "placeholder", "rows", "aria-invalid", "aria-describedby")... }
>
{ p.Value }
</textarea>
}
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-textarea{# Code generated by @ui8kit/codegen. DO NOT EDIT. #}
{# Textarea — Textarea renders a native textarea; Value is the initial content. #}
{# @param class (string) #}
{# @param id (string) #}
{# @param name (string) #}
{# @param value (string) #}
{# @param placeholder (string) #}
{# @param rows (string) #}
{# @param required (bool) #}
{# @param disabled (bool) #}
{# @param readOnly (bool) #}
{# @param ariaInvalid (string) #}
{# @param ariaDescribedBy (string) #}
{# @param attrs (attrs) #}
{% set class = class|default('') %}
{% set id = id ?? null %}
{% set name = name ?? null %}
{% set value = value|default('') %}
{% set placeholder = placeholder ?? null %}
{% set rows = rows ?? null %}
{% set required = required|default(false) %}
{% set disabled = disabled|default(false) %}
{% set readOnly = readOnly|default(false) %}
{% set ariaInvalid = ariaInvalid ?? null %}
{% set ariaDescribedBy = ariaDescribedBy ?? null %}
{% set attrs = attrs|default([]) %}
<textarea{{ ui8kit_attrs({'class': ui8kit_or_null(ui8kit_classes('textareaClasses', {'class': class, 'id': id, 'name': name, 'value': value, 'placeholder': placeholder, 'rows': rows, 'required': required, 'disabled': disabled, 'readOnly': readOnly, 'ariaInvalid': ariaInvalid, 'ariaDescribedBy': ariaDescribedBy})), 'id': ui8kit_or_null(id), 'name': ui8kit_or_null(name), 'placeholder': ui8kit_or_null(placeholder), 'rows': ui8kit_or_null(rows), 'required': required, 'disabled': disabled, 'readonly': readOnly, 'aria-invalid': ui8kit_or_null(ariaInvalid), 'aria-describedby': ui8kit_or_null(ariaDescribedBy)}, attrs, false, ['id', 'name', 'placeholder', 'rows', 'aria-invalid', 'aria-describedby']) }}>{{ value }}</textarea>
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-textarea{* Code generated by @ui8kit/codegen. DO NOT EDIT. *}
{* Textarea — Textarea renders a native textarea; Value is the initial content. *}
{parameters
string $class = '',
?string $id = null,
?string $name = null,
string $value = '',
?string $placeholder = null,
?string $rows = null,
bool $required = false,
bool $disabled = false,
bool $readOnly = false,
?string $ariaInvalid = null,
?string $ariaDescribedBy = null,
array $attrs = [],
}
<textarea n:attr="[
'class' => \UI8Kit\Latte\Rt::orNull(\UI8Kit\Latte\Classes::textareaClasses(['class' => $class, 'id' => $id, 'name' => $name, 'value' => $value, 'placeholder' => $placeholder, 'rows' => $rows, 'required' => $required, 'disabled' => $disabled, 'readOnly' => $readOnly, 'ariaInvalid' => $ariaInvalid, 'ariaDescribedBy' => $ariaDescribedBy])),
'id' => \UI8Kit\Latte\Rt::orNull($id),
'name' => \UI8Kit\Latte\Rt::orNull($name),
'placeholder' => \UI8Kit\Latte\Rt::orNull($placeholder),
'rows' => \UI8Kit\Latte\Rt::orNull($rows),
'required' => $required,
'disabled' => $disabled,
'readonly' => $readOnly,
'aria-invalid' => \UI8Kit\Latte\Rt::orNull($ariaInvalid),
'aria-describedby' => \UI8Kit\Latte\Rt::orNull($ariaDescribedBy),
...\UI8Kit\Latte\Rt::restAttrs($attrs, false, ['id', 'name', 'placeholder', 'rows', 'aria-invalid', 'aria-describedby']),
]">{=$value}</textarea>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-textarea{#- Code generated by @ui8kit/codegen. DO NOT EDIT.
Textarea: Textarea renders a native textarea; Value is the initial content.
Props (p): Class (string), ID (string), Name (string), Value (string), Placeholder (string), Rows (string), Required (bool), Disabled (bool), ReadOnly (bool), AriaInvalid (string), AriaDescribedBy (string), Attrs (attrs).
Classes without rendering: textarea_classes(p) (no asChild in Jinja2). -#}
<textarea
{%- with cls = textarea_classes(p) %}{%- if cls %} class="{{ cls }}"{%- endif %}{%- endwith %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'id') %}{%- if ui_is_set_str(p['ID']) %} id="{{ p['ID'] }}"{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'name') %}{%- if ui_is_set_str(p['Name']) %} name="{{ p['Name'] }}"{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'placeholder') %}{%- if ui_is_set_str(p['Placeholder']) %} placeholder="{{ p['Placeholder'] }}"{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'rows') %}{%- if ui_is_set_str(p['Rows']) %} rows="{{ p['Rows'] }}"{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'required') %}{%- if ui_def(p['Required'], false) %} required{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'disabled') %}{%- if ui_def(p['Disabled'], false) %} disabled{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'readonly') %}{%- if ui_def(p['ReadOnly'], false) %} readonly{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'aria-invalid') %}{%- if ui_is_set_str(p['AriaInvalid']) %} aria-invalid="{{ p['AriaInvalid'] }}"{%- endif %}{%- endif %}
{%- if not ui_has_attr(ui_def(p['Attrs'], {}), 'aria-describedby') %}{%- if ui_is_set_str(p['AriaDescribedBy']) %} aria-describedby="{{ p['AriaDescribedBy'] }}"{%- endif %}{%- endif %}
{{ ui_attr_html(ui_def(p['Attrs'], {}), false, ['id', 'name', 'placeholder', 'rows', 'aria-invalid', 'aria-describedby']) }}
>{{ ui_def(p['Value'], '') }}</textarea>
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.