What is @ant-design/icons-svg?
The @ant-design/icons-svg package provides a collection of SVG icons that are part of the Ant Design system, which is a design language for UI design. This package allows developers to use SVG icons in their web applications, providing a consistent look and feel that aligns with the Ant Design guidelines.
What are @ant-design/icons-svg's main functionalities?
Importing and using individual SVG icons
This feature allows developers to import individual SVG icons from the package and use them in their React components. The example shows how to import the 'AccountBookFill' icon and use it within a React component.
import { AccountBookFill } from '@ant-design/icons-svg';
// Usage in a React component
const MyComponent = () => (
<svg {...AccountBookFill.props} />
);
Customizing SVG icon properties
Developers can customize the properties of SVG icons, such as 'fill', 'width', and 'height'. The example demonstrates how to override the default properties of the 'AccountBookFill' icon with custom values.
import { AccountBookFill } from '@ant-design/icons-svg';
// Customizing the icon's properties
const customProps = {
fill: 'currentColor',
width: '1em',
height: '1em'
};
// Usage in a React component
const MyComponent = () => (
<svg {...AccountBookFill.props} {...customProps} />
);
Other packages similar to @ant-design/icons-svg
react-icons
The 'react-icons' package includes a large collection of icons from various icon libraries (such as Font Awesome, Ionicons, Material Design icons, and more) for use in React applications. It is similar to @ant-design/icons-svg in that it provides ready-to-use icons, but it offers a wider range of icon sets from different sources.
material-design-icons
This package provides the Material Design icons created by Google. It is similar to @ant-design/icons-svg as it also offers SVG icons, but these icons follow Google's Material Design guidelines rather than the Ant Design system.
font-awesome
Font Awesome is a popular icon set that can be used as web fonts or SVG icons. It is similar to @ant-design/icons-svg in providing a large set of icons, but it is not specifically tied to a design system like Ant Design and offers different styles and icon categories.
Ant Design Icons
⭐ The abstract node of the Ant Design SVG icons.
Check all icons list.
Install
$ yarn add @ant-design/icons-svg
$ npm install @ant-design/icons-svg --save
Use Library Adapter
Contribution Guide 贡献指南
See contribution guide. English | 中文
Get started
import { AccountBookOutlined } from '@ant-design/icons-svg';
console.log(AccountBookOutlined);
This library export all SVG files as IconDefinition
.
export declare type ThemeType = 'filled' | 'outlined' | 'twotone';
export interface AbstractNode {
tag: string;
attrs: {
[key: string]: string;
};
children?: AbstractNode[];
}
export interface IconDefinition {
name: string;
theme: ThemeType;
icon:
| ((primaryColor: string, secondaryColor: string) => AbstractNode)
| AbstractNode;
}
Render Helpers
import { AccountBookFilled } from '@ant-design/icons-svg';
import { renderIconDefinitionToSVGElement } from '@ant-design/icons-svg/es/helpers';
const svgHTMLString = renderIconDefinitionToSVGElement(AccountBookFilled, {
extraSVGAttrs: { width: '1em', height: '1em', fill: 'currentColor' }
});
console.log(svgHTMLString);
declare function renderIconDefinitionToSVGElement(
icon: IconDefinition,
options?: HelperRenderOptions
): string;
interface HelperRenderOptions {
placeholders?: {
primaryColor?: string;
secondaryColor?: string;
};
extraSVGAttrs?: {
[key: string]: string;
};
}