Textarea
Textarea primitive
Install
npx ui8kit add textareaPulls in: kit-textarea, 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 textareacompose/Textarea.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Textarea: Textarea + recipe textarea. -->
<script lang="ts">
import type { ComponentProps, Snippet } from "svelte";
import Prim from "../kit/ui/textarea/Textarea.svelte";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
let { "size": v_size, "variant": v_variant, "state": v_state, class: className, children, ...rest }: ComponentProps<typeof Prim> & { "size"?: string | number; "variant"?: string | number; "state"?: string | number; class?: string; children?: Snippet } = $props();
const cls = $derived(cn(rc("textarea", { "size": v_size, "variant": v_variant, "state": v_state }), className));
</script>
<Prim class={cls} aria-invalid={v_state === "error" ? "true" : undefined} {...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 textareacompose/textarea.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Textarea as Prim } from "../kit/ui/textarea/textarea";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type TextareaProps = Omit<ComponentProps<typeof Prim>, "tag" | "size" | "variant" | "state"> & { "size"?: string | number; "variant"?: string | number; "state"?: string | number; className?: string };
/** Textarea: Textarea + recipe textarea. */
export function Textarea({ "size": v_size, "variant": v_variant, "state": v_state, className, ...rest }: TextareaProps) {
return <Prim className={cn(rc("textarea", { "size": v_size, "variant": v_variant, "state": v_state }), className)} aria-invalid={v_state === "error" ? "true" : undefined} {...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 textareacompose/Textarea.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Textarea: Textarea + recipe textarea. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/textarea/Textarea.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
defineOptions({ name: "Textarea", inheritAttrs: false });
const props = defineProps<{ "size"?: string | number; "variant"?: string | number; "state"?: string | number }>();
const attrs = useAttrs();
const rest = computed(() => {
const { class: _class, ...r } = attrs;
return r;
});
const cls = computed(() => cn(rc("textarea", { "size": props["size"], "variant": props["variant"], "state": props["state"] }), attrs.class as string | undefined));
const tagValue = computed(() => "");
</script>
<template>
<Prim :class="cls" :aria-invalid="props.state === 'error' ? 'true' : undefined" 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 textareacompose/textarea.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 { Textarea as Prim } from "../kit/ui/textarea/textarea.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type TextareaProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className" | "size" | "variant" | "state"> & { "size"?: string | number; "variant"?: string | number; "state"?: string | number; class?: string; className?: string };
/** Textarea: Textarea + recipe textarea. */
export function Textarea(props: TextareaProps) {
const [local, rest] = splitProps(props, ["size", "variant", "state", "class", "className"]);
return <Prim class={cn(rc("textarea", { "size": local["size"], "variant": local["variant"], "state": local["state"] }), local.class ?? local.className)} aria-invalid={local["state"] === "error" ? "true" : undefined} {...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 textareacompose/textarea.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/textarea"
// TextareaProps: Textarea: Textarea + recipe textarea.
type TextareaProps struct {
Size string
Variant string
State string
textarea.TextareaProps
}
func textareaInner(p TextareaProps) textarea.TextareaProps {
in := p.TextareaProps
in.Class = Join(Rc("textarea", map[string]string{"size": p.Size, "variant": p.Variant, "state": p.State}), p.TextareaProps.Class)
if p.State == "error" {
in.AriaInvalid = Or(in.AriaInvalid, "true")
}
return in
}
// Textarea renders Textarea with the composition classes.
templ Textarea(p TextareaProps) {
@textarea.Textarea(textareaInner(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 textareacompose/Textarea.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Textarea: Textarea + recipe textarea. Params: size, variant, state, class, attrs + the params of Textarea. #}
{% include 'ui/textarea/Textarea.html.twig' with compose_props('Textarea', _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 textareacompose/Textarea.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Textarea: Textarea + recipe textarea. *}
{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 = [],
$size = null,
$variant = null,
$state = null,
}
{include '../ui/textarea/Textarea.latte', ...\CodegenX\Compose\Latte\Compose::props('Textarea', ['class' => $class, 'id' => $id, 'name' => $name, 'value' => $value, 'placeholder' => $placeholder, 'rows' => $rows, 'required' => $required, 'disabled' => $disabled, 'readOnly' => $readOnly, 'ariaInvalid' => $ariaInvalid, 'ariaDescribedBy' => $ariaDescribedBy, 'attrs' => $attrs, 'size' => $size, 'variant' => $variant, 'state' => $state])}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 textareacompose/textarea.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
Textarea: Textarea + recipe textarea. Props (p): Size, Variant, State, Class, Attrs + the props of Textarea. -#}
{%- with p = compose_props('Textarea', p) %}{% include 'ui/textarea/textarea.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.
Textarea renders a native textarea; Value is the initial content.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | initial content |
| required | boolean | - | |
| disabled | boolean | - | |
| readOnly | boolean | - |