0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

storybook8でtailwind cssを利用する。

Last updated at Posted at 2024-12-02

動作環境

"next": "15.0.3"
"storybook": "8.4.6"
"tailwindcss": "^3.4.1"
"typescript": "^5"

.storybook/preview.tsを編集する。

import type { Preview } from "@storybook/react";
+ import '@/app/globals.css'; //global.cssの相対パスを指定

const preview: Preview = {
 parameters: {
   controls: {
     matchers: {
       color: /(background|color)$/i,
       date: /Date$/i,
     },
   },
 },
};

export default preview;

アドオンのインストール(もしかしたらこれはいらないかも?)

npx storybook@latest add @storybook/addon-styling-webpack

デフォルトのままだとstyleがおかしくなるのでglobal.cssを修正しておく。

@tailwind base;
@tailwind components;
@tailwind utilities;

-:root {
-  --background: #ffffff;
-  --foreground: #171717;
-}
-
-@media (prefers-color-scheme: dark) {
- :root {
-    --background: #0a0a0a;
-    --foreground: #ededed;
-  }
-}
-
-body {
-  color: var(--foreground);
-  background: var(--background);
-  font-family: Arial, Helvetica, sans-serif;
-}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?