テキスト

テキストフィールド

短い1行のテキスト入力用フィールドです。タイトル、スラッグ、著者名など、短い文字列に適しています。

基本例

{
	"name": "title",
	"type": "text",
	"label": "タイトル",
	"required": true
}

プロパティ

プロパティ必須説明
namestringYesフィールドの識別子
type"text"Yes"text"を指定
labelstringNoCMS上での表示名
notestringNo編集者向けの補足メモ
requiredbooleanNo必須フィールドかどうか
defaultstringNoデフォルト値
minLengthnumberNo最小文字数
maxLengthnumberNo最大文字数
patternstringNo正規表現パターン(バリデーション用)

使用例

タイトル

{
	"name": "title",
	"type": "text",
	"label": "タイトル",
	"required": true,
	"maxLength": 100
}

スラッグ(URL用)

{
	"name": "slug",
	"type": "text",
	"label": "スラッグ",
	"required": true,
	"pattern": "^[a-z0-9-]+$",
	"note": "半角英数字とハイフンのみ使用できます"
}

メールアドレス

{
	"name": "email",
	"type": "text",
	"label": "メールアドレス",
	"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
}

デフォルト値

{
	"name": "status",
	"type": "text",
	"label": "ステータス",
	"default": "draft"
}

バリデーション

minLength / maxLength

文字数の制限を設定します。

{
	"name": "summary",
	"type": "text",
	"label": "要約",
	"minLength": 10,
	"maxLength": 200,
	"note": "10〜200文字で入力してください"
}

pattern

正規表現でフォーマットを制限します。

{
	"name": "phone",
	"type": "text",
	"label": "電話番号",
	"pattern": "^[0-9]{2,4}-[0-9]{2,4}-[0-9]{4}$",
	"note": "例: 03-1234-5678"
}

テキストエリアとの違い

フィールド用途UI
text短いテキスト1行の入力欄
textarea長いテキスト複数行のテキストエリア

タイトルや名前など短い文字列にはtext、説明文や本文にはtextareaまたはrichtextを使用してください。