docs/guide/lucide/advanced/global-styling.md
Adjusting icons can be done by using color, size and stroke width.
To style all icons globally, you can either use CSS, or use the attrs option in createIcons.
We recommend using CSS for global styling, as it is the most straightforward way to achieve this.
<!-- Local overwrite NOT working --> <!-- But using CSS prevents you from using props like `size`, `color` and `strokeWidth` on individual icons, since CSS specificity will override these props, to be able to use the props on individual ones you need to adjust the global styles using `attrs` in `createIcons`. -->This will apply the color, size and strokeWidth props to all icons.
createIconsYou can also apply global styles by passing attributes to the createIcons function.
::: sandpack {template=vanilla showTabs=false editorHeight=295 editorWidthPercentage=60 dependencies="lucide"}
<!DOCTYPE html>
<html>
<body>
<i data-lucide="building"></i>
<script src="index.js"></script>
</body>
</html>
import "./styles.css";
import { createIcons, Building } from 'lucide/dist/cjs/lucide';
createIcons({
attrs: {
'stroke-width': 1,
stroke: 'lightblue',
},
icons: {
Building,
}
});
:::
Styling icons is easy to accomplish using CSS.
Every icon has a class attribute applied called lucide. This class name can be used in the CSS file to target all icons that are being used within the app.
color CSS property.width and height CSS properties.stroke-width CSS property.::: sandpack {template=vanilla showTabs=false editorHeight=295 editorWidthPercentage=60 dependencies="lucide"}
.lucide {
/* Change this! */
color: #ffadff;
width: 48px;
height: 48px;
stroke-width: 1px;
}
.app {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
gap: 6px;
}
<!DOCTYPE html>
<html>
<body>
<div class="app">
<i data-lucide="cake-slice"></i>
<i data-lucide="candy"></i>
<i data-lucide="apple"></i>
<i data-lucide="cookie"></i>
<i data-lucide="martini"></i>
<i data-lucide="ice-cream-2"></i>
<i data-lucide="sandwich"></i>
<i data-lucide="wine"></i>
<i data-lucide="dessert"></i>
</div>
<script src="index.js"></script>
</body>
</html>
import "./styles.css";
import "./icon.css";
import {
createIcons,
CakeSlice,
Candy,
Apple,
Cookie,
Martini,
IceCream2,
Sandwich,
Wine,
Dessert
} from 'lucide/dist/cjs/lucide';
createIcons({
icons: {
CakeSlice,
Candy,
Apple,
Cookie,
Martini,
IceCream2,
Sandwich,
Wine,
Dessert,
}
});
:::