|
| 1 | +# @qlik/sprout-icons |
| 2 | + |
| 3 | +A comprehensive icon library for Qlik Sprout, available as React and Vue components. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- 📦 Framework agnostic SVG icons |
| 8 | +- ⚛️ React components with full TypeScript support |
| 9 | +- 🖖 Vue 3 components |
| 10 | +- 🎨 Customizable via SVG props |
| 11 | +- 📐 Multiple size options |
| 12 | +- 🎯 Tree-shakeable exports |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +```bash |
| 17 | +npm install @qlik/sprout-icons |
| 18 | +``` |
| 19 | + |
| 20 | +Or with pnpm: |
| 21 | + |
| 22 | +```bash |
| 23 | +pnpm add @qlik/sprout-icons |
| 24 | +``` |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +### React |
| 29 | + |
| 30 | +Import icons directly from the React package and use them as components: |
| 31 | + |
| 32 | +```tsx |
| 33 | +import { AddIcon, DeleteIcon, SearchIcon } from "@qlik/sprout-icons/react"; |
| 34 | + |
| 35 | +export function MyComponent() { |
| 36 | + return ( |
| 37 | + <div> |
| 38 | + <AddIcon /> |
| 39 | + <DeleteIcon className="size-xl" /> |
| 40 | + <SearchIcon style={{ color: "red" }} /> |
| 41 | + </div> |
| 42 | + ); |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +Icons accept any SVG element attributes, allowing you to customize: |
| 47 | + |
| 48 | +- **Styling**: `className`, `style`, inline CSS properties |
| 49 | +- **Dimensions**: `width`, `height`, or use Sprout size classes (`size-s`, `size-m`, `size-l`, etc.) |
| 50 | +- **Attributes**: `data-*`, `aria-*`, and other SVG attributes |
| 51 | + |
| 52 | +```tsx |
| 53 | +import { DownloadIcon } from "@qlik/sprout-icons/react"; |
| 54 | + |
| 55 | +<DownloadIcon className="size-2xl text-primary" aria-label="Download file" />; |
| 56 | +``` |
| 57 | + |
| 58 | +### Vue |
| 59 | + |
| 60 | +Import icons from the Vue package: |
| 61 | + |
| 62 | +```vue |
| 63 | +<script setup> |
| 64 | +import { AddIcon, DeleteIcon, SearchIcon } from "@qlik/sprout-icons/vue"; |
| 65 | +</script> |
| 66 | +
|
| 67 | +<template> |
| 68 | + <div> |
| 69 | + <add-icon /> |
| 70 | + <delete-icon class="size-xl" /> |
| 71 | + <search-icon :style="{ color: 'red' }" /> |
| 72 | + </div> |
| 73 | +</template> |
| 74 | +``` |
| 75 | + |
| 76 | +Vue components support the same customization options as React components. |
| 77 | + |
| 78 | +## Available Icons |
| 79 | + |
| 80 | +Browse all available icons in the [Storybook documentation](./storybook). The Storybook playground includes: |
| 81 | + |
| 82 | +- A searchable gallery of all icons |
| 83 | +- Live size preview |
| 84 | +- Component code samples |
| 85 | + |
| 86 | +## Icon Naming Convention |
| 87 | + |
| 88 | +All icon component names follow the pattern: `{name}Icon` |
| 89 | + |
| 90 | +For example: |
| 91 | + |
| 92 | +- `AddIcon` |
| 93 | +- `DeleteIcon` |
| 94 | +- `ChevronDownIcon` |
| 95 | +- `AlertCircleIcon` |
| 96 | + |
| 97 | +## Size Options |
| 98 | + |
| 99 | +Use Sprout's size tokens via the `size-{size}` class or inline CSS: |
| 100 | + |
| 101 | +- `size-s` - Small |
| 102 | +- `size-m` - Medium |
| 103 | +- `size-l` - Large |
| 104 | +- `size-xl` - Extra Large |
| 105 | +- `size-2xl`, `size-3xl`, ... `size-7xl` - Extra sizes |
| 106 | + |
| 107 | +```tsx |
| 108 | +import { StarIcon } from "@qlik/sprout-icons/react"; |
| 109 | + |
| 110 | +<StarIcon className="size-s" /> {/* Small */} |
| 111 | +<StarIcon className="size-xl" /> {/* Extra Large */} |
| 112 | +<StarIcon style={{ width: "32px", height: "32px" }} /> {/* Custom */} |
| 113 | +``` |
| 114 | + |
| 115 | +## Styling Tips |
| 116 | + |
| 117 | +### With Tailwind CSS |
| 118 | + |
| 119 | +```tsx |
| 120 | +import { AlertIcon } from "@qlik/sprout-icons/react"; |
| 121 | + |
| 122 | +<AlertIcon className="w-6 h-6 text-red-500" />; |
| 123 | +``` |
| 124 | + |
| 125 | +### With CSS Modules |
| 126 | + |
| 127 | +```tsx |
| 128 | +import { CheckIcon } from "@qlik/sprout-icons/react"; |
| 129 | +import styles from "./MyComponent.module.css"; |
| 130 | + |
| 131 | +<CheckIcon className={styles.icon} />; |
| 132 | +``` |
| 133 | + |
| 134 | +### Inline Styles |
| 135 | + |
| 136 | +```tsx |
| 137 | +import { InfoIcon } from "@qlik/sprout-icons/react"; |
| 138 | + |
| 139 | +<InfoIcon style={{ width: "24px", height: "24px", color: "#0066cc" }} />; |
| 140 | +``` |
| 141 | + |
| 142 | +## Accessibility |
| 143 | + |
| 144 | +Icons are semantic SVG elements. When using icons that convey meaning: |
| 145 | + |
| 146 | +```tsx |
| 147 | +import { DownloadIcon, WarningIcon } from "@qlik/sprout-icons/react"; |
| 148 | + |
| 149 | +{ |
| 150 | + /* Decorative icon - no label needed */ |
| 151 | +} |
| 152 | +<button> |
| 153 | + <DownloadIcon className="size-m" aria-hidden="true" /> |
| 154 | +</button>; |
| 155 | + |
| 156 | +{ |
| 157 | + /* Icon conveying meaning - add label */ |
| 158 | +} |
| 159 | +<button aria-label="Download file"> |
| 160 | + <DownloadIcon className="size-m" /> |
| 161 | +</button>; |
| 162 | + |
| 163 | +{ |
| 164 | + /* With text content - icon is decorative */ |
| 165 | +} |
| 166 | +<span> |
| 167 | + <WarningIcon className="size-m" aria-hidden="true" /> |
| 168 | + Important notice |
| 169 | +</span>; |
| 170 | +``` |
| 171 | + |
| 172 | +## Contributing |
| 173 | + |
| 174 | +Icons are sourced from the `./svg` directory and automatically compiled to React and Vue components. To add or modify icons: |
| 175 | + |
| 176 | +1. Add or update SVG files in `./svg` |
| 177 | +2. Run `npm run build` to generate components |
| 178 | +3. Icons will be optimized and converted to framework-specific components |
| 179 | + |
| 180 | +See [CONTRIBUTING.md](./CONTRIBUTING.md) for more details. |
| 181 | + |
| 182 | +## License |
| 183 | + |
| 184 | +MIT © Qlik |
0 commit comments