Copy Button
Default copy-to-clipboard button used by SyntaxHighlightedCode's copyButton slot.
Renders a simple ⧉ text icon inside an IconButton. Tint and size default to values that blend naturally with the code block background when placed inside a SyntaxHighlightedCode block.
Pass to copyButton to retain the default look while customising other parameters:
SyntaxHighlightedCode(
code = snippet,
language = "kotlin",
copyButton = { onClick ->
SyntaxHighlightedCodeDefaults.CopyButton(
onClick = onClick,
contentDescription = stringResource(R.string.copy_code_label),
)
},
)Parameters
Action invoked when the button is clicked. Wire this to the onClick parameter received from the copyButton slot.
Icon color. Defaults to LocalContentColor at 70 % opacity, which resolves correctly when inside a SyntaxHighlightedCode block.
Accessibility label for TalkBack and other assistive services. Provide a localized string for non-English users.
Width and height of the button touch target. Defaults to copyButtonSize.