• English
  • Styling guide

    Themes control Markdown colors, typography and spacing. Container styles handle layout. Use Slot plugins to change components or interactions.

    Follow your app's theme

    import { Fluxdown } from '@fluxdown/solid';
    
    type ArticleProps = {
      text: string;
    
      dark: boolean;
    };
    
    export function Article(props: ArticleProps) {
      return <Fluxdown text={props.text} theme={props.dark ? 'dark' : 'light'} />;
    }

    The default theme is light. Pass your app's theme state to switch it reactively.

    Adjust typography and color

    Start with a preset and override only the tokens you need:

    import type { Theme } from '@fluxdown/solid';
    
    import { Fluxdown } from '@fluxdown/solid';
    
    type ArticleProps = {
      text: string;
    };
    
    const theme: Theme = [
      'light',
      {
        tokens: {
          colors: { accent: '#567153' },
          typography: { fontSans: 'Inter, sans-serif' },
          heading: { h1: { fontSize: '2rem' } },
          paragraph: { marginBottom: '1rem' },
        },
      },
    ];
    
    export function Article(props: ArticleProps) {
      return <Fluxdown text={props.text} theme={theme} />;
    }

    Import Theme from @fluxdown/solid.

    A token object on its own uses light as its base. Use ['dark', overrides] to start from the dark theme. Set colors.bg: 'transparent' to blend into the surrounding container.

    Arrange the container

    Solid's class, classList and style apply to the outer element. Use them to arrange that container, and tokens for the Markdown inside it:

    <Fluxdown
      text={text()}
      class="article"
      style={{ 'max-width': '72ch', 'margin-inline': 'auto' }}
    />

    See configuration for syntax options such as math and footnotes.

    Style fields

    All fields below live under theme.tokens and support partial overrides. Colors, dimensions, and spacing accept CSS values; line heights and font weights also accept numbers. Omitted fields inherit from the selected theme.

    Import ThemeTokens from @fluxdown/solid for the full type.

    Colors

    FieldMeaning
    colors.fgPrimary text color.
    colors.fgMutedSecondary text for quotes and supporting information.
    colors.bgContent background color.
    colors.borderDefault border color.
    colors.accentAccent color for links and interactive controls.
    colors.accentHoverHover color for links and interactive controls.
    colors.surfaceMutedMuted surface color for code toolbars, table headers, and inline code.
    colors.surfaceSubtleSubtle surface color for code blocks, blockquotes, and alternating table rows.
    colors.borderEmphasisEmphasized border color for areas such as blockquotes.

    Typography

    FieldMeaning
    typography.fontSansFont family for body text and headings.
    typography.fontMonoMonospace family for code and formula placeholders.
    typography.fontSmoothingFont smoothing, such as antialiased.
    typography.fontSize.xsSmallest font size, used for code toolbars and supporting labels.
    typography.fontSize.smSmall font size, used for tables and footnotes.
    typography.fontSize.mdBody font size.
    typography.lineHeight.smCompact line height.
    typography.lineHeight.mdDefault line height for body content.
    typography.lineHeight.lgRelaxed line height.
    typography.fontWeight.normalBody font weight.
    typography.fontWeight.mediumMedium weight for table headers and toolbar labels.
    typography.fontWeight.boldWeight for bold text.

    Headings

    Replace <level> with h1, h2, h3, h4, h5, or h6 to configure each heading level independently.

    FieldMeaning
    heading.<level>.fontSizeFont size for this heading level.
    heading.<level>.fontWeightFont weight for this heading level.
    heading.<level>.lineHeightLine height for this heading level.
    heading.<level>.marginTopSpace above the heading.
    heading.<level>.marginBottomSpace below the heading.

    Paragraphs and code blocks

    FieldMeaning
    paragraph.marginTopSpace above paragraphs.
    paragraph.marginBottomSpace below paragraphs.
    code.fontSizeCode block font size.
    code.lineHeightCode block line height.

    Inline code

    FieldMeaning
    inlineCode.paddingBlockTop and bottom padding.
    inlineCode.paddingInlineInline padding on both sides.
    inlineCode.borderFull border declaration, such as 1px solid #ddd.
    inlineCode.borderRadiusCorner radius.
    inlineCode.backgroundBackground color or background declaration.
    inlineCode.fontFamilyFont family.
    inlineCode.fontSizeFont size.
    inlineCode.whiteSpaceWhitespace and wrapping behavior, such as break-spaces.

    Dividers

    FieldMeaning
    divider.heightDivider height.
    divider.marginBlockTop and bottom margins.
    divider.marginInlineInline margins on both sides.
    divider.borderFull border declaration.
    divider.borderBlockEndBottom border declaration.
    divider.backgroundBackground color or background declaration.

    Footnotes

    FieldMeaning
    footnotes.marginTopMargin above the footnote section.
    footnotes.paddingTopPadding above footnote content.
    footnotes.borderTopTop border of the footnote section.
    footnotes.colorFootnote text color.
    footnotes.fontSizeFootnote font size.

    Syntax highlighting

    FieldMeaning
    syntax.commentComment color.
    syntax.keywordKeyword color.
    syntax.stringString color.
    syntax.numberNumeric literal color.
    syntax.functionFunction name color.
    syntax.variableVariable name color.
    syntax.punctuationPunctuation and delimiter color.
    syntax.insertedColor for inserted diff content.
    syntax.deletedColor for deleted diff content.

    Radii and spacing

    FieldMeaning
    radius.smSmall radius for inline code and compact controls.
    radius.mdMedium radius for containers such as blockquotes.
    radius.lgLarge radius for code blocks, images, and tables.
    spacing.xsExtra-small spacing.
    spacing.smSmall spacing.
    spacing.mdMedium spacing.
    spacing.lgLarge spacing.
    spacing.xlExtra-large spacing, used for list indentation and dividers.