Copy Button
Default copy-to-clipboard button used by SyntaxHighlightedCode's copyButton slot.
Renders a vector copy icon inside an IconButton. The icon size scales proportionally to the button size (60 % of the touch target) so that callers who customize the button size get a matching icon automatically. 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.
Modifier applied to the root IconButton. Use this for padding, test tags, or other positioning/customisation.
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.