This guide shows how to make code samples stand out better in the Nimbus documentation.
All code blocks now have:
- Better borders and shadows for visual separation
- Improved spacing (margin top/bottom)
- Enhanced padding inside code blocks
- Better dark mode support
- Distinct styling for inline code vs code blocks
A new reusable component for code samples with titles.
Just use regular markdown code fences - they'll automatically get enhanced styling:
```csharp
var bus = new BusBuilder()
.Configure()
.Build();
\```This will render with:
- Border and shadow
- Better padding (p-4)
- Nice background colors (light/dark mode)
- 6-unit vertical spacing
For code that needs a descriptive title:
import CodeBlock from '@components/ui/CodeBlock.astro';
<CodeBlock title="Configure Azure Service Bus Transport">
```csharp
var transport = new AzureServiceBusTransportConfiguration()
.WithConnectionString(azureConnectionString)
.WithDefaultTimeout(TimeSpan.FromSeconds(30));
\```
</CodeBlock>This adds:
- A header bar with title
- Code icon
- Language indicator
- Better visual hierarchy
Inline code like IBusCommand automatically gets:
- Pink/rose color highlighting
- Subtle background
- Proper padding
Use the CodeBlock component when:
- The code needs context (configuration examples, setup steps)
- You want to emphasize important code
- Multiple related code blocks need clear separation
Use standard markdown code blocks when:
- Simple, self-explanatory snippets
- Code within lists or callouts
- Quick examples that don't need titles
See updated examples in:
src/content/docs/transports.mdx- Lines 87-139 show CodeBlock usage- Any
.mdxfile will automatically get enhanced styling for standard code blocks
The CSS now provides:
my-6(1.5rem top/bottom) for code blocksmy-4for code in listsmt-8for headings after code (better section separation)mt-4for code after headings (tighter coupling)
All code styling automatically adapts to dark mode:
- Light mode: gray-50 background with gray-200 borders
- Dark mode: gray-900 background with gray-800 borders
- Syntax highlighting themes switch automatically (via Shiki config)
To improve existing documentation:
-
Import the CodeBlock component at the top of your
.mdxfile:import CodeBlock from '@components/ui/CodeBlock.astro'; -
Wrap important code samples:
<CodeBlock title="Your descriptive title"> ```language // your code \``` </CodeBlock> -
Standard code blocks will automatically get enhanced styling - no changes needed!