Styling - Fluid Topics - Latest

Add Copy-to-Clipboard Button in Codeblocks

Category
How To
Audience
public
Version
Latest

To style copy-to-clipboard codeblocks, use the following CSS properties:

Variable name Description
--ft-button-background-color
Sets copy block button's background color.
--ft-button-color
Sets copy block button's color.
--ft-button-icon-size
Sets copy block button's icon size.
--ft-copy-block-background-color
Sets copy block's background color.
--ft-copy-block-border-color
Sets copy block's border color.
--ft-copy-block-border-radius
Sets copy block's border radius.
--ft-copy-block-border-style
Sets copy block's border style.
--ft-copy-block-border-width
Sets copy block's border width.
--ft-copy-block-button-height
Sets copy block button's height.
--ft-copy-block-spacing
Sets copy block's spacing between elements.

For example:

  1. Add the following example to a Markdown document:

    <ft-copy-block>console.log("Hello world!")</ft-copy-block>
    
  2. Publish the Markdown document.

  3. Add the following example to the portal's Content styles:

    ft-copy-block {
      font-family: monospace, monospace;
      --ft-button-background-color: transparent;
      --ft-button-color: indigo;
      --ft-copy-block-background-color: rgb(230, 230, 234);
      --ft-copy-block-border-color: indigo;
      --ft-copy-block-border-style: dotted;
      --ft-copy-block-border-width: 5px;
    }
    

This styling results in the following example:

console.log("Hello world!")