Skip to content

pantoken / packages/core/src / toVectorDrawable

Función: toVectorDrawable()

toVectorDrawable(svg, options?): string

Beta

Convierte un SVG en línea a una cadena XML de Android VectorDrawable. Los iconos basados en trazo (Lucide) emiten strokeColor/strokeWidth; los iconos basados en relleno (Custom) emiten fillColor.

Parámetros

svg

string

Marcado SVG en línea.

options?

VectorDrawableOptions = {}

VectorDrawableOptions.

Devuelve

string

El XML de VectorDrawable.

Ejemplos

Un icono basado en trazo (Lucide) emite strokeColor

ts
import { toVectorDrawable } from "@pantoken/core";

const xml = toVectorDrawable(
  '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">' +
    '<path d="M5 12h14"/></svg>',
);
// → <vector …> with android:strokeColor and android:pathData="M5 12h14"

Un icono basado en relleno (Custom) con un color de tinte emite fillColor

ts
import { toVectorDrawable } from "@pantoken/core";

toVectorDrawable('<svg viewBox="0 0 24 24"><path d="M0 0h24v24H0z"/></svg>', {
  color: "#FF0374B5",
});
// → <vector …> with android:fillColor="#FF0374B5"