@fichap/icons-react
v1.0.22
Published
Fichap Iconly-based icon library for React.
Readme
@fichap/icons-react
React icon package generated from the shared svgs/ source in the monorepo.
Installation
pnpm add @fichap/icons-reactCompatible with React 17, 18, and 19.
Usage
import {
ArrowLeftRegular,
Icon,
iconNamesByVariant,
type IconSvgProps,
} from "@fichap/icons-react";
function ArrowLeftIcon(props: IconSvgProps) {
return <ArrowLeftRegular {...props} />;
}
export function Demo() {
return (
<>
<ArrowLeftIcon size={24} className='text-white' />
<Icon name='arrowLeft' size={24} className='text-red-500' />
<Icon name='arrowLeft' variant='bold' size={24} />
<Icon
name='warning'
decorative={false}
aria-label='Advertencia'
size={20}
/>
<p>Regular icons: {iconNamesByVariant.regular.length}</p>
</>
);
}Recommended usage
- For app consumers, prefer the
Iconwrapper plusnamewhen you want a single stable import. variantis optional and defaults toregular.Iconapplies accessibility defaults automatically:- Decorative icon (default):
aria-hidden={true}+focusable={false}. - Meaningful icon (
decorative={false}or whenaria-label/aria-labelledbyis present):role="img"+focusable={false}.
- Decorative icon (default):
- For bold icons, keep the same canonical
nameand passvariant="bold". - Do not append
Boldto thenameprop unless that exact canonical icon name exists in the catalog. - Use direct icon imports when you explicitly want component-level imports, custom wrappers, or tighter control over what is imported.
- Both styles share the same
IconSvgPropscontract.
API
- Each generated icon component accepts
IconSvgProps:size?: numberwidth?: number | stringheight?: number | stringclassName?: string- plus all standard SVG props
Iconwrapper extras:decorative?: booleanname: IconNamevariant?: 'regular' | 'bold'
sizeapplies towidthandheight.- Si pasás
width/height, tienen prioridad sobresize. - Hardcoded black colors are normalized to
currentColorduring generation. - Kebab-case SVG attributes are converted to React-compatible props.
Accessibility quick guide
Use these patterns with Icon:
import { Icon } from "@fichap/icons-react";
// Decorative icon (default): hidden from screen readers
<Icon name='arrowLeft' size={20} />;
// Meaningful icon: exposed with accessible name
<Icon name='dangerTriangle' decorative={false} aria-label='Error' size={20} />;Notes:
- If you use
decorative={false}, pass an accessible name witharia-labeloraria-labelledby. - If you pass
decorative, that value takes precedence over auto behavior. - Dev-only warnings are emitted for conflicting setups (for example,
decorative={false}without accessible name).
Build
pnpm --filter @fichap/icons-react buildThis command regenerates packages/react/src from the shared svgs/ source before compiling the package.
