@mt-gloss/icons
v0.1.157
Published
A scalable SVG icon library for the Gloss UI design system. Icons are compiled into a single sprite for optimal performance and can be styled via CSS using `currentColor`.
Readme
@mt-gloss/icons
A scalable SVG icon library for the Gloss UI design system. Icons are compiled into a single sprite for optimal performance and can be styled via CSS using currentColor.
Installation
npm install @mt-gloss/iconsPeer Dependencies
- react ^18 || ^19
- react-dom ^18 || ^19
Usage
Basic Setup
Wrap your application with the SpriteProvider to inject the icon sprite into the DOM:
import { SpriteProvider } from '@mt-gloss/icons';
function App() {
return (
<SpriteProvider>
<YourApp />
</SpriteProvider>
);
}Using Icons
import { Icon } from '@mt-gloss/icons';
function MyComponent() {
return (
<div>
<Icon name="check" size="md" />
<Icon name="chevron-down" size="lg" className="text-blue-500" />
<Icon name="close" size="sm" />
</div>
);
}Available Icons
The library includes 27 icons extracted from the Gloss UI design system:
alert-circle- Alert/warning indicatorbook- Documentation/readingcheck- Checkmark/successcheck-square- Checkbox checkedchevron-down- Dropdown indicatorchevron-left- Navigation arrowclose- Close/dismisscredit-card- Paymentdroplet- Color/themegrid- Spacing/layouthash- Tag/categorizationhome- Home/dashboardinfo- Informationinput- Input fieldlayers- Layers/organizationlayout- Layout/structurelightbulb- Ideas/tipslink- Hyperlinklock- Security/passwordlog-in- Authenticationmenu- Navigation menumore-vertical- More optionsrefresh- Reload/refreshsquare- Button/controlstar- Favorite/ratingtag- Label/tagtype- Typography
Icon Sizes
Available sizes with corresponding pixel dimensions:
sm- 16pxmd- 20px (default)lg- 24pxxl- 32px
Styling
Icons inherit the current text color by default due to currentColor usage in fill/stroke:
<div className="text-blue-600">
<Icon name="check" /> {/* Will be blue */}
</div>
<Icon name="close" style={{ color: '#ef4444' }} /> {/* Inline style */}Advanced Usage
Manual Sprite Injection
For SSR or custom rendering scenarios, you can manually inject the sprite:
import { spriteContent } from '@mt-gloss/icons';
// Insert sprite into the DOM
const div = document.createElement('div');
div.innerHTML = spriteContent;
div.style.display = 'none';
document.body.insertBefore(div, document.body.firstChild);Custom Icon Component
You can extend the Icon component for custom behaviors:
import { Icon, IconProps } from '@mt-gloss/icons';
interface CustomIconProps extends IconProps {
rotate?: number;
}
export function CustomIcon({ rotate = 0, style, ...props }: CustomIconProps) {
return (
<Icon
{...props}
style={{
...style,
transform: `rotate(${rotate}deg)`,
transition: 'transform 0.2s',
}}
/>
);
}Development
Adding New Icons
- Add SVG file to
src/assets/(e.g.,new-icon.svg) - Ensure
currentColoris used for fills/strokes - Run the build script:
npm run build:spriteBuilding the Library
nx build gloss-iconsLicense
MIT
