2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ChakraUI version 3.5.1 Fieldset(Form機能)を使って、送信する方法

Last updated at Posted at 2025-02-02

はじめに

ドキュメントに、Fieldset(Form機能)を使って、送信する方法がなかったので記載します。
(ChakraUI version 3.5.1 )

問題

はじめにの通りです。

ChakraUI version 3.5.1
Fieldset ドキュメント
https://www.chakra-ui.com/docs/components/fieldset

解決方法

Register.tsx
const handleSubmit = (e: React.FormEvent) => {
    e.preventDefault();
    // 登録処理を実装
    console.log("User registered:", formData);
};

  return (

    <form onSubmit={handleSubmit}>  {/* 追加 */}
        <Fieldset.Root size="lg" maxW="md">
            <Stack>
                <Fieldset.Legend>xx新規登録</Fieldset.Legend>
            </Stack>

            <Fieldset.Content>
                <Field label="好きな英単語 *">
                        <Input type="text" name="id" value={formData.id} onChange={handleChange} />
                </Field>

    ~~省略~~
    
    </form>
    

おわりに

ドキュメントは、基本的なことしか書いていないので、実装するには書き方を調べる必要があります。

参考

ChakraUI version 3.5.1
Fieldset ドキュメント
https://www.chakra-ui.com/docs/components/fieldset

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?