• English
  • Styling guide

    Use a theme to match your app's colors, typography, and spacing, then use container styles for layout. For components and interactions, use slot plugins.

    Follow your app's theme

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

    The default theme is light. Fluxdown does not automatically follow the system theme; pass in your app's existing theme state.

    Adjust typography and color

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

    <Fluxdown
      text={text}
      theme={[
        'light',
        {
          tokens: {
            colors: { accent: '#567153' },
            typography: { fontSans: 'Inter, sans-serif' },
            heading: { h1: { fontSize: '2rem' } },
            paragraph: { marginBottom: '1rem' },
          },
        },
      ]}
    />

    Tokens cover colors, typography, headings, paragraph spacing, code highlighting, corner radii, and spacing. Passing a token object directly extends light; use ['dark', overrides] to extend the dark preset.

    Use className or style for the container's size and layout:

    <Fluxdown
      style={{
        maxWidth: '72ch',
        marginInline: 'auto',
      }}
      text={text}
    />

    See Configuration for all theme options. Formulas, footnotes, and other Markdown syntax switches are covered under build.

    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 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.