Toddy.Iced.Widget.Svg (Toddy v0.3.0)

Copy Markdown View Source

SVG display -- renders a vector image from a file path.

Props

  • source (string) -- path to the SVG file.
  • width (length) -- SVG width. Default: shrink. See Toddy.Iced.Length.
  • height (length) -- SVG height. Default: shrink.
  • content_fit -- how the SVG fits its bounds. See Toddy.Iced.ContentFit.
  • rotation (number) -- rotation angle in degrees.
  • opacity (number) -- opacity from 0.0 (transparent) to 1.0 (opaque).
  • color (color) -- color tint applied to the SVG. See Toddy.Iced.Color.
  • alt (string) -- alt text for the SVG (accessibility).
  • description (string) -- longer description for the SVG (accessibility).
  • a11y (map) -- accessibility overrides. See Toddy.Iced.A11y.

Summary

Functions

Sets accessibility annotations.

Sets the alt text for the SVG.

Converts this SVG struct to a ui_node() map via the Toddy.Iced.Widget protocol.

Sets the color tint applied to the SVG.

Sets how the SVG fits its bounds.

Sets a longer description for the SVG.

Sets the SVG height.

Creates a new SVG struct with the given source path and optional keyword opts.

Sets the SVG opacity.

Sets the rotation angle in degrees.

Sets the SVG width.

Applies keyword options to an existing SVG struct.

Types

option()

@type option() ::
  {:width, Toddy.Iced.Length.t()}
  | {:height, Toddy.Iced.Length.t()}
  | {:content_fit, Toddy.Iced.ContentFit.t()}
  | {:rotation, number()}
  | {:opacity, number()}
  | {:color, Toddy.Iced.Color.input()}
  | {:alt, String.t()}
  | {:description, String.t()}
  | {:a11y, Toddy.Iced.A11y.t()}

t()

@type t() :: %Toddy.Iced.Widget.Svg{
  a11y: Toddy.Iced.A11y.t() | nil,
  alt: String.t() | nil,
  color: Toddy.Iced.Color.t() | nil,
  content_fit: Toddy.Iced.ContentFit.t() | nil,
  description: String.t() | nil,
  height: Toddy.Iced.Length.t() | nil,
  id: String.t(),
  opacity: number() | nil,
  rotation: number() | nil,
  source: String.t(),
  width: Toddy.Iced.Length.t() | nil
}

Functions

a11y(svg, a11y)

@spec a11y(svg :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()

Sets accessibility annotations.

alt(svg, alt)

@spec alt(svg :: t(), alt :: String.t()) :: t()

Sets the alt text for the SVG.

build(svg)

@spec build(svg :: t()) :: Toddy.Iced.ui_node()

Converts this SVG struct to a ui_node() map via the Toddy.Iced.Widget protocol.

color(svg, color)

@spec color(svg :: t(), color :: Toddy.Iced.Color.input()) :: t()

Sets the color tint applied to the SVG.

content_fit(svg, content_fit)

@spec content_fit(svg :: t(), content_fit :: Toddy.Iced.ContentFit.t()) :: t()

Sets how the SVG fits its bounds.

description(svg, description)

@spec description(svg :: t(), description :: String.t()) :: t()

Sets a longer description for the SVG.

height(svg, height)

@spec height(svg :: t(), height :: Toddy.Iced.Length.t()) :: t()

Sets the SVG height.

new(id, source, opts \\ [])

@spec new(id :: String.t(), source :: String.t(), opts :: [option()]) :: t()

Creates a new SVG struct with the given source path and optional keyword opts.

opacity(svg, opacity)

@spec opacity(svg :: t(), opacity :: number()) :: t()

Sets the SVG opacity.

rotation(svg, rotation)

@spec rotation(svg :: t(), rotation :: number()) :: t()

Sets the rotation angle in degrees.

width(svg, width)

@spec width(svg :: t(), width :: Toddy.Iced.Length.t()) :: t()

Sets the SVG width.

with_options(svg, opts)

@spec with_options(svg :: t(), opts :: [option()]) :: t()

Applies keyword options to an existing SVG struct.