React Icon(图标)组件
Font vs SVG。 使用哪个更好呢?这两种方法都能很好地工作,但是其中有一些微妙的差异,特别是在性能和渲染质量方面。 在条件允许的情况下,首选使用 SVG 的方式,因为它允许代码分割,能支持更多的图标,并且渲染得更快更好。
更多详情,请查阅 为什么 GitHub 将 font icons 迁移到 SVG icons。
无障碍设计Icons can convey all sorts of meaningful information, so it's important to ensure they are accessible where appropriate. There are two use cases you'll want to consider: There are two use cases you'll want to consider:
装饰性图标 仅用于增强视觉或强调品牌。 即使将它们从页面中移除,用户仍然可以理解并能够使用整个界面。
Semantic icons are ones that you're using to convey meaning, rather than just pure decoration. 这包含了没有文字辅助说明的图标,这些图标一般被用作在交互式控件中 — 按钮、表单元素、切换按钮等。 这包含了没有文字辅助说明的图标,这些图标一般被用作在交互式控件中 — 按钮、表单元素、切换按钮等。
装饰性图标If your icons are purely decorative, you're already done! 而添加 aria-hidden=true 属性可以让你的图标变成正确的且可访问的(隐形的)。
语义图标语义化的 SVG icons你应该在 titleAccess 属性中增加一个有意义的值。 role="img" 属性和
对于可聚焦的交互式元素,例如当与图标按钮一起使用时,你可以使用 aria-label 属性:
import IconButton from '@material-ui/core/IconButton';
import SvgIcon from '@material-ui/core/SvgIcon';
// ...
;
语义化的 font icons你需要提供一个只有辅助技术才能看到的文本替代方案:
import Icon from '@material-ui/core/Icon';
import { visuallyHidden } from '@material-ui/utils';
import { makeStyles } from '@material-ui/core/styles';
const classes = makeStyles({ visuallyHidden })();
// ...
创建一个用户
参考
https://developer.paciellogroup.com/blog/2013/12/using-aria-enhance-svg-accessibility/