grasscnGitHub

Form

A copyable player/world form block with validation and reset.

Preview

Player and world settings

CJK names are welcome.

Keep a note for your next visit.

Save an empty form to try validation.
Loading example...
To run this copied example, install these items using the linked CLI or manual instructions:

Usage

Install the form item and import its actual FormExample export from @/components/form. This is a registry block, not a library of Form, FormField or FormProvider primitives. The primary example runs that block, including its real validation, disabled state, save result and reset action.

Composition

The block composes React Hook Form Controller, zodResolver, Zod, Field, Input, Textarea and Button. Keep Controller's value/onChange/ref on the input, connect error IDs with aria-describedby and set aria-invalid explicitly. It uses noValidate so the schema owns validation.

API and accessibility

The schema requires a player name of at least two characters and a world name; notes are a string. FieldSet and the actual controls are both disabled. Reset uses form.reset. scale defaults to 2. Field layout, validation and save feedback are web adaptations, not a native Minecraft form screen. Manual installation includes the block and its complete helpers/resources; dependencies include react-hook-form, @hookform/resolvers and zod.

See the underlying API for shared semantics.

Validation composition

Loading example...
To run this copied example, install these items using the linked CLI or manual instructions:

Installation

Loading registry address

Component source

This is the component implementation. Its supporting styles, helpers and resources are also required. See complete manual installation.

Component implementationcomponents/form.tsx · tsx
"use client";

import { zodResolver } from "@hookform/resolvers/zod";
import * as React from "react";
import type { CSSProperties as IntrinsicLayoutCSSProperties } from "react";
import { Controller, useForm } from "react-hook-form";
import { z } from "zod";

import { Button } from "@/components/ui/button";
import {
  Field,
  FieldContent,

Interactive playground

Player and world settings

CJK names are welcome.

Keep a note for your next visit.

Save an empty form to try validation.