New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@leafygreen-ui/code

Package Overview
Dependencies
Maintainers
3
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafygreen-ui/code

leafyGreen UI Kit Code Blocks

  • 3.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35K
decreased by-46.44%
Maintainers
3
Weekly downloads
 
Created
Source

Code

npm (scoped)

Usage

npm install @leafygreen-ui/code

Example

import Code from '@leafygreen-ui/code';

const codeSnippet = `
function greeting(entity) {
  return \`Hello, \${entity}!\`;
}

console.log(greeting('World'));
`;

const SomeComponent = () => <Code>{codeSnippet}</Code>;

Output HTML

<pre class="leafygreen-ui-5u6rr1">
	<code class="lg-highlight-hljs-light leafygreen-ui-16k3j4z">
		<span class="lg-highlight-function">
			<span class="lg-highlight-keyword">function</span>

			<span class="lg-highlight-title">greeting</span>
			(
			<span class="lg-highlight-params">entity</span>
			)
		</span>
		{
		<span class="lg-highlight-keyword">return</span>

		<span class="lg-highlight-string">
			`Hello, <span class="lg-highlight-subst">${entity}</span>!`
		</span>;
		}
		<span class="lg-highlight-built_in">console</span>
		.log(greeting(
		<span class="lg-highlight-string">'World'</span>));
	</code>
</pre>

Properties

PropTypeDescriptionDefault
childrenstringRequired This is the code snippet that will be rendered in the code block.''
multilinebooleanThis prop determines whether or not the code snippet will visually retain line breaks when rendered.true
lang'javascript', 'typescript', 'csp', 'cpp', 'go', 'java', 'perl', 'php', 'python', 'ruby', 'scala', 'swift', 'bash', 'shell', 'sql', 'yaml', 'json', 'auto', 'none'The language to render the code block as. When set to 'none', no syntax highlighting will be applied. When set to 'auto', the component will attempt to do its best to guess what language the code snippet is.'auto'
variant'dark', 'light'Determines whether to use a light or dark highlighting palette.'light'
classNamestringApplies a className to the root element's classList.
showLineNumbersbooleanShows line numbers next to each line of code in the passed code snippet. NOTE: While you can set this to true regardless of the code component being multiline, the line numbers will not be displayed if the multiline prop is true.false
showWindowChromebooleanShows a stylized window chrome frame around the code snippet. This is purely stylistic.false
chromeTitlestringShows a filename-like title in the window chrome frame.NOTE: While you can set this prop if showWindowChrome is false, it will not be displayed unless the showWindowChrome prop is true.''

FAQs

Package last updated on 08 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc