On this page
@addTagHelper *, Webority.Ui.RazorBasic
Pass one row per entry, numbered, so a validation message can say which row is wrong.
Handling the post
Both controls are buttons with a namespaced name, derived from the repeater's name attribute; webority-ui.js posts the form with it, so the page must load that script. Set it to the collection name and the handler reads like the model.
Minimum and maximum
Set min and max to keep the row count in range; remove hides at min and add disables at max.
Empty state
Give an empty repeater a message, so the lone add button does not read as broken.
Per-row labels
Label each row with its role or category, shown in the header band beside its number.
With react-hook-form
React-only concept: react-hook-form's useFieldArray is the intended pairing for the React AppRepeater. The Razor tag helper has no client-side form library; the equivalent is ASP.NET Core model binding with indexed row names, which every example on this page already uses.
Custom row rendering
Put any markup in a row, such as a searchable select beside a number field.
Every option
Every value of every prop, one cell each.
rows
rows: one app-repeater-row per entry
renderRow
renderRow: the markup inside each app-repeater-row draws the fields
rowLabel
app-repeater-row label="…": the header band text of one row
onAdd
add button: posts {name}.add, and the page appends a row
onRemove
remove button: posts {name}.remove, and the page removes the row
min / max
min="0" (default): can remove down to zero
min="1": last row's remove control hidden
max="2": at max, add button disabled
max="0" (default): add button never disables
emptyText
empty-text set, no rows
empty-text unset, no rows: a lone Add button
addLabel
add-label="Add line item"
addVariant
add-variant="soft" (default)
add-variant="solid"
add-variant="outline"
add-variant="ghost"
add-variant="glass"
add-variant="link"
removeLabel
remove-label="Remove line item": the accessible name of each remove control
numbered
numbered="true" (default)
numbered="false"
className
class: extra classes on the repeater
name
name="NameA": namespaces the add and remove keys
add-form-action
add-form-action: where the add button posts; omit it to post to the form's own action
Guidance
What to do, and what to avoid.
Use it when
- A form needs one or more of the same group of fields.
- The count is decided by the user, not the schema.
- Each entry has more than one field: a name and an email, a description and an amount.
Reach for something else when
- The user is picking from a known list of options. → AppSelect mode="multiple"
- It is a single repeated value, like a list of tags. → AppSelect mode="tag"
- The rows are existing records to manage. → AppDataTable
- The count is fixed by the schema. → plain fields
Name the actions and number rows
Specific add and remove labels ("Add contact"), a minimum so the form cannot reach an unsubmittable state, and numbered rows validation can point at.
A generic "Add another", no remove control at all, and no numbering, so "Row 2 email is invalid" has nothing to point at.
Reference
Try every prop, read the full list, and check keyboard and screen reader behaviour.
10 props. The 4 most used come first.
Used on most screens 4 props
| Prop | Type | Default | Description |
|---|---|---|---|
| add-labeldefault Add another | string | Add another | Text of the add button. |
| remove-labeldefault Remove row | string | Remove row | Accessible name of each remove control. The row number is added, as in "Remove row 2". |
| empty-textdefault - | string | - | Shown in place of the rows when there are none. |
| mindefault 0 | int | 0 | Rows at or below this count cannot be removed. |
Less common 6 props
| Prop | Type | Default | Description |
|---|---|---|---|
| namedefault repeater | string | repeater | Namespaces the add and remove buttons. Set it to the collection name so two repeaters on a page cannot collide. |
| add-variantdefault soft | ghost | glass | link | outline | soft | solid | soft | The add control's variant: an AppButton variant such as solid, outline or ghost, or link for a small text link with a plus icon. An unknown value warns in development. |
| maxdefault 0 | int | 0 | Adding is disabled at this count. |
| numbereddefault true | bool | true | Show the row index. |
| add-form-actiondefault - | string | - | Where the add button posts. Omit to post to the form's own action. |
| labeldefault - | string | - | Set on an app-repeater-row. The label sits in the row's top-left header band. Omit it to leave the row unlabelled. |
Screen reader
2 notes- Each remove control is an icon button named by removeLabel and the row number, such as "Remove contact 2".
- The add button shows its addLabel as visible text and is disabled once max rows exist.
Do and avoid
1 pairsName the actions and number rows
Specific add and remove labels ("Add contact"), a minimum so the form cannot reach an unsubmittable state, and numbered rows validation can point at.
A generic "Add another", no remove control at all, and no numbering, so "Row 2 email is invalid" has nothing to point at.