A standalone SVG icon library for StrataKit
npm install @stratakit/iconsStandalone .svg icons for StrataKit.
Each icon is available as an SVG containing multiple resolutions of the same icon using elements. This allows the icon to be used at different sizes with increasing detail and quality.
Currently supported symbols as identified by their id attribute values are:
- icon
- icon-large
These symbols can be accessed by appending a hash (e.g. #icon, #icon-large) to the .svg URL.
Using your package manager of choice, install the latest version of @stratakit/icons.
``console`
npm add @stratakit/icons
> [!NOTE]
>
> As @stratakit/icons requires bundler configuration, consider making it a _peer_ dependency if you're building a package that uses @stratakit/icons.
1. Import the icon you want to use.
Using a static import to get the URL of the icon:
`tsx`
import placeholderIcon from "@stratakit/icons/placeholder.svg";
Or using the import.meta feature to get the URL of the icon:
`tsx`
const placeholderIcon = new URL("@stratakit/icons/placeholder.svg", import.meta.url).href;
The static import method is good for use with build tools that support it, while the import.meta works better in browsers (but may not work reliably in all build tools).
2. Pass it to the Icon component from @stratakit/mui or @stratakit/foundations.
`tsx
import { Icon } from "@stratakit/mui";
`
An optional hash can be specified to select a specific symbol from the .svg:
`tsx
} />
} size="large" />`
Alternatively, you can
`tsx
`
> [!IMPORTANT]
> Icons of @stratakit/icons should always be used as external HTTP resources, because of SVG
Within your Vite configuration, you will need to configure build.assetsInlineLimit to ensure .svg files are not inlined:
`ts`
export default defineConfig({
// …
build: {
assetsInlineLimit: (filePath) => {
if (filePath.endsWith(".svg")) return false;
return undefined;
},
},
});
Within your Rsbuild configuration, you will need to configure output.dataUriLimit to ensure .svg files are not inlined:
`ts`
export default {
// …
output: {
dataUriLimit: {
svg: 0,
},
},
};
With esbuild, you will need to enable the file loader for .svg files:
`ts`
esbuild.build({
// …
loader: {
".svg": "file",
},
});
> [!NOTE]
> esbuild does not support bundling of assets when using the URL constructor, so you may need to additionally use a plugin to transform those into static import statements.
Are you interested in helping StrataKit grow? You can submit feature requests or bugs by creating issues.
If you're interested in contributing code, please read CONTRIBUTING.md` for more information.