Skip to content

pantoken / packages/core/src / toVectorDrawable

함수: toVectorDrawable()

toVectorDrawable(svg, options?): string

베타

인라인 SVG를 Android VectorDrawable XML 문자열로 변환합니다. 스트로크 기반 아이콘(Lucide)은 strokeColor/strokeWidth를 출력합니다; 채움 기반 아이콘(Custom)은 fillColor를 출력합니다.

매개변수

svg

string

인라인 SVG 마크업.

options?

VectorDrawableOptions = {}

VectorDrawableOptions.

반환값

string

VectorDrawable XML.

예제들

스트로크 기반(Lucide) 아이콘은 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"

틴트 색이 있는 채움 기반(Custom) 아이콘은 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"