Primitives
Label
A control's visible name, with a required marker
States
Workspace nameShown on invitations.
Workspace nameShown to everyone in the workspace.
Workspace nameUse 3–40 characters.
Usage
import { useRef } from "react";
import type { PublicInstance } from "@gpuix/react";
import { Input, Label, labelledBy } from "@gpuixui/primitives";
const name = "Workspace name";
const help = "Shown on invitations and in the app switcher.";
export const NameField = () => {
const ref = useRef<PublicInstance>(null);
return (
<>
<Label target={ref} description={help}>
{name}
</Label>
<Input ref={ref} {...labelledBy(name)} description={help} fullWidth />
</>
);
};API
| Prop | Type | Default | Consequence |
|---|---|---|---|
target | RefObject<PublicInstance | null> | none | a press on the label focuses this control |
disabled | boolean | false | drops that press, for a control that is disabled |
required | boolean | false | appends a destructive *; visual only |
invalid | boolean | false | paints the name in the destructive role |
description | string | none | a caption line under the name; a blank one paints nothing, the rule a blank name keeps |
className | string | — | a Tailwind class string, joined after the recipe so it wins conflicts |
style | StyleDesc | — | merged last |
testId | string | — | stable locator |
children | ReactNode | — | the name |
Edit this page on GitHubpackages/primitives/docs/label.mdx