x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<div class="tw:p-6 tw:max-w-7xl tw:mx-auto tw:space-y-8">
<!-- Introductory callout -->
<div class="tw-callout">
<p class="tw:mb-1 tw:text-sm tw:font-mono">
<strong>TAG INPUT:</strong> Interactive tag container for multi-value form inputs<br>
<strong>COMPOSES:</strong> Tag (.tag, .tag-close) | Form Controls (visual alignment)
</p>
<p class="tw:mb-0 tw:text-sm">
A form-field-like wrapper that holds removable tags with an inline text input. Used for multi-select inputs, filter builders, and any UI where users manage a list of values. Visually aligns with <code>.form-control</code> (same border, radius, focus ring).
</p>
</div>
<!-- ============================================
Section 1: Basic Tag Input
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Basic Tag Input</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Pre-populated:</strong> Tags are already inside the container. Click the container to focus the input. Type text and press Enter to add a tag. Press Backspace on an empty input to remove the last tag.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag" data-tag-input-target="tag" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag" data-tag-input-target="tag" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add a tag..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div class="tw:mt-4 tw:text-sm tw:text-gray-600">
<code><div class="tw-tag-input" data-controller="tag-input">...</div></code>
</div>
</div>
<!-- ============================================
Section 2: Empty with Placeholder
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Empty with Placeholder</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Empty state:</strong> When no tags are present, the placeholder text guides the user. Type a value and press Enter to add the first tag.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<input class="tw-tag-input-field" type="text" placeholder="Type and press Enter..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
</div>
<!-- ============================================
Section 3: With Colored Tags
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">With Colored Tags</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Variant value:</strong> Set <code>data-tag-input-variant-value</code> to apply a color variant to dynamically added tags. Pre-populated tags can use any variant class.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input" data-controller="tag-input"
data-tag-input-variant-value="tw-tag-primary-subtle"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag tw-tag-primary-subtle" data-tag-input-target="tag" data-value="Year 7">
Year 7
<button class="tw-tag-close" type="button" aria-label="Remove Year 7"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag tw-tag-primary-subtle" data-tag-input-target="tag" data-value="Year 8">
Year 8
<button class="tw-tag-close" type="button" aria-label="Remove Year 8"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add year group..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add year group">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
</div>
<!-- ============================================
Section 4: Sizes
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Sizes</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Size variants:</strong> <code>.tag-input-sm</code> for compact forms, default for standard use, <code>.tag-input-lg</code> for prominent inputs.
</p>
</div>
<div class="tw:max-w-md tw:space-y-4">
<div>
<p class="tw:text-body-xs tw:text-neutral-600 tw:mb-2">Small</p>
<div class="tw-tag-input tw-tag-input-sm" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag tw-tag-sm" data-tag-input-target="tag" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag tw-tag-sm" data-tag-input-target="tag" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div>
<p class="tw:text-body-xs tw:text-neutral-600 tw:mb-2">Default</p>
<div class="tw-tag-input" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag" data-tag-input-target="tag" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag" data-tag-input-target="tag" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div>
<p class="tw:text-body-xs tw:text-neutral-600 tw:mb-2">Large</p>
<div class="tw-tag-input tw-tag-input-lg" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag tw-tag-lg" data-tag-input-target="tag" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag tw-tag-lg" data-tag-input-target="tag" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
</div>
<div class="tw:mt-4 tw:text-sm tw:text-gray-600">
<code><div class="tw-tag-input tw-tag-input-sm">...</div></code>  
<code><div class="tw-tag-input tw-tag-input-lg">...</div></code>
</div>
</div>
<!-- ============================================
Section 5: Validation States
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Validation States</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Validation:</strong> Add <code>.is-valid</code> or <code>.is-invalid</code> to show green or red border and focus ring. Pair with form-group helper text for error messages.
</p>
</div>
<div class="tw:max-w-md tw:space-y-4">
<div>
<label class="tw-form-label">Valid</label>
<div class="tw-tag-input tw-is-valid" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag" data-tag-input-target="tag" data-value="Year 7">
Year 7
<button class="tw-tag-close" type="button" aria-label="Remove Year 7"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add year group">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
<p class="tw-valid-feedback">Year group selection confirmed.</p>
</div>
<div>
<label class="tw-form-label">Invalid</label>
<div class="tw-tag-input tw-is-invalid" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<input class="tw-tag-input-field" type="text" placeholder="Select at least one..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add year group">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
<p class="tw-invalid-feedback">Please select at least one year group.</p>
</div>
</div>
</div>
<!-- ============================================
Section 6: Disabled State
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Disabled State</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Disabled:</strong> Add <code>.tag-input-disabled</code> to gray out the container and prevent all interaction. Tags inside become non-interactive automatically.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input tw-tag-input-disabled">
<div class="tw-tag-input-tags">
<span class="tw-tag tw-tag-disabled" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples" disabled>
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag tw-tag-disabled" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges" disabled>
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add a tag..." disabled
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div class="tw:mt-4 tw:text-sm tw:text-gray-600">
<code><div class="tw-tag-input tw-tag-input-disabled">...</div></code>
</div>
</div>
<!-- ============================================
Section 7: Max Tags Limit
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Max Tags Limit</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Max tags:</strong> Set <code>data-tag-input-max-tags-value</code> to limit the number of tags. Once the limit is reached, new entries are silently ignored. This example allows a maximum of 3 tags.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input" data-controller="tag-input"
data-tag-input-max-tags-value="3"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag" data-tag-input-target="tag" data-value="Maths">
Maths
<button class="tw-tag-close" type="button" aria-label="Remove Maths"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag" data-tag-input-target="tag" data-value="English">
English
<button class="tw-tag-close" type="button" aria-label="Remove English"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add subject (max 3)..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add subject">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div class="tw:mt-4 tw:text-sm tw:text-gray-600">
<code>data-tag-input-max-tags-value="3"</code>
</div>
</div>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<div class="tw:p-6 tw:max-w-7xl tw:mx-auto tw:space-y-8">
<!-- Introductory callout -->
<div class="tw-callout">
<p class="tw:mb-1 tw:text-sm tw:font-mono">
<strong>TAG INPUT:</strong> Interactive tag container for multi-value form inputs<br>
<strong>COMPOSES:</strong> Tag (.tag, .tag-close) | Form Controls (visual alignment)
</p>
<p class="tw:mb-0 tw:text-sm">
A form-field-like wrapper that holds removable tags with an inline text input. Used for multi-select inputs, filter builders, and any UI where users manage a list of values. Visually aligns with <code>.form-control</code> (same border, radius, focus ring).
</p>
</div>
<!-- ============================================
Section 1: Basic Tag Input
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Basic Tag Input</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Pre-populated:</strong> Tags are already inside the container. Click the container to focus the input. Type text and press Enter to add a tag. Press Backspace on an empty input to remove the last tag.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag" data-tag-input-target="tag" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag" data-tag-input-target="tag" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add a tag..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div class="tw:mt-4 tw:text-sm tw:text-gray-600">
<code><div class="tw-tag-input" data-controller="tag-input">...</div></code>
</div>
</div>
<!-- ============================================
Section 2: Empty with Placeholder
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Empty with Placeholder</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Empty state:</strong> When no tags are present, the placeholder text guides the user. Type a value and press Enter to add the first tag.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<input class="tw-tag-input-field" type="text" placeholder="Type and press Enter..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
</div>
<!-- ============================================
Section 3: With Colored Tags
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">With Colored Tags</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Variant value:</strong> Set <code>data-tag-input-variant-value</code> to apply a color variant to dynamically added tags. Pre-populated tags can use any variant class.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input" data-controller="tag-input"
data-tag-input-variant-value="tw-tag-primary-subtle"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag tw-tag-primary-subtle" data-tag-input-target="tag" data-value="Year 7">
Year 7
<button class="tw-tag-close" type="button" aria-label="Remove Year 7"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag tw-tag-primary-subtle" data-tag-input-target="tag" data-value="Year 8">
Year 8
<button class="tw-tag-close" type="button" aria-label="Remove Year 8"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add year group..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add year group">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
</div>
<!-- ============================================
Section 4: Sizes
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Sizes</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Size variants:</strong> <code>.tag-input-sm</code> for compact forms, default for standard use, <code>.tag-input-lg</code> for prominent inputs.
</p>
</div>
<div class="tw:max-w-md tw:space-y-4">
<div>
<p class="tw:text-body-xs tw:text-neutral-600 tw:mb-2">Small</p>
<div class="tw-tag-input tw-tag-input-sm" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag tw-tag-sm" data-tag-input-target="tag" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag tw-tag-sm" data-tag-input-target="tag" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div>
<p class="tw:text-body-xs tw:text-neutral-600 tw:mb-2">Default</p>
<div class="tw-tag-input" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag" data-tag-input-target="tag" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag" data-tag-input-target="tag" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div>
<p class="tw:text-body-xs tw:text-neutral-600 tw:mb-2">Large</p>
<div class="tw-tag-input tw-tag-input-lg" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag tw-tag-lg" data-tag-input-target="tag" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag tw-tag-lg" data-tag-input-target="tag" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
</div>
<div class="tw:mt-4 tw:text-sm tw:text-gray-600">
<code><div class="tw-tag-input tw-tag-input-sm">...</div></code>  
<code><div class="tw-tag-input tw-tag-input-lg">...</div></code>
</div>
</div>
<!-- ============================================
Section 5: Validation States
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Validation States</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Validation:</strong> Add <code>.is-valid</code> or <code>.is-invalid</code> to show green or red border and focus ring. Pair with form-group helper text for error messages.
</p>
</div>
<div class="tw:max-w-md tw:space-y-4">
<div>
<label class="tw-form-label">Valid</label>
<div class="tw-tag-input tw-is-valid" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag" data-tag-input-target="tag" data-value="Year 7">
Year 7
<button class="tw-tag-close" type="button" aria-label="Remove Year 7"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add year group">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
<p class="tw-valid-feedback">Year group selection confirmed.</p>
</div>
<div>
<label class="tw-form-label">Invalid</label>
<div class="tw-tag-input tw-is-invalid" data-controller="tag-input"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<input class="tw-tag-input-field" type="text" placeholder="Select at least one..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add year group">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
<p class="tw-invalid-feedback">Please select at least one year group.</p>
</div>
</div>
</div>
<!-- ============================================
Section 6: Disabled State
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Disabled State</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Disabled:</strong> Add <code>.tag-input-disabled</code> to gray out the container and prevent all interaction. Tags inside become non-interactive automatically.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input tw-tag-input-disabled">
<div class="tw-tag-input-tags">
<span class="tw-tag tw-tag-disabled" data-value="Apples">
Apples
<button class="tw-tag-close" type="button" aria-label="Remove Apples" disabled>
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag tw-tag-disabled" data-value="Oranges">
Oranges
<button class="tw-tag-close" type="button" aria-label="Remove Oranges" disabled>
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add a tag..." disabled
aria-label="Add a tag">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div class="tw:mt-4 tw:text-sm tw:text-gray-600">
<code><div class="tw-tag-input tw-tag-input-disabled">...</div></code>
</div>
</div>
<!-- ============================================
Section 7: Max Tags Limit
============================================ -->
<div class="tw:border-t tw:pt-6">
<h2 class="tw-h4 tw:mb-4">Max Tags Limit</h2>
<div class="tw-callout tw:mb-4">
<p class="tw:mb-0 tw:text-sm">
<strong>Max tags:</strong> Set <code>data-tag-input-max-tags-value</code> to limit the number of tags. Once the limit is reached, new entries are silently ignored. This example allows a maximum of 3 tags.
</p>
</div>
<div class="tw:max-w-md">
<div class="tw-tag-input" data-controller="tag-input"
data-tag-input-max-tags-value="3"
data-action="click->tag-input#focus">
<div class="tw-tag-input-tags">
<span class="tw-tag" data-tag-input-target="tag" data-value="Maths">
Maths
<button class="tw-tag-close" type="button" aria-label="Remove Maths"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<span class="tw-tag" data-tag-input-target="tag" data-value="English">
English
<button class="tw-tag-close" type="button" aria-label="Remove English"
data-action="click->tag-input#removeTag">
<i class="fa-solid fa-xmark"></i>
</button>
</span>
<input class="tw-tag-input-field" type="text" placeholder="Add subject (max 3)..."
data-tag-input-target="input"
data-action="keydown->tag-input#keydown"
aria-label="Add subject">
</div>
<div class="tw-tag-input-chevron">
<i class="fa-solid fa-chevron-down"></i>
</div>
</div>
</div>
<div class="tw:mt-4 tw:text-sm tw:text-gray-600">
<code>data-tag-input-max-tags-value="3"</code>
</div>
</div>
</div>