mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
* fix(form): use native as default validation behavior * docs(form): delete explicit validationBehavior=native * test(form): adjusted form test validation behaviors * chore(form): adjusted stories with forms * chore(changeset): changed form default validation behavior to native * chore(changeset): removed packages with only test changes * chore(changeset): change to patch * chore(changeset): update package name * refactor(docs): update package name * refactor(docs): update to heroui --------- Co-authored-by: աӄա <wingkwong.code@gmail.com>
31 lines
737 B
JavaScript
31 lines
737 B
JavaScript
import {Form, Input, Button} from "@heroui-org/react";
|
|
|
|
export default function App() {
|
|
const onSubmit = (e) => {
|
|
e.preventDefault();
|
|
};
|
|
|
|
return (
|
|
<Form className="w-full max-w-xs" validationBehavior="aria" onSubmit={onSubmit}>
|
|
<Input
|
|
isRequired
|
|
label="Username"
|
|
labelPlacement="outside"
|
|
name="username"
|
|
placeholder="Enter your username"
|
|
type="text"
|
|
validate={(value) => {
|
|
if (value.length < 3) {
|
|
return "Username must be at least 3 characters long";
|
|
}
|
|
|
|
return value === "admin" ? "Nice try!" : null;
|
|
}}
|
|
/>
|
|
<Button type="submit" variant="bordered">
|
|
Submit
|
|
</Button>
|
|
</Form>
|
|
);
|
|
}
|