Auth Form
Auth Form component
Install
npx ui8kit add auth-formPulls in: auth-card, button, checkbox, compose, field, form, group, input, kit-box, kit-button, kit-checkbox, kit-form, kit-input, kit-label, label, 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 auth-form<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
The form of AuthCard: the fields of the mode (sign-in, sign-up, reset, magic link), remember me and the forgot
link, the terms, the submit button.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { AuthLabels } from "../blocks/auth-card.types";
export type AuthFormProps = {
id: string;
mode?: "signin" | "signup" | "reset" | "magic";
labels: AuthLabels;
submit: string;
};
</script>
<script lang="ts">
import Button from "../compose/Button.svelte";
import Checkbox from "../compose/Checkbox.svelte";
import Form from "../compose/Form.svelte";
import Group from "../compose/Group.svelte";
import Input from "../compose/Input.svelte";
import Label from "../compose/Label.svelte";
import Field from "../components/field.svelte";
import { cn, tpl } from "../utils";
let { id, mode = "signin", labels, submit }: AuthFormProps = $props();
</script>
<Form method="dialog" class="gap-4" data-slot="auth-form">
{#if ((mode as string) === "signup")}
<Field label={labels.name} htmlFor={tpl("{0}-name", id)}>
<Input type="text" name="name" autocomplete="name" id={tpl("{0}-name", id)} data-slot="field" />
</Field>
{/if}
<Field label={labels.email} htmlFor={tpl("{0}-email", id)}>
<Input type="email" name="email" autocomplete="email" id={tpl("{0}-email", id)} data-slot="field" />
</Field>
{#if (((mode as string) !== "reset") && ((mode as string) !== "magic"))}
<Field label={labels.password} htmlFor={tpl("{0}-password", id)}>
<Input
type="password"
name="password"
autocomplete={(((mode as string) === "signup") ? "new-password" : "current-password")}
id={tpl("{0}-password", id)}
data-slot="field"
/>
</Field>
{/if}
{#if ((mode as string) === "signin")}
<Group justify="between" align="center" class="flex-wrap gap-2">
<Group gap="2" align="center" class={cn("w-fit", "")}>
<Checkbox name="remember" id={tpl("{0}-remember", id)} />
<Label for={tpl("{0}-remember", id)} class="text-sm">
{labels.remember}
</Label>
</Group>
<Button variant="link" size="sm" class="px-0">
{labels.forgot}
</Button>
</Group>
{/if}
{#if ((mode as string) === "signup")}
<Group gap="2" align="center" class={cn("w-fit", "")}>
<Checkbox name="terms" id={tpl("{0}-terms", id)} />
<Label for={tpl("{0}-terms", id)} class="text-sm">
{labels.terms}
</Label>
</Group>
{/if}
<Button variant="default" size="default" type="submit" class="w-full">
{submit}
</Button>
</Form>
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 auth-form// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* The form of AuthCard: the fields of the mode (sign-in, sign-up, reset, magic link), remember me and the forgot
* link, the terms, the submit button.
*/
import { type ReactNode } from "react";
import { Button, Checkbox, Form, Group, Input, Label } from "../compose";
import { Field } from "../components/field";
import { cn, tpl } from "../utils";
import type { AuthLabels } from "../blocks/auth-card.types";
export type AuthFormProps = {
id: string;
mode?: "signin" | "signup" | "reset" | "magic";
labels: AuthLabels;
submit: string;
};
export function AuthForm({ id, mode = "signin", labels, submit }: AuthFormProps) {
return (
<Form method="dialog" className="gap-4" data-slot="auth-form">
{((mode as string) === "signup") ? (
<Field label={labels.name} htmlFor={tpl("{0}-name", id)}>
<Input type="text" name="name" autoComplete="name" id={tpl("{0}-name", id)} data-slot="field" />
</Field>
) : null}
<Field label={labels.email} htmlFor={tpl("{0}-email", id)}>
<Input type="email" name="email" autoComplete="email" id={tpl("{0}-email", id)} data-slot="field" />
</Field>
{(((mode as string) !== "reset") && ((mode as string) !== "magic")) ? (
<Field label={labels.password} htmlFor={tpl("{0}-password", id)}>
<Input
type="password"
name="password"
autoComplete={(((mode as string) === "signup") ? "new-password" : "current-password")}
id={tpl("{0}-password", id)}
data-slot="field"
/>
</Field>
) : null}
{((mode as string) === "signin") ? (
<Group justify="between" align="center" className="flex-wrap gap-2">
<Group gap="2" align="center" className={cn("w-fit", "")}>
<Checkbox name="remember" id={tpl("{0}-remember", id)} />
<Label htmlFor={tpl("{0}-remember", id)} className="text-sm">
{labels.remember}
</Label>
</Group>
<Button variant="link" size="sm" className="px-0">
{labels.forgot}
</Button>
</Group>
) : null}
{((mode as string) === "signup") ? (
<Group gap="2" align="center" className={cn("w-fit", "")}>
<Checkbox name="terms" id={tpl("{0}-terms", id)} />
<Label htmlFor={tpl("{0}-terms", id)} className="text-sm">
{labels.terms}
</Label>
</Group>
) : null}
<Button variant="default" size="default" type="submit" className="w-full">
{submit}
</Button>
</Form>
);
}
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 auth-form<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
The form of AuthCard: the fields of the mode (sign-in, sign-up, reset, magic link), remember me and the forgot
link, the terms, the submit button.
-->
<script lang="ts">
import type { AuthLabels } from "../blocks/auth-card.types";
export type AuthFormProps = {
id: string;
mode?: "signin" | "signup" | "reset" | "magic";
labels: AuthLabels;
submit: string;
};
</script>
<script setup lang="ts">
import Button from "../compose/Button.vue";
import Checkbox from "../compose/Checkbox.vue";
import Form from "../compose/Form.vue";
import Group from "../compose/Group.vue";
import Input from "../compose/Input.vue";
import Label from "../compose/Label.vue";
import Field from "../components/field.vue";
import { cn, tpl } from "../utils";
const { id, mode = "signin", labels, submit } = defineProps<AuthFormProps>();
</script>
<template>
<Form method="dialog" class="gap-4" data-slot="auth-form">
<Field v-if="((mode as string) === 'signup')" :label="labels.name" :htmlFor="tpl('{0}-name', id)">
<Input type="text" name="name" autocomplete="name" :id="tpl('{0}-name', id)" data-slot="field" />
</Field>
<Field :label="labels.email" :htmlFor="tpl('{0}-email', id)">
<Input type="email" name="email" autocomplete="email" :id="tpl('{0}-email', id)" data-slot="field" />
</Field>
<Field
v-if="(((mode as string) !== 'reset') && ((mode as string) !== 'magic'))"
:label="labels.password"
:htmlFor="tpl('{0}-password', id)"
>
<Input
type="password"
name="password"
:autocomplete="(((mode as string) === 'signup') ? 'new-password' : 'current-password')"
:id="tpl('{0}-password', id)"
data-slot="field"
/>
</Field>
<Group v-if="((mode as string) === 'signin')" justify="between" align="center" class="flex-wrap gap-2">
<Group gap="2" align="center" :class="cn('w-fit', '')">
<Checkbox name="remember" :id="tpl('{0}-remember', id)" />
<Label :for="tpl('{0}-remember', id)" class="text-sm">
{{ labels.remember }}
</Label>
</Group>
<Button variant="link" size="sm" class="px-0">
{{ labels.forgot }}
</Button>
</Group>
<Group v-if="((mode as string) === 'signup')" gap="2" align="center" :class="cn('w-fit', '')">
<Checkbox name="terms" :id="tpl('{0}-terms', id)" />
<Label :for="tpl('{0}-terms', id)" class="text-sm">
{{ labels.terms }}
</Label>
</Group>
<Button variant="default" size="default" type="submit" class="w-full">
{{ submit }}
</Button>
</Form>
</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 auth-form// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* The form of AuthCard: the fields of the mode (sign-in, sign-up, reset, magic link), remember me and the forgot
* link, the terms, the submit button.
*/
import { For, type JSX } from "solid-js";
import { Button, Checkbox, Form, Group, Input, Label } from "../compose";
import { Field } from "../components/field";
import { cn, tpl } from "../utils";
import type { AuthLabels } from "../blocks/auth-card.types";
export type AuthFormProps = {
id: string;
mode?: "signin" | "signup" | "reset" | "magic";
labels: AuthLabels;
submit: string;
};
export function AuthForm({ id, mode = "signin", labels, submit }: AuthFormProps) {
return (
<Form method="dialog" class="gap-4" data-slot="auth-form">
{((mode as string) === "signup") ? (
<Field label={labels.name} htmlFor={tpl("{0}-name", id)}>
<Input type="text" name="name" autocomplete="name" id={tpl("{0}-name", id)} data-slot="field" />
</Field>
) : null}
<Field label={labels.email} htmlFor={tpl("{0}-email", id)}>
<Input type="email" name="email" autocomplete="email" id={tpl("{0}-email", id)} data-slot="field" />
</Field>
{(((mode as string) !== "reset") && ((mode as string) !== "magic")) ? (
<Field label={labels.password} htmlFor={tpl("{0}-password", id)}>
<Input
type="password"
name="password"
autocomplete={(((mode as string) === "signup") ? "new-password" : "current-password")}
id={tpl("{0}-password", id)}
data-slot="field"
/>
</Field>
) : null}
{((mode as string) === "signin") ? (
<Group justify="between" align="center" class="flex-wrap gap-2">
<Group gap="2" align="center" class={cn("w-fit", "")}>
<Checkbox name="remember" id={tpl("{0}-remember", id)} />
<Label for={tpl("{0}-remember", id)} class="text-sm">
{labels.remember}
</Label>
</Group>
<Button variant="link" size="sm" class="px-0">
{labels.forgot}
</Button>
</Group>
) : null}
{((mode as string) === "signup") ? (
<Group gap="2" align="center" class={cn("w-fit", "")}>
<Checkbox name="terms" id={tpl("{0}-terms", id)} />
<Label for={tpl("{0}-terms", id)} class="text-sm">
{labels.terms}
</Label>
</Group>
) : null}
<Button variant="default" size="default" type="submit" class="w-full">
{submit}
</Button>
</Form>
);
}
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 auth-form// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/organisms/auth-form.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/ui/button"
"github.com/ui8kit/codegen/generated/templ/ui/checkbox"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/ui/form"
"github.com/ui8kit/codegen/generated/templ/ui/input"
"github.com/ui8kit/codegen/generated/templ/ui/label"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// AuthFormProps are the props of AuthForm; the values are the JSON shapes of the TypeScript props.
type AuthFormProps struct {
Id any `json:"id"`
Mode any `json:"mode"`
Labels any `json:"labels"`
Submit any `json:"submit"`
}
// The form of AuthCard: the fields of the mode (sign-in, sign-up, reset, magic link), remember me and the forgot link, the terms, the submit button.
templ AuthForm(p AuthFormProps) {
{{ vId := p.Id }}
{{ vMode := uiutils.Def(p.Mode, "signin") }}
{{ vLabels := p.Labels }}
{{ vSubmit := p.Submit }}
@compose.Form(compose.FormProps{FormProps: form.FormProps{Method: "dialog", Class: "gap-4", Attrs: uiutils.Attrs("data-slot", "auth-form")}}) {
if uiutils.Eq(vMode, "signup") {
@Field(FieldProps{Label: uiutils.Get(vLabels, "name"), HtmlFor: uiutils.Tpl("{0}-name", vId)}) {
@compose.Input(compose.InputProps{InputProps: input.InputProps{Type: "text", Name: "name", Attrs: uiutils.Attrs("autocomplete", "name", "id", uiutils.Tpl("{0}-name", vId), "data-slot", "field")}})
}
}
@Field(FieldProps{Label: uiutils.Get(vLabels, "email"), HtmlFor: uiutils.Tpl("{0}-email", vId)}) {
@compose.Input(compose.InputProps{InputProps: input.InputProps{Type: "email", Name: "email", Attrs: uiutils.Attrs("autocomplete", "email", "id", uiutils.Tpl("{0}-email", vId), "data-slot", "field")}})
}
if uiutils.T(uiutils.And(!uiutils.Eq(vMode, "reset"), !uiutils.Eq(vMode, "magic"))) {
@Field(FieldProps{Label: uiutils.Get(vLabels, "password"), HtmlFor: uiutils.Tpl("{0}-password", vId)}) {
@compose.Input(compose.InputProps{InputProps: input.InputProps{Type: "password", Name: "password", Attrs: uiutils.Attrs("autocomplete", uiutils.Cond(uiutils.T(uiutils.Eq(vMode, "signup")), "new-password", "current-password"), "id", uiutils.Tpl("{0}-password", vId), "data-slot", "field")}})
}
}
if uiutils.Eq(vMode, "signin") {
@compose.Group(compose.GroupProps{Justify: "between", Align: "center", BoxProps: box.BoxProps{Class: "flex-wrap gap-2"}}) {
@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("w-fit", ""))}}) {
@compose.Checkbox(compose.CheckboxProps{CheckboxProps: checkbox.CheckboxProps{Name: "remember", Attrs: uiutils.Attrs("id", uiutils.Tpl("{0}-remember", vId))}})
@compose.Label(compose.LabelProps{LabelProps: label.LabelProps{For: uiutils.S(uiutils.Tpl("{0}-remember", vId)), Class: "text-sm"}}) {
{ uiutils.Text(uiutils.Get(vLabels, "remember")) }
}
}
@compose.Button(compose.ButtonProps{Variant: "link", Size: "sm", ButtonProps: button.ButtonProps{Class: "px-0"}}) {
{ uiutils.Text(uiutils.Get(vLabels, "forgot")) }
}
}
}
if uiutils.Eq(vMode, "signup") {
@compose.Group(compose.GroupProps{Gap: "2", Align: "center", BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("w-fit", ""))}}) {
@compose.Checkbox(compose.CheckboxProps{CheckboxProps: checkbox.CheckboxProps{Name: "terms", Attrs: uiutils.Attrs("id", uiutils.Tpl("{0}-terms", vId))}})
@compose.Label(compose.LabelProps{LabelProps: label.LabelProps{For: uiutils.S(uiutils.Tpl("{0}-terms", vId)), Class: "text-sm"}}) {
{ uiutils.Text(uiutils.Get(vLabels, "terms")) }
}
}
}
@compose.Button(compose.ButtonProps{Variant: "default", Size: "default", ButtonProps: button.ButtonProps{Type: "submit", Class: "w-full"}}) {
{ uiutils.Text(vSubmit) }
}
}
}
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 auth-form{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/auth-form.json
The form of AuthCard: the fields of the mode (sign-in, sign-up, reset, magic link), remember me and the forgot link, the terms, the submit button.
Props (p): id, mode, labels, submit. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_mode = (p.mode ?? 'signin') -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_submit = (p.submit ?? null) -%}
{%- set c_11 -%}
{%- if og_t(og_eq(v_mode, 'signup')) %}
{%- set c_1 -%}
{{ include('compose/Input.html.twig', {'type': 'text', 'name': 'name', 'attrs': og_attrs(['autocomplete', 'name', 'id', og_tpl('{0}-name', [v_id]), 'data-slot', 'field'])}, with_context = false) }}
{%- endset -%}
{{ include('blocks/field.html.twig', {'p': {'label': og_get(v_labels, ['name']), 'htmlFor': og_tpl('{0}-name', [v_id])}, 'children': og_markup(c_1)}, with_context = false) }}
{%- endif %}
{%- set c_2 -%}
{{ include('compose/Input.html.twig', {'type': 'email', 'name': 'email', 'attrs': og_attrs(['autocomplete', 'email', 'id', og_tpl('{0}-email', [v_id]), 'data-slot', 'field'])}, with_context = false) }}
{%- endset -%}
{{ include('blocks/field.html.twig', {'p': {'label': og_get(v_labels, ['email']), 'htmlFor': og_tpl('{0}-email', [v_id])}, 'children': og_markup(c_2)}, with_context = false) }}
{%- if og_t(og_and([not (og_eq(v_mode, 'reset')), not (og_eq(v_mode, 'magic'))])) %}
{%- set c_3 -%}
{{ include('compose/Input.html.twig', {'type': 'password', 'name': 'password', 'attrs': og_attrs(['autocomplete', (og_t(og_eq(v_mode, 'signup')) ? 'new-password' : 'current-password'), 'id', og_tpl('{0}-password', [v_id]), 'data-slot', 'field'])}, with_context = false) }}
{%- endset -%}
{{ include('blocks/field.html.twig', {'p': {'label': og_get(v_labels, ['password']), 'htmlFor': og_tpl('{0}-password', [v_id])}, 'children': og_markup(c_3)}, with_context = false) }}
{%- endif %}
{%- if og_t(og_eq(v_mode, 'signin')) %}
{%- set c_7 -%}
{%- set c_5 -%}
{{ include('compose/Checkbox.html.twig', {'name': 'remember', 'attrs': og_attrs(['id', og_tpl('{0}-remember', [v_id])])}, with_context = false) }}
{%- set c_4 -%}
{{ og_text(og_get(v_labels, ['remember'])) }}
{%- endset -%}
{{ include('compose/Label.html.twig', {'htmlFor': og_s(og_tpl('{0}-remember', [v_id])), 'class': 'text-sm', 'children': c_4}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'align': 'center', 'class': og_s(og_cnv(['w-fit', ''])), 'children': c_5}, with_context = false) }}
{%- set c_6 -%}
{{ og_text(og_get(v_labels, ['forgot'])) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'link', 'size': 'sm', 'class': 'px-0', 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'justify': 'between', 'align': 'center', 'class': 'flex-wrap gap-2', 'children': c_7}, with_context = false) }}
{%- endif %}
{%- if og_t(og_eq(v_mode, 'signup')) %}
{%- set c_9 -%}
{{ include('compose/Checkbox.html.twig', {'name': 'terms', 'attrs': og_attrs(['id', og_tpl('{0}-terms', [v_id])])}, with_context = false) }}
{%- set c_8 -%}
{{ og_text(og_get(v_labels, ['terms'])) }}
{%- endset -%}
{{ include('compose/Label.html.twig', {'htmlFor': og_s(og_tpl('{0}-terms', [v_id])), 'class': 'text-sm', 'children': c_8}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'align': 'center', 'class': og_s(og_cnv(['w-fit', ''])), 'children': c_9}, with_context = false) }}
{%- endif %}
{%- set c_10 -%}
{{ og_text(v_submit) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'default', 'size': 'default', 'type': 'submit', 'class': 'w-full', 'children': c_10}, with_context = false) }}
{%- endset -%}
{{ include('compose/Form.html.twig', {'method': 'dialog', 'class': 'gap-4', 'attrs': og_attrs(['data-slot', 'auth-form']), 'children': c_11}, with_context = false) }}
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 auth-form{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/auth-form.json
The form of AuthCard: the fields of the mode (sign-in, sign-up, reset, magic link), remember me and the forgot link, the terms, the submit button.
Props (p): id, mode, labels, submit. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_mode = ($p['mode'] ?? 'signin')}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_submit = ($p['submit'] ?? null)}
{capture $c_11}
{if og_t(og_eq($v_mode, 'signup'))}
{capture $c_1}
{=og_include('compose/Input.latte', ['type' => 'text', 'name' => 'name', 'attrs' => og_attrs(['autocomplete', 'name', 'id', og_tpl('{0}-name', [$v_id]), 'data-slot', 'field'])])|noescape}
{/capture}
{=og_include('blocks/field.latte', ['p' => ['label' => og_get($v_labels, ['name']), 'htmlFor' => og_tpl('{0}-name', [$v_id])], 'children' => og_markup($c_1)])|noescape}
{/if}
{capture $c_2}
{=og_include('compose/Input.latte', ['type' => 'email', 'name' => 'email', 'attrs' => og_attrs(['autocomplete', 'email', 'id', og_tpl('{0}-email', [$v_id]), 'data-slot', 'field'])])|noescape}
{/capture}
{=og_include('blocks/field.latte', ['p' => ['label' => og_get($v_labels, ['email']), 'htmlFor' => og_tpl('{0}-email', [$v_id])], 'children' => og_markup($c_2)])|noescape}
{if og_t(og_and([!(og_eq($v_mode, 'reset')), !(og_eq($v_mode, 'magic'))]))}
{capture $c_3}
{=og_include('compose/Input.latte', ['type' => 'password', 'name' => 'password', 'attrs' => og_attrs(['autocomplete', (og_t(og_eq($v_mode, 'signup')) ? 'new-password' : 'current-password'), 'id', og_tpl('{0}-password', [$v_id]), 'data-slot', 'field'])])|noescape}
{/capture}
{=og_include('blocks/field.latte', ['p' => ['label' => og_get($v_labels, ['password']), 'htmlFor' => og_tpl('{0}-password', [$v_id])], 'children' => og_markup($c_3)])|noescape}
{/if}
{if og_t(og_eq($v_mode, 'signin'))}
{capture $c_7}
{capture $c_5}
{=og_include('compose/Checkbox.latte', ['name' => 'remember', 'attrs' => og_attrs(['id', og_tpl('{0}-remember', [$v_id])])])|noescape}
{capture $c_4}
{=og_text(og_get($v_labels, ['remember']))}
{/capture}
{=og_include('compose/Label.latte', ['htmlFor' => og_s(og_tpl('{0}-remember', [$v_id])), 'class' => 'text-sm', 'children' => (string) $c_4])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'class' => og_s(og_cnv(['w-fit', ''])), 'children' => (string) $c_5])|noescape}
{capture $c_6}
{=og_text(og_get($v_labels, ['forgot']))}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'link', 'size' => 'sm', 'class' => 'px-0', 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['justify' => 'between', 'align' => 'center', 'class' => 'flex-wrap gap-2', 'children' => (string) $c_7])|noescape}
{/if}
{if og_t(og_eq($v_mode, 'signup'))}
{capture $c_9}
{=og_include('compose/Checkbox.latte', ['name' => 'terms', 'attrs' => og_attrs(['id', og_tpl('{0}-terms', [$v_id])])])|noescape}
{capture $c_8}
{=og_text(og_get($v_labels, ['terms']))}
{/capture}
{=og_include('compose/Label.latte', ['htmlFor' => og_s(og_tpl('{0}-terms', [$v_id])), 'class' => 'text-sm', 'children' => (string) $c_8])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'align' => 'center', 'class' => og_s(og_cnv(['w-fit', ''])), 'children' => (string) $c_9])|noescape}
{/if}
{capture $c_10}
{=og_text($v_submit)}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'default', 'size' => 'default', 'type' => 'submit', 'class' => 'w-full', 'children' => (string) $c_10])|noescape}
{/capture}
{=og_include('compose/Form.latte', ['method' => 'dialog', 'class' => 'gap-4', 'attrs' => og_attrs(['data-slot', 'auth-form']), 'children' => (string) $c_11])|noescape}
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 auth-form{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/auth-form.json
The form of AuthCard: the fields of the mode (sign-in, sign-up, reset, magic link), remember me and the forgot link, the terms, the submit button.
Props (p): id, mode, labels, submit. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_mode = og_def(p['mode'], 'signin') -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_submit = og_def(p['submit'], none) -%}
{%- set c_11 -%}
{%- if og_t(og_eq(v_mode, 'signup')) %}
{%- set c_1 -%}
{{ og_include('compose/input.html.j2', {'p': {'Type': 'text', 'Name': 'name', 'Attrs': og_attrs(['autocomplete', 'name', 'id', og_tpl('{0}-name', [v_id]), 'data-slot', 'field'])}}) }}
{%- endset -%}
{{ og_include('blocks/field.html.j2', {'p': {'label': og_get(v_labels, ['name']), 'htmlFor': og_tpl('{0}-name', [v_id])}, 'children': og_markup(c_1)}) }}
{%- endif %}
{%- set c_2 -%}
{{ og_include('compose/input.html.j2', {'p': {'Type': 'email', 'Name': 'email', 'Attrs': og_attrs(['autocomplete', 'email', 'id', og_tpl('{0}-email', [v_id]), 'data-slot', 'field'])}}) }}
{%- endset -%}
{{ og_include('blocks/field.html.j2', {'p': {'label': og_get(v_labels, ['email']), 'htmlFor': og_tpl('{0}-email', [v_id])}, 'children': og_markup(c_2)}) }}
{%- if og_t(og_and([not (og_eq(v_mode, 'reset')), not (og_eq(v_mode, 'magic'))])) %}
{%- set c_3 -%}
{{ og_include('compose/input.html.j2', {'p': {'Type': 'password', 'Name': 'password', 'Attrs': og_attrs(['autocomplete', ('new-password' if og_t(og_eq(v_mode, 'signup')) else 'current-password'), 'id', og_tpl('{0}-password', [v_id]), 'data-slot', 'field'])}}) }}
{%- endset -%}
{{ og_include('blocks/field.html.j2', {'p': {'label': og_get(v_labels, ['password']), 'htmlFor': og_tpl('{0}-password', [v_id])}, 'children': og_markup(c_3)}) }}
{%- endif %}
{%- if og_t(og_eq(v_mode, 'signin')) %}
{%- set c_7 -%}
{%- set c_5 -%}
{{ og_include('compose/checkbox.html.j2', {'p': {'Name': 'remember', 'Attrs': og_attrs(['id', og_tpl('{0}-remember', [v_id])])}}) }}
{%- set c_4 -%}
{{ og_text(og_get(v_labels, ['remember'])) }}
{%- endset -%}
{{ og_include('compose/label.html.j2', {'p': {'For': og_s(og_tpl('{0}-remember', [v_id])), 'Class': 'text-sm'}, 'children': c_4}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'center', 'Class': og_s(og_cnv(['w-fit', '']))}, 'children': c_5}) }}
{%- set c_6 -%}
{{ og_text(og_get(v_labels, ['forgot'])) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'link', 'Size': 'sm', 'Class': 'px-0'}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Justify': 'between', 'Align': 'center', 'Class': 'flex-wrap gap-2'}, 'children': c_7}) }}
{%- endif %}
{%- if og_t(og_eq(v_mode, 'signup')) %}
{%- set c_9 -%}
{{ og_include('compose/checkbox.html.j2', {'p': {'Name': 'terms', 'Attrs': og_attrs(['id', og_tpl('{0}-terms', [v_id])])}}) }}
{%- set c_8 -%}
{{ og_text(og_get(v_labels, ['terms'])) }}
{%- endset -%}
{{ og_include('compose/label.html.j2', {'p': {'For': og_s(og_tpl('{0}-terms', [v_id])), 'Class': 'text-sm'}, 'children': c_8}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Align': 'center', 'Class': og_s(og_cnv(['w-fit', '']))}, 'children': c_9}) }}
{%- endif %}
{%- set c_10 -%}
{{ og_text(v_submit) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'default', 'Size': 'default', 'Type': 'submit', 'Class': 'w-full'}, 'children': c_10}) }}
{%- endset -%}
{{ og_include('compose/form.html.j2', {'p': {'Method': 'dialog', 'Class': 'gap-4', 'Attrs': og_attrs(['data-slot', 'auth-form'])}, 'children': c_11}) }}
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.
The form of AuthCard: the fields of the mode (sign-in, sign-up, reset, magic link), remember me and the forgot link, the terms, the submit button.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | the id of the card: field ids are <id>-email, <id>-password, ... |
| mode | "signin" | "signup" | "reset" | "magic" | "signin" | |
| labels (required) | AuthLabels | - | |
| submit (required) | string | - | text of the submit button |