@qlik/sprout-icons
v0.23.0
Published
Comprehensive icon library for the Sprout Design System, available as React and Vue components
Readme
@qlik/sprout-icons
A comprehensive icon library for Qlik Sprout, available as React and Vue components.
Features
- 📦 Framework agnostic SVG icons
- ⚛️ React components with full TypeScript support
- 🖖 Vue 3 components
- 🎨 Customizable via SVG props
- 📐 Multiple size options
- 🎯 Tree-shakeable exports
Installation
npm install @qlik/sprout-iconsOr with pnpm:
pnpm add @qlik/sprout-iconsUsage
React
Import icons directly from the React package and use them as components:
import { AddIcon, DeleteIcon, SearchIcon } from "@qlik/sprout-icons/react";
export function MyComponent() {
return (
<div>
<AddIcon />
<DeleteIcon className="size-xl" />
<SearchIcon style={{ color: "red" }} />
</div>
);
}Icons accept any SVG element attributes, allowing you to customize:
- Styling:
className,style, inline CSS properties - Dimensions:
width,height, or use Sprout size classes (size-s,size-m,size-l, etc.) - Attributes:
data-*,aria-*, and other SVG attributes
import { DownloadIcon } from "@qlik/sprout-icons/react";
<DownloadIcon className="size-2xl text-primary" aria-label="Download file" />;Vue
Import icons from the Vue package:
<script setup>
import { AddIcon, DeleteIcon, SearchIcon } from "@qlik/sprout-icons/vue";
</script>
<template>
<div>
<add-icon />
<delete-icon class="size-xl" />
<search-icon :style="{ color: 'red' }" />
</div>
</template>Vue components support the same customization options as React components.
Available Icons
Browse all available icons in the Storybook documentation. The Storybook playground includes:
- A searchable gallery of all icons
- Live size preview
- Component code samples
Icon Naming Convention
All icon component names follow the pattern: {name}Icon
For example:
AddIconDeleteIconChevronDownIconAlertCircleIcon
Icon Pages and Color Mode
Source SVGs live in svg/. Icons directly in svg/ are the outlines set: single-colour, filled with currentColor so they follow the surrounding text colour.
Every other Figma page is exported to its own folder, svg/<page>/, and its components are prefixed with the page name (svg/file-types/pdf.svg becomes FileTypesPdfIcon). A page is single-colour by default. To keep its colours, gradients and layers as drawn, the export tool writes a page.json into the folder:
{ "mode": "color" }Colour icons keep their own size, and their ids (gradients, masks) are prefixed with the component name so several can be inlined in one document. A single-colour page that contains a gradient or a white fill fails the build with the icon's name, rather than being flattened. Mark the page as colour or redraw the icon.
Theming parts of a colour icon
Colour icons look exactly as designed unless you restyle them. To make part of an icon themeable, name its Figma layers outline or fill (Figma's outline_2, outline_3 for duplicates also work, and a group applies to everything inside it). The export tool must include layer names (Figma's "include id" export option).
Each shape in such a layer gets a sprout-icon-outline or sprout-icon-fill class, and its colour becomes a CSS variable with the designed colour as the fallback:
<path
class="sprout-icon-outline"
fill="var(--sprout-icon-outline, #262626)"
...
/>Set the variable to restyle that part, for example to a design token:
.my-icon {
--sprout-icon-outline: var(--your-outline-token);
--sprout-icon-fill: var(--your-fill-token);
}Only outline and fill can be mapped to tokens. Every other layer name is left as designed, and its colour never changes.
Logos and other fixed artwork
Third-party logos must never change colour, and we don't control their layer names: a partner file could have a layer called Fill or outline. Export logo pages with the fixed mode:
{ "mode": "fixed" }A fixed page keeps its colours, gradients and size like a colour page, but nothing in it is ever themeable, whatever its layers are called.
SVG Requirements
SVGs must not contain live text (<text>). Text is drawn with whatever font the viewer has, so it can look different on every machine. Figma's SVG export, which the Sprout Toolkit plugin uses, turns text into outlines by default, so plugin exports are fine. If an SVG reaches svg/ another way (a logo added by hand, say), convert its text to outlines first. The build does not do this for you: it fails and names the icon.
Size Options
Use Sprout's size tokens via the size-{size} class or inline CSS:
size-s- Smallsize-m- Mediumsize-l- Largesize-xl- Extra Largesize-2xl,size-3xl, ...size-7xl- Extra sizes
import { StarIcon } from "@qlik/sprout-icons/react";
<StarIcon className="size-s" /> {/* Small */}
<StarIcon className="size-xl" /> {/* Extra Large */}
<StarIcon style={{ width: "32px", height: "32px" }} /> {/* Custom */}Styling Tips
With Tailwind CSS
import { AlertIcon } from "@qlik/sprout-icons/react";
<AlertIcon className="w-6 h-6 text-red-500" />;With CSS Modules
import { CheckIcon } from "@qlik/sprout-icons/react";
import styles from "./MyComponent.module.css";
<CheckIcon className={styles.icon} />;Inline Styles
import { InfoIcon } from "@qlik/sprout-icons/react";
<InfoIcon style={{ width: "24px", height: "24px", color: "#0066cc" }} />;Accessibility
Icons are semantic SVG elements. When using icons that convey meaning:
import { DownloadIcon, WarningIcon } from "@qlik/sprout-icons/react";
{
/* Decorative icon - no label needed */
}
<button>
<DownloadIcon className="size-m" aria-hidden="true" />
</button>;
{
/* Icon conveying meaning - add label */
}
<button aria-label="Download file">
<DownloadIcon className="size-m" />
</button>;
{
/* With text content - icon is decorative */
}
<span>
<WarningIcon className="size-m" aria-hidden="true" />
Important notice
</span>;Contributing
Icons are sourced from the ./svg directory and automatically compiled to React and Vue components. To add or modify icons:
- Add or update SVG files in
./svg - Run
npm run buildto generate components - Icons will be optimized and converted to framework-specific components
See CONTRIBUTING.md for more details.
License
MIT © Qlik
