cssBuilder property

String Function(String css, ThemeData themeData)? cssBuilder
final

Used to build custom CSS code for the editor.

Should return a String containing valid CSS code.

The default builder uses the current ThemeData to ensure the editor is always displayed correctly.

If you need to use a custom CSS or add your own styles, you can provide a custom builder. The builder provides the current CSS string used and the current ThemeData. So you can append or prepend your CSS to your liking.

Example of appending custom CSS:

HtmlEditorField(
  cssBuilder: (css, themeData) => [
    css,
    CssBuilder.elementCss(
      selector: '.note-editable',
      style: {
        'color': CssBuilder.hexFromColor(color: themeData.colorScheme.onSurface),
        'background-color': CssBuilder.hexFromColor(color: themeData.colorScheme.surface),
      },
    ),
  ].join(),
)

Implementation

final String Function(String css, ThemeData themeData)? cssBuilder;