Header

fun Header(languageLabel: @Composable () -> Unit?, actions: @Composable RowScope.(onCopy: () -> Unit) -> Unit?, onCopy: () -> Unit, modifier: Modifier = Modifier, padding: PaddingValues = headerPadding)

Default header layout used by SyntaxHighlightedCode's header slot: the language label on the left, the trailing actions on the right.

Pass to header to retain the default layout while customising individual pieces via languageLabel and actions, or call it directly from a custom header slot:

SyntaxHighlightedCode(
code = snippet,
language = "kotlin",
header = { onCopy ->
SyntaxHighlightedCodeDefaults.Header(
languageLabel = { SyntaxHighlightedCodeDefaults.LanguageLabel("kotlin") },
actions = { copy -> SyntaxHighlightedCodeDefaults.CopyButton(onClick = copy) },
onCopy = onCopy,
padding = PaddingValues(horizontal = 24.dp, vertical = 12.dp),
)
},
)

Nothing is rendered when both languageLabel and actions are null.

Parameters

languageLabel

Optional composable rendered on the left side of the row.

actions

Optional trailing actions rendered on the right side of the row, laid out with RowScope. Receives the pre-wired copy action to forward to copy buttons.

onCopy

Copy action forwarded to actions. Wire this to any copy button's onClick.

modifier

Modifier applied to the root Row. Use this for background, test tags, or other positioning/customisation.

padding

Padding applied around the header row. Defaults to headerPadding.