FieldScope
The parts every labeled form field composes.
Lowercase letters, numbers and dashes.
View code
function SlugField(handle: Handle<{ name: string; children: RemixNode }>) {
return () => {
let field = wireField(handle, {
slot: "slug-field",
name: handle.props.name,
children: handle.props.children,
});
let { color, ...control } = field.control;
return (
<FieldScope context={field.context}>
{field.arrange(
<input {...control} data-color={color} name={handle.props.name} />,
)}
</FieldScope>
);
};
}
<SlugField name="slug">
<FieldLabel>Workspace address</FieldLabel>
<FieldPrefix>sdxc.dev/</FieldPrefix>
<FieldDescription>Lowercase letters, numbers and dashes.</FieldDescription>
</SlugField>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add field-partsUsage
import { FieldScope } from "@sdxc/ui";The stacked host of a labeled field. It publishes the ids and message its field resolved, so each part wires itself to the control wherever the caller writes it.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
context | Context | — | No | What the parts read; without it they draw unwired, under the default field slot. |
Also accepts everything in TagProps<"div">.
Also exported
Other components this module publishes.
FieldLabelFieldDescriptionFieldErrorMessageFieldPrefixFieldSuffixwireField