Component reference
Code & Kbd
Inline technical values and shortcut notation.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
Shortcuts
A compact keyboard reference.
Terminal
A block is the right surface for a command.
$ pnpm install
$ pnpm build:all
$ pnpm "playground dev"Width adapts to the available space
"use client";
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
Text,
Kbd,
Code
} from "@pimolu/react";
export function DemoExample() {
return (
<div
className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))] gap-6 min-w-0 items-start"
>
<Card>
<CardHeader>
<CardTitle>Shortcuts</CardTitle>
<CardDescription>A compact keyboard reference.</CardDescription>
</CardHeader>
<CardContent>
<div className="grid gap-5 min-w-0">
{
[
["Command palette", ["Cmd", "K"]],
["Search", ["/"]],
["Save", ["Ctrl", "S"]],
["Close", ["Esc"]],
].map(([label, keys]) => (<div
key={label as string}
className="flex flex-wrap items-center gap-3 min-w-0 justify-between"
>
<Text size="sm">
{label as string}
</Text>
<span className="flex flex-wrap items-center gap-3 min-w-0">
{
(keys as string[]).map((key) => (<Kbd key={key}>
{key}
</Kbd>))
}
</span>
</div>))
}
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Terminal</CardTitle>
<CardDescription>A block is the right surface for a command.</CardDescription>
</CardHeader>
<CardContent>
<Code block>
{
`$ pnpm install
$ pnpm build:all
$ pnpm "playground dev"`
}
</Code>
</CardContent>
</Card>
</div>
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Inline
Code sits inside a paragraph without breaking its rhythm.
Block
block wraps the code in a preformatted surface with horizontal scrolling.
Keyboard
Kbd names a physical key; combine several keys in a row.
Usage
Use Code for short fragments and Kbd for keys; neither registers a keyboard shortcut.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluCodeProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
block | boolean | undefined | false | Render a preformatted block instead of an inline fragment. |
size | "sm" | "md" | "lg" | undefined | "sm" | Relative font size. Defaults to "sm". |
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
onChange | ChangeEventHandler<HTMLElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLElement> | undefined | — | Standard React/HTML attribute. |
blockboolean | undefinedDefault: false
Render a preformatted block instead of an inline fragment.
size"sm" | "md" | "lg" | undefinedDefault: "sm"
Relative font size. Defaults to "sm".
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
onChangeChangeEventHandler<HTMLElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLElement> | undefinedNo default extracted.
Standard React/HTML attribute.
PimoluKbdProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
size | "sm" | "md" | "lg" | undefined | "sm" | Relative font size. Defaults to "sm". |
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
onChange | ChangeEventHandler<HTMLElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLElement> | undefined | — | Standard React/HTML attribute. |
size"sm" | "md" | "lg" | undefinedDefault: "sm"
Relative font size. Defaults to "sm".
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
onChangeChangeEventHandler<HTMLElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLElement> | undefinedNo default extracted.
Standard React/HTML attribute.
Accessibility
- Explain shortcuts in readable text and avoid depending on punctuation alone.