Typix LogoTypix
Getting Started

Theming

Customize the editor appearance with theme classes

Typix uses Lexical's theming system — a mapping of editor elements to CSS class names. You provide CSS classes and Lexical applies them to the rendered DOM.

Default theme

Import the built-in theme:

import { defaultTheme } from '@typix-editor/react';

The default theme provides typix-* prefixed class names for all editor elements. You write the CSS that targets these classes.

Theme class reference

Text formats

KeyClassElement
text.boldtypix-text--boldBold text
text.italictypix-text--italicItalic text
text.underlinetypix-text--underlineUnderlined text
text.strikethroughtypix-text--strikethroughStrikethrough text
text.codetypix-text--codeInline code
text.highlighttypix-text--highlightHighlighted text
text.subscripttypix-text--subscriptSubscript text
text.superscripttypix-text--superscriptSuperscript text

Block elements

KeyClassElement
paragraphtypix-paragraphParagraph
heading.h1heading.h6typix-heading--h1typix-heading--h6Headings
quotetypix-quoteBlock quote
codetypix-codeCode block
linktypix-linkLink

Lists

KeyClassElement
list.ultypix-list--ulUnordered list
list.checklisttypix-checklistCheck list
list.listitemtypix-list__itemList item
list.listitemCheckedtypix-list__item--checkedChecked item
list.listitemUncheckedtypix-list__item--uncheckedUnchecked item

Tables

KeyClassElement
tabletypix-tableTable
tableCelltypix-table__cellTable cell
tableCellHeadertypix-table__cell--headerHeader cell
tableCellSelectedtypix-table__cell--selectedSelected cell

Custom theme

Create your own theme object or extend the default:

import { defaultTheme, createEditorConfig } from '@typix-editor/react';

const myTheme = {
  ...defaultTheme,
  paragraph: 'my-paragraph',
  heading: {
    h1: 'my-heading-1',
    h2: 'my-heading-2',
    h3: 'my-heading-3',
    h4: 'my-heading-4',
    h5: 'my-heading-5',
    h6: 'my-heading-6',
  },
  text: {
    ...defaultTheme.text,
    bold: 'my-bold',
  },
};

const config = createEditorConfig({
  theme: myTheme,
});

CSS example

Here's a minimal stylesheet targeting the default theme classes:

.typix-text--bold {
  font-weight: bold;
}

.typix-text--italic {
  font-style: italic;
}

.typix-text--underline {
  text-decoration: underline;
}

.typix-text--strikethrough {
  text-decoration: line-through;
}

.typix-text--code {
  background: #f4f4f5;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

.typix-heading--h1 {
  font-size: 2em;
  font-weight: bold;
}

.typix-heading--h2 {
  font-size: 1.5em;
  font-weight: bold;
}

.typix-quote {
  border-left: 4px solid #e4e4e7;
  padding-left: 1em;
  color: #71717a;
}

Tailwind CSS

If you use Tailwind, you can apply utility classes directly in the theme:

const tailwindTheme = {
  paragraph: 'mb-2',
  heading: {
    h1: 'text-4xl font-bold mb-4',
    h2: 'text-3xl font-bold mb-3',
    h3: 'text-2xl font-bold mb-2',
  },
  text: {
    bold: 'font-bold',
    italic: 'italic',
    underline: 'underline',
    strikethrough: 'line-through',
    code: 'bg-zinc-100 px-1 rounded font-mono text-sm',
  },
  quote: 'border-l-4 border-zinc-300 pl-4 text-zinc-500',
  link: 'text-blue-600 underline hover:text-blue-800',
};

On this page