Skip to content
ui8kit

primitive / primitives

Form

Form primitive

Install

npx ui8kit add form

Pulls in: kit-form, recipes, utils

Preview

default

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 form
compose/Form.svelte
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Form: Form + recipe form. -->
<script lang="ts">
  import type { ComponentProps, Snippet } from "svelte";
  import Prim from "../kit/ui/form/Form.svelte";
  import { cn } from "../kit/utils";
  import { rc } from "./recipes";

  let { class: className, children, ...rest }: ComponentProps<typeof Prim> & { class?: string; children?: Snippet } = $props();
  const cls = $derived(cn(rc("form", {  }), className));
</script>

<Prim class={cls} {...rest}>{@render children?.()}</Prim>

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 form
compose/form.tsx
// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Form as Prim } from "../kit/ui/form/form";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

export type FormProps = Omit<ComponentProps<typeof Prim>, "tag"> & { className?: string };

/** Form: Form + recipe form. */
export function Form({ className, ...rest }: FormProps) {
  return <Prim className={cn(rc("form", {  }), className)} {...rest} />;
}

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 form
compose/Form.vue
<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- Form: Form + recipe form. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/form/Form.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

defineOptions({ name: "Form", inheritAttrs: false });
const props = defineProps<{  }>();
const attrs = useAttrs();
const rest = computed(() => {
  const { class: _class, ...r } = attrs;
  return r;
});
const cls = computed(() => cn(rc("form", {  }), attrs.class as string | undefined));
const tagValue = computed(() => "");
</script>

<template>
  <Prim :class="cls" v-bind="rest"><slot /></Prim>
</template>

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 form
compose/form.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 { Form as Prim } from "../kit/ui/form/form.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";

export type FormProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className"> & { class?: string; className?: string };

/** Form: Form + recipe form. */
export function Form(props: FormProps) {
  const [local, rest] = splitProps(props, ["class", "className"]);
  return <Prim class={cn(rc("form", {  }), local.class ?? local.className)} {...rest} />;
}

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 form
compose/form.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/form"

// FormProps: Form: Form + recipe form.
type FormProps struct {
	form.FormProps
}

func formInner(p FormProps) form.FormProps {
	in := p.FormProps
	in.Class = Join(Rc("form", map[string]string{}), p.FormProps.Class)
	return in
}

// Form renders Form with the composition classes.
templ Form(p FormProps) {
	@form.Form(formInner(p)) {
		{ children... }
	}
}

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 form
compose/Form.html.twig
{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# Form: Form + recipe form. Params: class, attrs + the params of Form. #}
{% include 'ui/form/Form.html.twig' with compose_props('Form', _context) only %}

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 form
compose/Form.latte
{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* Form: Form + recipe form. *}
{parameters
  string $class = '',
  ?string $id = null,
  ?string $name = null,
  ?string $action = null,
  string $method = '',
  ?string $encType = null,
  bool $noValidate = false,
  ?string $autoComplete = null,
  ?string $target = null,
  ?string $ariaLabel = null,
  ?string $ariaLabelledBy = null,
  ?string $ariaDescribedBy = null,
  array $attrs = [],
  string $children = '',
}
{include '../ui/form/Form.latte', ...\CodegenX\Compose\Latte\Compose::props('Form', ['class' => $class, 'id' => $id, 'name' => $name, 'action' => $action, 'method' => $method, 'encType' => $encType, 'noValidate' => $noValidate, 'autoComplete' => $autoComplete, 'target' => $target, 'ariaLabel' => $ariaLabel, 'ariaLabelledBy' => $ariaLabelledBy, 'ariaDescribedBy' => $ariaDescribedBy, 'attrs' => $attrs, 'children' => $children])}

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 form
compose/form.html.j2
{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
    Form: Form + recipe form. Props (p): Class, Attrs + the props of Form. -#}
{%- with p = compose_props('Form', p) %}{% include 'ui/form/form.html.j2' %}{% endwith %}

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.

Form renders a native form element; method is whitelisted (get|post|dialog).

Props of Form
PropTypeDefault Description
method string-HTTP method: get | post | dialog (omitted when empty)
noValidate boolean-skip native constraint validation