View Source PhoenixSVG behaviour (phoenix_svg_lv_1 v1.1.0)

Inline SVG component for Phoenix. Check out the README to get started.

Options

  • :otp_app - The name of your OTP application. This is required.

  • :as - The name of the generated component function. Defaults to :svg.

  • :from - The path of your svg files relative to your project directory. If using releases, make sure this path is included in your release directory (priv is included by default). Defaults to priv/svgs.

  • :attributes - A keyword list of default attributes to inject into the SVG tags. Defaults to [].

Example

use PhoenixSVG,
  otp_app: :myapp,
  as: :icon,
  from: "priv/static/icons",
  attributes: [width: "24px", height: "24px"]
<.icon name="checkmark" />

Summary

Callbacks

Renders an inline SVG using a cached file.

Callbacks

svg(assigns)

@callback svg(assigns :: map()) :: Phoenix.LiveView.Rendered.t()

Renders an inline SVG using a cached file.

Attributes

  • :name - The name of the svg file, excluding the .svg extension.

  • :path - A list of nested paths if the file is not in the root.

Any other attributes will be passed through to the SVG tag.