Invite Row
FreeAn email field and a role select for inviting one person, with an optional button that removes the row. The row is controlled, so you keep the email and the role.
npx wunderui-cli add invite-rowPlayground
Installation
npx wunderui-cli add invite-rowWrites the source into your project with its dependencies and, on first use, the styles - see Installation.
Then import what you need:
import { InviteRow } from "@/components/blocks/auth"
import type { InviteRowProps } from "@/components/blocks/auth"Then use it:
import { useState } from "react"
import { InviteRow } from "@wunderui/react"
export function Invite() {
const [email, setEmail] = useState("daniel.okafor@wunderui.com")
const [role, setRole] = useState("Editor")
return <InviteRow email={email} role={role} onEmailChange={setEmail} onRoleChange={setRole} />
}Expected result: You see an email field and a role select showing Editor, side by side on a wide screen. Typing and picking change them.
When to use
Use Invite Row for
- A list of people to invite, one email and one role per row
- A row that can be removed from the list
- A role chosen from a short list
Use something else for
- Input Group for one shareable link with a copy button
- Field for a single labelled input with its own error message
- Select for a role or option picker on its own
- Settings Row for a setting with a title, a description and a control
Layout
The email and role sit side by side from the small breakpoint up, and one over the other below it. The stacked option stacks them at every width, for a narrow dialog or side panel.
Remove
The remove button is drawn only when you pass a remove handler, so the first row of a list can have none.
Roles
The role select lists Admin, Editor and Viewer by default. Pass your own list and the selected value.
Content
An empty address shows the placeholder, and a long address scrolls inside the field with no ellipsis. The row has no error state, so validate in your handler and write the message under the row.
Enter a valid email address.
Keyboard interactions
A row has up to three tab stops, in this order: the email field, the role select, the remove button. The remove button exists only with a remove handler.
- TaborShift+Tab
- Moves focus between the email field, the role select and the remove button, then on to the next row.
- EnterorSpaceorArrowDown
- On the role select: opens the list.
- ArrowUporArrowDown
- In the open list: moves to the previous or next role.
- Enter
- In the open list: picks the highlighted role, closes the list and calls .
- Esc
- Closes the open list without a change and returns focus to the select.
- EnterorSpace
- On the remove button: presses it and calls .
Behavior and motion
What an invite row does with state, content, the DOM and motion.
- Controlled
- The row keeps no value of its own. Typing and picking call your change handlers, and the row shows what you pass back; without a handler the field stays as it is.
- Layout
- From 640 px the email, role select and 36 px remove button sit in one row with a 12 px gap. Below that, or when stacked, the email is on top and the select and button under it.
- States
- Each control keeps the states of its own component. The row itself has no loading, error or disabled state, so write error messages yourself under the row.
- Long text
- A long address doesn't wrap or get cut with an ellipsis: it scrolls inside the field. Role names stay on one line in the select.
- Names for assistive technology
- The field is named Email, the select Role and the button Remove, the same on every row. Screen reader users can't tell rows apart by those names, so say which row changed in a status line.
- Motion and reduced motion
- The role list opens with a short fade and scale and leaves faster, and control colours change quickly. With reduced motion the list appears without a transition.
Anatomy
The parts of an invite row, numbered in the figure. The email field, role select and remove button are parts of one component.
- 1data-slot="invite-row"
A flex container with a 12 px gap between the email and the role, with no border or fill. From the small breakpoint up they sit in one row; below that, or when stacked, one over the other.
- 2
An Input of type email, named Email, that takes the rest of the row. It shows the placeholder info@wunderui.com while empty.
- 3
A NativeSelect named Role, at least 9 rem wide, with the roles you pass. The list opens below the field.
- 4Optional
A plain icon button with a 16 px X, named Remove. It is drawn only when you pass a remove handler.
Best practices
- Do
Keep it controlled: pass the email and role with their change handlers. Without the handlers the fields don't change when someone types or picks.
- Do
Pass your own roles when the defaults (Admin, Editor, Viewer) don't match the product, and make sure the current role is one of them.
- Do
Use the stacked layout in a narrow container. The row switches layout with the screen width, not its container's, so a narrow dialog on a wide screen stays inline.
- Do
Validate in your handler and write the message under the row, like Enter a valid email address. The row has no error state, so name the address when checking several rows.
- Do
After a row is removed, move focus to the list and say which address went in a status line. Every remove button is named just Remove.
- Don’t
Don't pass a remove handler to a row you must keep. The remove button is drawn only when the handler exists.
- Don’t
Don't use real addresses in docs or tests. The addresses in the demos belong to made-up people.
API reference
Invite Row is one component with the props below. It takes no other attributes, so an id, a data attribute or an aria-label can't be passed to it.
A flex container with a 12 px gap between the email and the role, with no border or fill. From the small breakpoint up they sit in one row; below that, or when stacked, one over the other.
| Prop | Type | Default | Description |
|---|---|---|---|
| email required | string | — | The value of the email field. Required, and controlled: the field shows exactly this text. |
| role required | string | — | The selected role. It should be one of . Required, and controlled. |
| roles | string[] | ["Admin", "Editor", "Viewer"] | The roles in the select, as strings that are also the labels. Defaults to Admin, Editor and Viewer. |
| onEmailChange | (email) => void | — | Called with the new text each time the email changes. Without it the field does not change. |
| onRoleChange | (role) => void | — | Called with the picked role. Without it the select does not change. |
| onRemove | () => void | — | Adds the remove button and is called when it is pressed. Take the row out of your list in the handler. |
| stacked | boolean | — | Puts the email over the role and the button at every width. Without it the row stacks only below 640 px. |
| className | string | — | Added to the row. Use it for the width. |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("invite-row")npx wunderui-cli add invite-rowThe full library index for assistants is at /llms.txt.