SnowballSH Foundation UI

Code Block

Pick a framework. Both use the same recipe, so the styling matches exactly.

snowflake.rs
fn main() {
    let flakes = (0..6).map(|i| i * 60);
    println!("{:?}", flakes.collect::<Vec<_>>());
}
Code Block props for React
PropTypeDefaultDescription
codestringThe code to display.
labelstringFilename or caption shown above the code.

Also takes className and children. Anything else passes through to the figure.

code-block.demo.tsx
import { CodeBlock } from "../react/index.js";

const sample = `fn main() {
    let flakes = (0..6).map(|i| i * 60);
    println!("{:?}", flakes.collect::<Vec<_>>());
}`;

export default function CodeBlockDemo() {
  return <CodeBlock label="snowflake.rs" code={sample} />;
}