Overview
The Icon component renders icons from the Grauity icon library with customizable properties like size, color, rotation, and styling options.
Basic Usage
import { Icon } from '@newtonschool/grauity';
function MyComponent() {
return (
<NSIcon
name="sparkle"
size="32"
color="var(--text-emphasis-primary-default)"
/>
);
}
Name of the icon to display from the Grauity icon library.
Size of the icon in pixels.Available sizes: 12, 16, 20, 24, 32, 40, etc.
Color of the icon. Accepts CSS color values or design tokens.
Show that the icon is in an inactive state.
Use the icon as a loading spinner.
Flip the icon horizontally or vertically.Available choices: horizontally, vertically
Rotate the icon.Available choices: clockwise, counterclockwise
Format the icon to appear with a border.
Format the icon to appear in a circular container.
Invert the icon colors (works with bordered or circular icons).
Remove space to the left or right of the icon.
Format the icon as a clickable link.
Element type to render as (e.g., button, a, span).
Additional CSS classes to be added to the component.
Additional inline styles to be applied to the element.
Aria-hidden attribute for accessibility.
Aria-label attribute for accessibility.
Icon Sizes
<NSIcon name="sparkle" size="12" />
<NSIcon name="sparkle" size="16" />
<NSIcon name="sparkle" size="20" />
<NSIcon name="sparkle" size="24" />
<NSIcon name="sparkle" size="32" />
<NSIcon name="sparkle" size="40" />
Loading State
Use an icon as a loading spinner:
<NSIcon name="loading" loading={true} size="24" />
Disabled State
<NSIcon name="sparkle" disabled={true} size="24" />
Transformations
Flipped Icons
<NSIcon name="arrow-right" flipped="horizontally" />
<NSIcon name="arrow-right" flipped="vertically" />
Rotated Icons
<NSIcon name="arrow-right" rotated="clockwise" />
<NSIcon name="arrow-right" rotated="counterclockwise" />
Styled Icons
Bordered Icon
<NSIcon
name="sparkle"
bordered={true}
size="32"
/>
Circular Icon
<NSIcon
name="sparkle"
circular={true}
size="32"
/>
Inverted Colors
Works with bordered or circular icons:
<NSIcon
name="sparkle"
bordered={true}
inverted={true}
size="32"
/>
<NSIcon
name="sparkle"
circular={true}
inverted={true}
size="32"
/>
Custom Colors
<NSIcon
name="sparkle"
color="#FF5733"
size="32"
/>
<NSIcon
name="sparkle"
color="var(--text-emphasis-brand-default)"
size="32"
/>
Inherit Color
Useful when used inside buttons or other colored containers:
<NSIcon name="sparkle" color="inherit" size="20" />