Forms
Trek ships Trek::FormBuilder, an extension of ViewComponent::Form's builder, automatically used in admin views. On top of the standard helpers, it provides:
| Helper | Renders |
|---|---|
f.group | a label + input wrapper with errors |
f.content_editor | the Tiptap rich text editor |
f.image_field | an image uploader with thumbnail preview (Uppy + Shrine) |
f.sound_field | an audio file uploader |
f.switch_box | a toggle switch |
f.link_select | a link picker (internal pages & external links) |
Each helper renders the matching component from the Trek::Form namespace.
Standard helpers are styled too: a plain f.file_field inside an f.group gets its native ::file-selector-button styled like a narrow Trek::ButtonComponent (following the current data-accent-color), keeping the browser's built-in "file chosen" feedback with no JS — handy for one-off uploads like a spreadsheet import.
slim
= form_with model: [:admin, @book] do |f|
= f.group :title
= f.content_editor :intro, floating: false
= f.switch_box :published