I’m struggling to track down documentation for Phoenix components, like “input”, “button”, etc.
Can someone point me to the appropriate page on Hexdocs please?
I’m struggling to track down documentation for Phoenix components, like “input”, “button”, etc.
Can someone point me to the appropriate page on Hexdocs please?
They’re not on hexdocs, because they’re not part of a library. They’re in your own codebase in core_components.ex. That’s because they’re meant to be edited to your needs.
In addition to what @LostKobrakai mentioned, docs for .form
and .link
are at Phoenix.Component — Phoenix LiveView v0.20.3
I know it’s not exactly what you’re looking for but when I’m working on a project in iex
I usually just do:
iex(1) h MyAppWeb.CoreComponents.input
def input(assigns)
Renders an input with label and error messages.
A Phoenix.HTML.FormField may be passed as argument, which is used to retrieve
the input name, id, and values. Otherwise all attributes may be passed
explicitly.
## Types
This function accepts all HTML input types, considering that:
• You may also set type="select" to render a <select> tag
• type="checkbox" is used exclusively to render boolean values
• For live file uploads, see Phoenix.Component.live_file_input/1
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input for more
information.
## Examples
<.input field={@form[:email]} type="email" />
<.input name="my-input" errors={["oh no!"]} />
## Attributes
• id (:any) - Defaults to nil.
• name (:any)
• label (:string) - Defaults to nil.
• value (:any)
• type (:string) - Defaults to "text".
• field (Phoenix.HTML.FormField) - a form field struct retrieved from the
form, for example: @form[:email].
• errors (:list) - Defaults to [].
• checked (:boolean) - the checked flag for checkbox inputs.
• prompt (:string) - the prompt for select inputs. Defaults to nil.
• options (:list) - the options to pass to
Phoenix.HTML.Form.options_for_select/2.
• multiple (:boolean) - the multiple flag for select inputs. Defaults to
false.
• Global attributes are accepted. Supports all globals plus: ["accept",
"autocomplete", "capture", "cols", "disabled", "form", "list", "max",
"maxlength", "min", "minlength", "multiple", "pattern", "placeholder",
"readonly", "required", "rows", "size", "step"].
## Slots
• inner_block
If you make any local changes to any of the CoreComponents
don’t forget to update the relevant help section(s).