Syntax Highlighted Code Defaults
Default values and helper composables used by SyntaxHighlightedCode and CodeBlockStyle.
Expose constants so callers can build on them without hard-coding magic numbers, and helper composables so callers can compose on top of the built-in defaults:
// Use the library default text style with only fontSize overridden
val myStyle = CodeBlockStyle(
textStyle = SyntaxHighlightedCodeDefaults.codeTextStyle.copy(fontSize = 15.sp),
)
// Start from Compact but widen the line-number gutter
val myCompact = CodeBlockStyle.Compact.copy(
lineNumberWidth = SyntaxHighlightedCodeDefaults.lineNumberWidth + 16.dp,
)
// Customise the copy button slot while keeping the default icon
SyntaxHighlightedCode(
code = snippet,
language = "kotlin",
copyButton = { onClick ->
SyntaxHighlightedCodeDefaults.CopyButton(
onClick = onClick,
contentDescription = stringResource(R.string.copy_code),
)
},
)Properties
Default TextStyle applied to the code text: monospace font, 13 sp size, 20 sp line height.
Default size (width and height) of the copy button.
Default background color used when the active theme CSS has no .hljs { background: ... } rule. Matches the dark background from the built-in tomorrow-night and atom-one-dark themes.
Default text color used when the active theme CSS has no .hljs { color: ... } rule. Provides readable light-gray text on the dark fallbackBackgroundColor.
Default padding for the header row (language label + copy button).
Default width reserved for the line-number gutter.
Default inner padding for the code content area.
Functions
Default copy-to-clipboard button used by SyntaxHighlightedCode's copyButton slot.
Default language badge used by SyntaxHighlightedCode's languageLabel slot.