Field
Generates an id, points the label at it and sets `aria-describedby`, then hands all three to you through a snippet. It is the piece that stops every form growing its own slightly different label markup.
import
import { Field } from '@joshicodes/cock';Label and error
The snippet gets the id and the aria wiring; spread the rest onto the control.
Decides the currency at checkout.
Behaviour
- `error` replaces `description` while it is set, and switches the control to its invalid styling.
- The snippet receives `id`, `invalid` and `aria-describedby`. Spread the rest onto the control so the wiring survives.
API
Read out of the component sources at build time, so it matches the version you installed.
Every component also takes class, merged
through tailwind-merge so your utility wins.
Props of Field
| Prop | Type | Default |
|---|---|---|
label | string | — |
description Helper text under the control. Replaced by `error` when that is set. | string | — |
error | string | — |
required | boolean | false |
class | string | — |
Snippets of Field
| Snippet | Type | Default |
|---|---|---|
children required | Snippet<[FieldSlotArgs]> | — |