Code

An inline code element for displaying code snippets with syntax-appropriate styling.

Anatomy

<script>
  import { Code } from "@saas-ui/svelte/typography/code";
</script>

<!-- Basic code -->
<Code>console.log("Hello")</Code>

<!-- With variant -->
<Code variant="solid">npm install</Code>

<!-- With size -->
<Code size="lg">const x = 42</Code>

Examples

Basic Accessibility

Basic inline code element with default styling for displaying code snippets.

Colours Accessibility

Use the colour prop to change the colour scheme. Supports all standard colour options.

Sizes Accessibility

Use the size prop to change the size of the code. Available sizes: xs, sm, md, lg.

Variants Accessibility

Use the variant prop to change the visual style. Available variants: solid, outline, subtle, surface.

Props

Prop Type Default Description
variant solid | outline | subtle | surface subtle -
size xs | sm | md | lg sm -
colour accent | gray | zinc | neutral | stone | slate | red | orange | amber | yellow | lime | green | emerald | teal | cyan | sky | blue | indigo | violet | purple | fuchsia | pink | rose gray The colour theme of the component.
children any - The content to be rendered inside the component.
class text - Additional CSS classes to apply.