導覽

v1.0.0
框架

Astro

在 Astro 呈現動態或固定的光學圖稿。

本頁內容

#動態圖示

Astro 是必要的 peer dependency。請在應用程式安裝 Astro 7,並安裝 @master/icons-astro。

---import { SearchIcon } from '@master/icons-astro';---<SearchIcon size={20} corner="rounded" label="Search" />

動態入口會為每個匯入的圖示包含九種光學尺寸與圓角組合,以及各組合支援的線寬圖稿,與其他框架及 SVG 共用相同幾何。size 會選擇最接近的光學圖稿;corner 預設為 soft。

#固定圖示

---import { SearchIcon } from '@master/icons-astro/16/soft';---<button aria-label="Search"><SearchIcon /></button>

固定入口只包含一種光學尺寸與圓角。可將 16/soft 換成 16、20、24 與 sharp、soft、rounded 的任意組合。固定元件不接受 corner 或 opticalSize;size 只會縮放所選圖稿。

#框架行為

原生 .astro 元件會輸出 inline SVG,不需要瀏覽器端圖示 JavaScript,也不需要框架整合或 client:* 指令。支援 SVG 屬性、class:list 與預設 slot。Node.js 版本須符合 Astro 的要求。

沒有標籤的圖示會視為裝飾。對有意義的圖示使用 label、aria-label 或 aria-labelledby,或替外層按鈕命名,詳見無障礙。

#自訂線寬

動態與固定入口都接受 strokeWidth,以原生單位與 0.25 為級距。它會選用重新繪製的幾何,而非修改 SVG 的線寬屬性。

---import { SearchIcon } from '@master/icons-astro/24/soft';---<SearchIcon size={48} strokeWidth={2} />

各光學尺寸支援的範圍與繪製方式,請見線寬。