Fields · Components
PolicyField
PolicyField — layout-neutral wrapper around any input. Contributes: - Visibility by resolved tier × current mode (advanced fields hidden in basic mode) - Initial-value prefill from the resolved default (new records only — never clobbers loaded values) - Label rendering (the resolved label; when the policy has no label the label element is omitted rather than fabricated from the raw field name, and tooltip-density help falls back to a visible hint) - Help hint rendered from resolved help (manifest description → org/user override) - Required marker Label ↔ control association: the default wrapper renders `<label for={name}>`, so the wrapped control should carry an `id` equal to the field `name`. When the first wrapped control has a different `id`, the `for` attribute is re-pointed to it after mount; when it has no `id` at all, the wrapper assigns `id={name}` so the association is guaranteed. Headless escape hatch: pass a `render` snippet receiving `{visible, label, help, defaultValue, required, tier}` for fully custom rendering. Without a snippet, PolicyField wraps children in a label + help affordance and controls visibility. Graceful degradation: outside a FieldPolicyProvider, PolicyField renders its children verbatim (no visibility filtering, no label/help injection) so forms can adopt it incrementally.Public export
typescript
import { PolicyField } from '@happyvertical/smrt-fields/svelte';- Import path
@happyvertical/smrt-fields/svelte- Props
- 10
- Props described
- 10 of 10
- Bindable state
- 0
- Callback events
- 0
- Verified release
- 0.44.0
Props
NameTypeRequiredDescription
namestringYesThe field name matching a key in the resolved policy's `fields`.idstringNoStable per-form control id; defaults to `name` for standalone use.helpIdstringNoStable per-form help id; defaults to `${id}-help`.childrenSnippetNoChildren — the actual input(s). Always rendered when the field is visible (unless the `render` snippet escape hatch is used).renderSnippet<[PolicyFieldSnippetProps]>NoHeadless escape hatch: a snippet receiving all resolved policy data for fully custom rendering. When provided, it replaces the default label + children + help layout entirely.isNewRecordbooleanNoWhether this is a new record. When true (default) and the field has a resolved default, the provider can prefill. Set to false for loaded records to prevent overwriting existing values.labelstringNoOverride the resolved label. When provided, takes precedence over the policy label.helpstringNoOverride the resolved help text. When provided, takes precedence over the policy help.helpDensity'hint' | 'tooltip'NoDensity of the help hint: 'hint' (inline hint text, default) or 'tooltip' (title attribute on the label).classstringNoAdditional class for the wrapper element.Bindable state
This component has no bindable public state.
Callback events
This component declares no callback event props.