Field
Label + control + hint/error wrapper; adds a required asterisk or an (optional) marker.
Code
import * as React from 'react';
import { Field, NumberInput } from '@fruit-labs/design';
export default function Demo() {
return (
<div
style={{
maxWidth: 320,
}}
>
<Field label="Team size" required hint="Billed per seat.">
{(id) => <NumberInput id={id} defaultValue={5} min={1} suffix="seats" />}
</Field>
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { Field } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/field.jsonGuidelines
- Children may be a function receiving the generated id for
htmlFor. - Mark the minority: if most fields are required, mark the optional ones with
optional; otherwise markrequired.
Props
| Prop | Type | Required |
|---|---|---|
label | React.ReactNode | No |
hint | React.ReactNode | No |
error | React.ReactNode | No |
required | boolean | No |
optional | boolean | No |
id | string | No |
className | string | No |
style | React.CSSProperties | No |
children | React.ReactNode | ((id: string) => React.ReactNode) | Yes |