0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JetCompose TextFieldをコピペで使う

Posted at

テキストフィールドってどうやって記載するんだっけ?って時に

コピペで使えるシリーズの記事を書いてみようかと、思ったので投稿しました。

まず、画像を確認して、下にコードがあるのでコピペ

スクリーンショット 2025-05-15 12.00.30.png

@Composable
fun TextFieldExample() {
    var text by remember { mutableStateOf("") }

    TextField(
        value = text,
        onValueChange = { newText ->
            text = newText
        },
        label = { Text("メールアドレス") }, // フローティングラベル
        placeholder = { Text("例: example@example.com") }, // プレースホルダー
        leadingIcon = { // 先頭のアイコン
            Icon(Icons.Filled.Email, contentDescription = "メールアイコン")
        },
        modifier = Modifier.padding(16.dp)
    )
}
@Composable
fun OutlinedTextFieldExample() {
    var text by remember { mutableStateOf("") }

    OutlinedTextField(
        value = text,
        onValueChange = { newText ->
            text = newText
        },
        label = { Text("パスワード") }, // フローティングラベル
        trailingIcon = { // 末尾のアイコン (例: パスワード表示切り替えアイコンなど)
            // ここにアイコンを追加
        },
        modifier = Modifier.padding(16.dp)
    )
}

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?