View Source PhoenixSVG behaviour (phoenix_svg v1.0.4)

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

options

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

Example

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

Link to this section Summary

Callbacks

Renders an inline SVG using a cached file.

Link to this section Callbacks

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

Renders an inline SVG using a cached file.

attributes

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.