Skip to content

[Documentation]: Angular theming not working! #33855

@MurhafSousli

Description

@MurhafSousli

Describe the problem

I am using Storybook v20 (CSF next) + Angular v21 (library)

I followed the theming documentation https://storybook.js.org/docs/essentials/themes

I could choose a dark theme, but cannot switch between dark and light!

The theme toggle appears in the toolbar, however, toggling it doesn't do what is written in the docs, it doesn't apply a class anywhere in the DOM

Preview.ts

import { definePreview } from '@storybook/angular';
import { setCompodocJson } from '@storybook/addon-docs/angular';
import docJson from '../documentation.json';

import addonDocs from '@storybook/addon-docs';
import addonA11y from '@storybook/addon-a11y';
import addonThemes from '@storybook/addon-themes';
import { withThemeByClassName } from '@storybook/addon-themes'

import { themes } from 'storybook/theming';

setCompodocJson(docJson);

export default definePreview({
  tags: ['autodocs'],

  addons: [
    addonDocs(),
    addonA11y(),
    addonThemes()
  ],

  parameters: {
    docs: {
      theme: themes.dark,
    },
  },

  decorators: [
    withThemeByClassName({
      themes: {
        light: 'light-theme',
        dark: 'dark-theme',
      },
      defaultTheme: 'dark',
    }),
  ]
});

main.ts

import { defineMain } from '@storybook/angular/node';
import remarkGfm from "remark-gfm";

export default defineMain({
  stories: [
    '../src/**/*.mdx',
    '../src/**/*.stories.@(ts|tsx)'
  ],

  addons: [
    '@storybook/addon-a11y',
    '@storybook/addon-themes',
    {
      name: '@storybook/addon-docs',
      options: {
        mdxPluginOptions: {
          mdxCompileOptions: {
            remarkPlugins: [remarkGfm],
          },
        },
      },
    }
  ],

  framework: '@storybook/angular'
});

manager.ts

import { addons } from 'storybook/manager-api';
import { themes } from 'storybook/theming';

addons.setConfig({
  theme: themes.dark
});

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions