Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

The stored value

Save the stored value as it is, and notify the people it mentions, each once.

Post and read it back
Show code
public void OnPost(string body)
{
    IReadOnlyList<string> notify = MentionText.Ids(body);
    string preview = MentionText.Plain(body);
}

Looking people up

Look people up as the person types, instead of loading the full list up front.

Lookup as you type
Show code
<app-mention-input name="note" label="Comment" people-source="/Components/AppMentionInput?handler=People" />

public async Task<IActionResult> OnGetPeopleAsync(string q) => this.MentionPeople(FindPeople(q));

Every option

Every value of every prop, one cell each.

value

value="Thanks @[Asha Rao](u-12), can you check the totals?"

onChange

onChange (React only): Razor reads the posted value on submit

people

people="@AppMentionInputModel.Team"

loadPeople

people-source="/Components/AppMentionInput?handler=People"

minChars

min-chars="3"

debounce

debounce="1000"

onSubmit

onSubmit (React only): Razor sends the form with its submit button

rows

rows="6"

placeholder

placeholder="Type @ to mention someone"

disabled

disabled="true"
disabled="false" (default)

readOnly

read-only="true"
read-only="false" (default)

loading

loading="true"
loading="false" (default)

size

size="sm"
size="md" (default)
size="lg"

defaultValue

defaultValue (React only): Razor sets the starting text with value

name

name: posts the stored value under this name in a form

id

id: the element id, and the text box is that id plus -text

label

label="Reply"

error

error="Choose someone to mention."
Choose someone to mention.

helperText

helper-text="Pick someone from the list as you type."
Pick someone from the list as you type.

required

required="true"
required="false" (default)

help

help="Mentions notify the person."

helpLabel

help-label: names the info tip for screen readers, no visual change

className

input-class: extra classes on the text box itself

fieldClassName

class: extra classes on the field wrapper

Guidance

What to do, and what to avoid.

Use it when

  • A comment, note or message that should reach named people.
  • Any text a server reads to notify someone.

Reach for something else when

  • Choosing people as a field value. → AppSelect mode="multiple"
  • Formatted text with headings and lists. → AppRichText

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

people: four people: none people-source: lookup
default sm md lg
React, generated from the controls
<AppMentionInput label="Comment" people={people} placeholder="Type @ to mention someone" onChange={(value, { mentions }) => …} />
Razor, the same props
<app-mention-input name="body" label="Comment" people="@Model.People" placeholder="Type @ to mention someone" />

19 props. The 5 most used come first.

Used on most screens 5 props

PropTypeDefaultDescription
labeldefault - string - Shown above the box; also its accessible name.
placeholderdefault - string - Placeholder text shown while the box is empty.
rowsdefault 3 int 3 The number of visible lines.
peopledefault - IEnumerable<MentionPerson> - The people the list offers; Value is the person's public id.
errordefault - string - An error message shown under the box.

Less common 14 props

PropTypeDefaultDescription
namedefault - string - Posts the stored value under this name in a form.
valuedefault - string - The stored value, plain text with each mention written as @[Asha Rao](u-12).
disableddefault false bool false Turns the box off.
read-onlydefault false bool false Shows the value but blocks editing. The value still posts.
loadingdefault false bool false Shows a busy state and blocks input while data loads.
sizedefault md sm | md | lg md The control size: sm, md or lg.
people-sourcedefault - string - An address that answers people as the person types (GET with q).
min-charsdefault 1 int 1 How many letters after @ before the lookup runs.
debouncedefault 250 int 250 Milliseconds to wait for typing to pause before the lookup runs.
helper-textdefault - string - Helper text shown under the box when there is no error.
requireddefault false bool false Marks the field as required.
helpdefault - string - Help in an info tip beside the label.
help-labeldefault More information string More information The accessible name of that info tip.
input-classdefault - string - Extra classes on the text box itself (the control). The plain class attribute merges onto the field wrapper instead.

Screen reader

3 notes
  • The label points at the text box, whose id is the element id plus -text, so the label names it.
  • The helper text or the error is tied to the box with aria-describedby, and an error also marks the box aria-invalid.
  • In the list, Up and Down choose, Enter or Tab mention and Escape closes it. Backspace just after a mention removes it whole.