Icons
Grauity includes a comprehensive icon system with over 450 icons organized into categories. The icon system uses a custom icon font built from theiconland submodule and provides a flexible React component for rendering icons.
Installation
Icons are included with the Grauity package. To use icons, you need to import the icon CSS:The icon fonts are loaded from
ui/fonts/grauity-icons.* and include .eot, .ttf, .woff, and .woff2 formats for maximum browser compatibility.NSIcon Component
TheNSIcon component (defined in ui/elements/Icon/Icon.tsx:13) is the primary way to render icons in Grauity.
Basic Usage
Props
The name of the icon to display. See Icon Categories for available icons.
The size of the icon in pixels (e.g.,
"16", "20", "24", "32").The color of the icon. Accepts any color value or design token.
The HTML element to render as.
Additional CSS classes to apply.
Whether the icon is disabled.
Whether to add a border around the icon.
Whether to render the icon with a circular background.
Whether to remove extra spacing around the icon.
Whether to invert the icon colors.
Whether the icon should appear as a clickable link.
Whether the icon should display a loading animation.
Flip the icon horizontally or vertically.
Rotate the icon by the specified degrees.
Accessible label for the icon (for screen readers).
Whether the icon is hidden from screen readers.
Click handler for the icon.
Icon Categories
Grauity’s icons are organized into 14 categories. You can access icon category mappings through the exported constants:Available Categories
- System
- Media
- Alert
- Reward
- User
- Code
- Docs
- Time
- Device
- Misc
- Finance
- College
250+ icons for common UI actions and navigation:
- Arrows:
arrow-up,arrow-down,arrow-left,arrow-right - Chevrons:
chevron-up,chevron-down,chevron-left,chevron-right - Actions:
check,close,plus,minus,search,filter - Controls:
menu,gear,refresh,upload,download - States:
loading,check-circle,close-circle,info-circle
check, close, menu, search, gear, arrow-right, chevron-down, home, book, briefcase, bulb, camera, copy, email, globe, link, starEach icon typically comes in both outlined and filled variants. For example:
star and star-filled.Icon Variants
Many icons support different style variants:Filled vs Outlined
Rotations and Flips
Using Icons in Components
Icons integrate seamlessly with other Grauity components:With Buttons
Standalone Icons
Icon Font Build Process
Grauity’s icon system uses a custom build process:- Source: Icons are stored as SVG files in the
iconlandsubmodule - Build: The build process converts SVGs to an icon font
- Output: Generated files in
ui/fonts/:grauity-icons.eotgrauity-icons.ttfgrauity-icons.woffgrauity-icons.woff2
- CSS: The
grauity-icons.scssfile defines icon classes and mappings
Adding New Icons
To add new icons to Grauity:- Add SVG files to the
iconlandsubmodule - Update the icon mappings in
ui/core/icons/iconTags.ts - Rebuild the icon font
- Update the CSS
Accessibility
Grauity icons are designed with accessibility in mind:By default, icons have
aria-hidden="true". Always provide an ariaLabel when an icon is used as a standalone interactive element.Best Practices
Consistent Sizing
Use consistent icon sizes throughout your app. Common sizes: 16px, 20px, 24px, 32px.
Filled vs Outlined
Use filled icons for active/selected states, outlined for inactive/default states.
Accessibility
Always provide aria labels for standalone interactive icons.
Loading States
Use the
loading prop with the loading icon for async actions.Finding Icons
To explore all available icons, check:- Source code:
ui/core/icons/iconTags.tscontains the complete icon list - Storybook: Browse icons interactively in the Grauity Storybook
- Constants: Import
ICON_TAGSandTAG_ICONSto programmatically access icon lists
Related
- NSButton - Using icons in buttons
- NSIconButton - Icon-only button component
- Design Tokens - Color tokens for styling icons