Forms & Inputs
@hacline/ui/token-inputTokenInput
Insert and manage structured references inline inside editable text.
Usage
Edit the sentence inline or remove attached file chips via their adjacent clear buttons. renderToken customizes token presentation while preserving plain-text and token order.
Please review delivery-plan.md checklist items.
"use client";
import {
TokenInput,
TokenInputEditor,
TokenInputToken,
TokenInputTokenRemove,
} from "@/components/ui/hacline/components/token-input";
export const Example = () => (
<div className="w-full max-w-sm">
<TokenInput
defaultValue={[
"Please review ",
{ label: "delivery-plan.md", type: "file", value: "delivery-plan" },
" checklist items.",
]}
getTokenDescription={() => "File"}
renderToken={(token) => (
<TokenInputToken>
{token.label}
<TokenInputTokenRemove />
</TokenInputToken>
)}
>
<TokenInputEditor aria-label="Review request" />
</TokenInput>
</div>
);Inserting Collaborator Mentions
Type @ to select a collaborator. The trigger menu inserts candidates as individually removable person tokens.
Invite
"use client";
import {
TokenInput,
TokenInputEditor,
TokenInputToken,
TokenInputTokenRemove,
} from "@/components/ui/hacline/components/token-input";
import { TriggerMenu } from "@/components/ui/hacline/components/trigger-menu";
import type { TriggerDefinition } from "@/components/ui/hacline/components/trigger-menu";
const mentions: TriggerDefinition[] = [
{
char: "@",
items: [
{ label: "Lin Yu", value: "lin-yu" },
{ label: "Zhou Ning", value: "zhou-ning" },
],
type: "person",
},
];
export const Example = () => (
<div className="w-full max-w-sm">
<TokenInput
defaultValue={["Invite "]}
getTokenDescription={() => "Collaborator"}
renderToken={(token) => (
<TokenInputToken>
@{token.label}
<TokenInputTokenRemove />
</TokenInputToken>
)}
>
<TokenInputEditor aria-label="Collaborator invite message" />
<TriggerMenu triggers={mentions} />
</TokenInput>
</div>
);Parts
| Part | Description | Extended Props |
|---|---|---|
TokenInputEditor | The editable text. The core owns its content; style it, and show the placeholder with data-empty. | size |
TokenInputToken | A token's content, inside renderToken, with its state for styling. | — |
TokenInputTokenRemove | Removes its token when pressed. Hidden from assistive technology: the keyboard's way is Backspace. | — |
Props
Prop
Type