PhxComponentHelpers.extend_class

You're seeing just the function extend_class, go back to PhxComponentHelpers module for more information.
Link to this function

extend_class(assigns, default_classes, opts \\ [])

View Source

Extends assigns with class attributes.

The class attribute will take provided default_classes as a default value and will be extended, on a class-by-class basis, by your assigns.

Parameters

  • assigns - your component assigns
  • default_classes - the default classes that will be overridden by your assigns.

Options

  • :attribute - read & write css classes from & into this key
  • :error_class - extra class that will be added if assigns contain form/field keys and field is faulty.

Example

assigns
|> extend_class("bg-blue-500 mt-8")
|> extend_class("py-4 px-2 divide-y-8 divide-gray-200", attribute: :wrapper_class)
|> extend_class("form-input", error_class: "form-input-error", attribute: :input_class)

assigns now contains @raw_class and @raw_wrapper_class.

If your input assigns were %{class: "mt-2", wrapper_class: "divide-none"} then:

  • @raw_class would contain "bg-blue-500 mt-2"
  • @raw_wrapper_class would contain "py-4 px-2 divide-none"