Wraps a control with a label, help description, and error slot, matching the
shadcn form-field anatomy. The bundled JS wires aria-describedby from the
description/error elements to the contained control on init. Most Tier 2
constructors reuse this internally when given label/description.
Usage
shad_form_field(
...,
label = NULL,
description = NULL,
error = NULL,
required = FALSE,
inputId = NULL,
class = NULL
)Arguments
- ...
The control(s) to wrap, plus optional named attributes.
- label
Optional field label text.
- description
Optional help text shown below the control.
- error
Optional error message. When non-
NULLthe error slot is shown (otherwise it is rendered buthidden, ready for client-side validation).- required
If
TRUE, appends a visual required marker to the label.- inputId
Optional id for the field root.
- class
Extra CSS classes.
See also
Other shadshiny tier-2 components:
shad_calendar(),
shad_checkbox(),
shad_combobox(),
shad_date_picker(),
shad_date_presets(),
shad_input(),
shad_input_group(),
shad_input_otp(),
shad_native_select(),
shad_radio_group(),
shad_select(),
shad_slider(),
shad_switch(),
shad_textarea(),
shad_toggle(),
shad_toggle_group()
Examples
shad_form_field(
shad_input("user", value = "shadcn"),
label = "Username",
description = "This is your public display name."
)
#> <div class="shad-form-field" data-shad="form-field">
#> <label class="shad-label">Username</label>
#> <input id="user" class="shad-input" type="text" value="shadcn"/>
#> <p class="shad-form-field__description">This is your public display name.</p>
#> <p class="shad-form-field__error" hidden></p>
#> </div>