I am building React storybook components using react-bootstrap. Almost components are completed well. But only some components that includes bootstrap icons don't show in storybook. Is there any way to fix this issue? Thanks.
Asked
Active
Viewed 476 times
3 Answers
0
Sometimes the issue is for linked components, in this case, you need import each icon from SVG.
import {
faEdit,
faUser,
faCartShopping,
faHeart,
} from "@fortawesome/free-solid-svg-icons";
Don't forget link the components in console with: npm link

kentomax
- 1
- 2
0
import "bootstrap-icons/font/bootstrap-icons.css";
in the .storybook/preview.js
file solved that issue.

Li 1001
- 65
- 7
0
Two things:
import "bootstrap-icons/font/bootstrap-icons.min.css";
in.storybook/preview.js
, as mentioned by @li-1001 (note that I recommend using the minified version, though).- Add the
node_modules/bootstrap-icons/font
directory to statically served files. Otherwise you will get a 404, because thebootstrap-icons.woff2
file can't be found. At least that's what I got.
So in .storybook/main.js
, do:
module.exports = {
defaultSettings: {
staticDirs: [
'../node_modules/bootstrap-icons/font',
],
// ...
And adjust this package.json
script:
"build-storybook": "storybook build -s ../node_modules/bootstrap-icons/font",
-s
can take a comma separated list, if you need to serve multiple static directories.

EzPizza
- 979
- 1
- 13
- 22