Example#
@layer theme, base, mk, site, components, utilities;
@import "@maxgrits/overprint-react/css";
Usage#
Use a code block for code people read or copy: an install command, a component example, a config file. It prints in the code face, the one place the system uses a monospaced family (D-D9), with a header holding the file name, the language and a copy key.
- Highlighting runs where the code is built (the docs use Shiki's CSS-variables theme mapped to the
--mk-code-*roles); the component carries no highlighter. Passcodeas a string for plain text. - Options.
title(a file name),lineNumbers,highlightfor lines to mark,wrap(off by default: code scrolls sideways) andcopy(on by default). - Inline code in a sentence is a
codeelement insideProse, not a block.
Anatomy#
@layer theme, base, mk, site, components, utilities;
@import "@maxgrits/overprint-react/css";
- Header
data-mk-part="header" - File nameLabel role.
.mk-code-title - CodeA focusable region that scrolls sideways.
.mk-code-pre
Volume#
Reading layer: identical at every volume.
Quiet
app/globals.csscss @layer theme, base, mk, site, components, utilities; @import "@maxgrits/overprint-react/css";Studio
app/globals.csscss @layer theme, base, mk, site, components, utilities; @import "@maxgrits/overprint-react/css";Press
app/globals.csscss @layer theme, base, mk, site, components, utilities; @import "@maxgrits/overprint-react/css";Rave
app/globals.csscss @layer theme, base, mk, site, components, utilities; @import "@maxgrits/overprint-react/css";
Content#
- Show code that runs as written; mark a placeholder clearly, such as
YOUR_TOKEN. - One task per block; title it with the file it belongs in.
- Never put a real token, key or address in an example.
Do and don't#
Do
@import "@maxgrits/overprint-react/css";
Don't
export GITHUB_PACKAGES_TOKEN=ghp_a1b2c3d4e5f6
pnpm install
Accessibility#
- The scrolling
preis a focusable region named "{title}code". - The copy key says "Copied" for 2 s and announces it politely.
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
code | string | none | Plain source. |
children | ReactNode | none | Pre-highlighted tokens (or a `<code>` element) from the docs pipeline. |
lang | string | none | |
title | string | none | A file name. |
lineNumbers | boolean | none | |
highlight | readonly number[] | none | 1-based lines to mark. |
wrap | boolean | false | Default false: long lines scroll. |
copy | boolean | true | Default true. |
regionLabel | string | "Code" | The scroll region's name when there is no title (default "Code"). |
Tokens#
System tokens (19)
Changelog#
Arrived in 0.1.0.
Sectionwith its plate andArtslot,Plate,VolumeScope,PageHero,SectionHead,Eyebrow,Card,LineCard,InfoPanel,Stack,Cluster,Grid,Container,Main,Ruleand theFittedLineclient fitter;Navbarwith theNavDisclosuremega panels,Footer,FooterMap,BuildStamp,SkipLink,ActionDockandVisitorControls; theTableparts,ComparisonTablewith the one-tier switcher,SpecStrip,Numeral,Stat,StatGroup,StatusChip,BadgeandScoreDial;ProsewithmdxComponents,Quote,CodeBlockwithCopyButton,Figure,ScreenshotFrameandPhoneFrame; and the brand: the three evolved 2 × 2 options inmarkGeometry(a Overprint by default, b Paper seam, c Key block) with the pixel-snappedpxmode and the one-ink seam variant,logoGeometrywith the 1x clear-space frame,Mark,Wordmark,Logo,MaxosMarkandLineBadge. Read the whole entry- SegmentedControl, Tabs and CodeBlock draw LC-05's ring outside the focused key (2 px at 2 px) instead of inset; RadioGroup and CheckboxGroup keys and cards, VolumeDial stops and link Cards mark the element that draws the ring (
data-mk-focus-ring); a focusable VisuallyHidden draws the ring. Read the whole entry