Skip to content
Components

Copy field

Hand over a value with one clear copy action, inline, in a field, or in a titled code block.

TS
import { … } from "@fungi.computer/caps/components/copy-field";

Command

TSX
import { CopyField } from "@fungi.computer/caps/components/copy-field";
export default function Command() {
return <CopyField value="npx fungi forage --nearby" />;
}

Api key field

TSX
import { CopyField } from "@fungi.computer/caps/components/copy-field";
export default function ApiKeyField() {
return (
<CopyField
displayValue="sk_live_••••••••ab"
fieldLabel="API key"
label="Copy key"
value="sk_live_8f2c9139ab"
/>
);
}

Code block

TSX
import {
CopyField,
type CopyFieldToken,
} from "@fungi.computer/caps/components/copy-field";
const tokens: CopyFieldToken[] = [
{ kind: "tag", text: "<Mushroom " },
{ kind: "attribute", text: "species" },
{ kind: "text", text: "=" },
{ kind: "string", text: '"chanterelle"' },
{ kind: "tag", text: " />" },
];
export default function CodeBlock() {
return <CopyField layout="block" title="JSX" tokens={tokens} />;
}

Props

CopyFieldProps

PropTypeDescription
label?stringCopy action text; the code presentations default to "Copy".
  • label?string

    Copy action text; the code presentations default to "Copy".

Full types: API reference.