@halo-dev/shiki-code-element
v1.0.11
Published
[](https://www.npmjs.com/package/@halo-dev/shiki-code-element) [;
</code></pre>
</shiki-code>Customizing Themes
<shiki-code
light-theme="github-light"
dark-theme="github-dark">
<pre><code class="language-typescript">
interface User {
name: string;
age: number;
}
const user: User = {
name: "John",
age: 30
};
</code></pre>
</shiki-code>Mac Window Style
<shiki-code variant="mac">
<pre><code class="language-python">
def greet(name):
return f"Hello, {name}!"
print(greet("World"))
</code></pre>
</shiki-code>Code Highlighting Features
This component integrates with Shiki Transformers to provide advanced code highlighting features. The following transformers are supported:
- Line highlighting:
// [!code highlight] - Line focus:
// [!code focus] - Error/warning annotations:
// [!code error],// [!code warning] - Code diff (additions/deletions):
// [!code ++],// [!code --]
For more details on how to use these features, please refer to the Shiki Transformers documentation.
API
Properties
| Property | Attribute | Type | Default | Description | |--------------|---------------|---------------------|-----------------|---------------------------------------------------| | lightTheme | light-theme | string | "github-light" | Theme to use in light mode | | darkTheme | dark-theme | string | "github-dark" | Theme to use in dark mode | | variant | variant | "simple" | "mac" | "simple" | Visual style variant | | fontSize | font-size | string | "0.875em" | Font size for the code block |
Browser Support
This component works in all modern browsers that support Custom Elements v1 and Shadow DOM v1.
