Honest Prose
Style rendered Markdown and plain HTML with one class, in any project, including text that is still streaming.
Use the panel below the preview to adjust typography or start from the Chat, Document, and Compact presets. Advanced options override theme colors and code styling. Reset restores the Chat preset and theme defaults. Choose CSS or Tailwind under Export, then copy the current settings. Text width is measured in ch, approximately the width of the font's zero character.
Overview
Prose styles rendered Markdown and plain HTML. Use the honest-prose class with its stylesheet, or install the Tailwind utilities to get the styles without another CSS file.
It is plain CSS, so it works with any Markdown renderer and in a project without React or Tailwind. In an Honest UI project it reads the theme's tokens. Anywhere else it falls back to values based on the text color around it, so it follows your light and dark themes.
Markdown and Streaming Text use it for their text.
Installation
Tailwind v4, without a separate stylesheet
This copies lib/prose-tailwind.ts, with no package or stylesheet dependencies. Your project needs Tailwind v4 already configured.
import { proseTailwind } from "@/lib/prose-tailwind"
<article className={proseTailwind}>
<h2>Release checklist</h2>
<p>The export fix is ready.</p>
</article>The utilities use the same --prose-* variables and not-prose opt-out as the stylesheet. Set customized variables with an inline style, or choose Tailwind in the playground and paste the copied classes directly into your template.
Keep the installed file and any pasted classes inside Tailwind's source scan. If your lib folder is excluded, add @source "../lib/prose-tailwind.ts"; to your existing Tailwind stylesheet, adjusting the path. Tailwind cannot discover class names assembled from values at runtime; copy the generated classes into source or use proseTailwind with inline variables.
The generated utilities use Tailwind's important modifier so theme element rules cannot override them. Customize with the variables. Tailwind v3 is not supported by this install option.
// Generated from registry/styles/prose.css by npm run prose:generate.
// Tailwind v4: keep this file inside your source scan. No extra stylesheet is needed.
/** Complete prose styles. Customize with the --prose-* variables. */
export const proseTailwind = [
"[--prose-internal-size:var(--prose-size,var(--hui-font-size-regular,1em))]!",
"[--prose-internal-leading:var(--prose-leading,1.6)]!",
"[--prose-internal-flow:var(--prose-flow,var(--hui-space-4,0.85em))]!",
"[--prose-internal-heading:var(--prose-heading,1.143em)]!",
"[--prose-internal-color:var(--prose-color,var(--hui-color-foreground-base-primary,currentColor))]!",
"[--prose-internal-muted:var(--prose-muted,var(--hui-color-foreground-base-secondary,color-mix(in_oklab,currentColor_72%,transparent)))]!",
"[--prose-internal-surface:var(--prose-surface,var(--hui-color-background-base-secondary,color-mix(in_oklab,currentColor_5%,transparent)))]!",
"[--prose-internal-rule:var(--prose-rule,var(--hui-color-border-base-primary,color-mix(in_oklab,currentColor_18%,transparent)))]!",
"[--prose-internal-rule-strong:var(--prose-rule-strong,var(--hui-color-border-base-secondary,color-mix(in_oklab,currentColor_34%,transparent)))]!",
"[--prose-internal-font-mono:var(--prose-font-mono,var(--hui-font-mono,ui-monospace,SFMono-Regular,Menlo,Consolas,monospace))]!",
"[--prose-internal-radius:var(--prose-radius,var(--hui-radius-1,0.25em))]!",
"[--prose-internal-radius-block:var(--hui-radius-code-block,calc(var(--prose-internal-radius)_+_0.25rem))]!",
"[--prose-internal-hairline:var(--hui-border-width-surface,1px)]!",
"[min-width:0]!",
"[max-width:var(--prose-width,none)]!",
"[overflow-wrap:break-word]!",
"[color:var(--prose-internal-color)]!",
"[font-size:var(--prose-internal-size)]!",
"[line-height:var(--prose-internal-leading)]!",
"[letter-spacing:var(--prose-tracking,var(--hui-letter-spacing-regular,normal))]!",
"[&_:where(p,ul,ol,dl,blockquote,pre,table,figure,details,hr,.prose-scroll,.not-prose):not(:where(.not-prose_*))]:[margin-block:var(--prose-internal-flow)_0]!",
"[&_:where(p,ul,ol,dl,blockquote,pre,figure):not(:where(.not-prose,.not-prose_*))]:[margin-inline:0]!",
"[&_:where(h1,h2,h3,h4,h5,h6):not(:where(.not-prose,.not-prose_*))]:[margin-block:calc(var(--prose-internal-flow)_*_1.667)_0]!",
"[&_:where(h1,h2,h3,h4,h5,h6):not(:where(.not-prose,.not-prose_*))]:[text-wrap:balance]!",
"[&_:is(h1,h2,h3,h4,h5,h6):not(:where(.not-prose,.not-prose_*))]:[font-family:inherit]!",
"[&_:is(h1,h2,h3,h4,h5,h6):not(:where(.not-prose,.not-prose_*))]:[font-size:1em]!",
"[&_:is(h1,h2,h3,h4,h5,h6):not(:where(.not-prose,.not-prose_*))]:[font-weight:var(--hui-font-weight-semibold,600)]!",
"[&_:is(h1,h2,h3,h4,h5,h6):not(:where(.not-prose,.not-prose_*))]:[line-height:1.43]!",
"[&_:is(h1,h2,h3,h4,h5,h6):not(:where(.not-prose,.not-prose_*))]:[letter-spacing:inherit]!",
"[&&_:is(h1,h2):not(:where(.not-prose,.not-prose_*))]:[font-size:var(--prose-internal-heading)]!",
"[&&_:is(h1,h2):not(:where(.not-prose,.not-prose_*))]:[line-height:1.375]!",
"[&&_:is(h1,h2):not(:where(.not-prose,.not-prose_*))]:[letter-spacing:var(--hui-letter-spacing-large,-0.011em)]!",
"[&&_:where(h1,h2,h3,h4,h5,h6):not(:where(.not-prose,.not-prose_*))_+_*]:[margin-block-start:calc(var(--prose-internal-flow)_*_0.667)]!",
"[&_:where(a):not(:where(.not-prose,.not-prose_*))]:[color:inherit]!",
"[&_:where(a):not(:where(.not-prose,.not-prose_*))]:[text-decoration-line:underline]!",
"[&_:where(a):not(:where(.not-prose,.not-prose_*))]:[text-decoration-thickness:max(1px,0.0625em)]!",
"[&_:where(a):not(:where(.not-prose,.not-prose_*))]:[text-decoration-color:color-mix(in_oklab,currentColor_50%,transparent)]!",
"[&_:where(a):not(:where(.not-prose,.not-prose_*))]:[text-underline-offset:0.2em]!",
"[&&_:where(a:hover):not(:where(.not-prose,.not-prose_*))]:[text-decoration-color:currentColor]!",
"[&_:where(strong,b):not(:where(.not-prose,.not-prose_*))]:[font-weight:var(--hui-font-weight-semibold,600)]!",
"[&_:where(sub,sup):not(:where(.not-prose,.not-prose_*))]:[line-height:0]!",
"[&_:where(pre,code,kbd,samp):not(:where(.not-prose,.not-prose_*))]:[font-family:var(--prose-internal-font-mono)]!",
"[&_:where(pre,code,kbd,samp):not(:where(.not-prose,.not-prose_*))]:[font-variant-ligatures:none]!",
"[&_:where(pre,code,kbd,samp):not(:where(.not-prose,.not-prose_*))]:[letter-spacing:0]!",
"[&_:where(h1,h2,h3,h4,h5,h6)_:where(code):not(:where(.not-prose,.not-prose_*))]:[font-weight:var(--hui-font-weight-medium,500)]!",
"[&_:where(:not(pre)_>_code,kbd,samp):not(:where(.not-prose,.not-prose_*))]:[font-size:0.857em]!",
"[&_:where(:not(pre)_>_code,kbd):not(:where(.not-prose,.not-prose_*))]:[border:var(--prose-internal-hairline)_solid_var(--prose-internal-rule)]!",
"[&_:where(:not(pre)_>_code,kbd):not(:where(.not-prose,.not-prose_*))]:[border-radius:var(--prose-internal-radius)]!",
"[&_:where(:not(pre)_>_code,kbd):not(:where(.not-prose,.not-prose_*))]:[background:var(--hui-color-background-base-primary,color-mix(in_oklab,currentColor_4%,transparent))]!",
"[&_:where(:not(pre)_>_code,kbd):not(:where(.not-prose,.not-prose_*))]:[padding:0.1em_0.35em]!",
"[&_:where(:not(pre)_>_code,kbd):not(:where(.not-prose,.not-prose_*))]:[-webkit-box-decoration-break:clone]!",
"[&_:where(:not(pre)_>_code,kbd):not(:where(.not-prose,.not-prose_*))]:[box-decoration-break:clone]!",
"[&_:where(:not(pre)_>_code):not(:where(.not-prose,.not-prose_*))]:[color:var(--prose-code-color,inherit)]!",
"[&&_:where(kbd):not(:where(.not-prose,.not-prose_*))]:[box-shadow:inset_0_-1px_0_var(--prose-internal-rule-strong)]!",
"[&_:where(ul,ol):not(:where(.not-prose,.not-prose_*))]:[padding-inline-start:1.6em]!",
"[&_:where(ul):not(:where(.not-prose,.not-prose_*))]:[list-style:disc]!",
"[&_:where(ol):not(:where(.not-prose,.not-prose_*))]:[list-style:decimal]!",
"[&&_:where(ul_ul):not(:where(.not-prose,.not-prose_*))]:[list-style:circle]!",
"[&_:where(li):not(:where(.not-prose,.not-prose_*))::marker]:[color:var(--prose-internal-muted)]!",
"[&_:where(li):not(:where(.not-prose,.not-prose_*))::marker]:[font-variant-numeric:normal]!",
"[&_:where(li):not(:where(.not-prose,.not-prose_*))]:[margin-block:calc(var(--prose-internal-flow)_/_3)_0]!",
"[&&_:where(li)_>_:where(ul,ol):not(:where(.not-prose,.not-prose_*))]:[margin-block-start:calc(var(--prose-internal-flow)_/_3)]!",
"[&&_:where(li_>_p_+_p):not(:where(.not-prose,.not-prose_*))]:[margin-block-start:calc(var(--prose-internal-flow)_/_2)]!",
"[&&_:where(li:has(>_:is(p,pre,blockquote,figure,table,div,dl))_+_li):not(:where(.not-prose,.not-prose_*))]:[margin-block-start:var(--prose-internal-flow)]!",
"[&_:where(li.task-list-item):not(:where(.not-prose,.not-prose_*))]:[position:relative]!",
"[&_:where(li.task-list-item):not(:where(.not-prose,.not-prose_*))]:[list-style:none]!",
"[&&&_:where(li.task-list-item_>_:first-child:is(input,[data-slot=markdown-task-mark]),li.task-list-item_>_p:first-child_>_:first-child:is(input,[data-slot=markdown-task-mark])):not(:where(.not-prose,.not-prose_*))]:[position:absolute]!",
"[&&&_:where(li.task-list-item_>_:first-child:is(input,[data-slot=markdown-task-mark]),li.task-list-item_>_p:first-child_>_:first-child:is(input,[data-slot=markdown-task-mark])):not(:where(.not-prose,.not-prose_*))]:[inset-inline-start:-1.6em]!",
"[&&&_:where(li.task-list-item_>_:first-child:is(input,[data-slot=markdown-task-mark]),li.task-list-item_>_p:first-child_>_:first-child:is(input,[data-slot=markdown-task-mark])):not(:where(.not-prose,.not-prose_*))]:[inset-block-start:calc(var(--prose-internal-leading)_*_0.5em)]!",
"[&&&_:where(li.task-list-item_>_:first-child:is(input,[data-slot=markdown-task-mark]),li.task-list-item_>_p:first-child_>_:first-child:is(input,[data-slot=markdown-task-mark])):not(:where(.not-prose,.not-prose_*))]:[translate:0_-50%]!",
"[&&&_:where(li.task-list-item_>_:first-child:is(input,[data-slot=markdown-task-mark]),li.task-list-item_>_p:first-child_>_:first-child:is(input,[data-slot=markdown-task-mark])):not(:where(.not-prose,.not-prose_*))]:[margin:0]!",
"[&&&_:where(li.task-list-item_>_:first-child:is(input,[data-slot=markdown-task-mark]),li.task-list-item_>_p:first-child_>_:first-child:is(input,[data-slot=markdown-task-mark])):not(:where(.not-prose,.not-prose_*))]:[font-size:inherit]!",
"[&_:where(dt):not(:where(.not-prose,.not-prose_*))]:[font-weight:var(--hui-font-weight-medium,500)]!",
"[&_:where(dd):not(:where(.not-prose,.not-prose_*))]:[margin:0]!",
"[&_:where(dd):not(:where(.not-prose,.not-prose_*))]:[color:var(--prose-internal-muted)]!",
"[&&_:where(dd_+_dt):not(:where(.not-prose,.not-prose_*))]:[margin-block-start:calc(var(--prose-internal-flow)_*_0.667)]!",
"[&_:where(blockquote):not(:where(.not-prose,.not-prose_*))]:[border-inline-start:2px_solid_var(--prose-internal-rule-strong)]!",
"[&_:where(blockquote):not(:where(.not-prose,.not-prose_*))]:[padding-inline-start:var(--prose-internal-flow)]!",
"[&_:where(blockquote):not(:where(.not-prose,.not-prose_*))]:[color:var(--prose-internal-muted)]!",
"[&&_:where(hr):not(:where(.not-prose,.not-prose_*))]:[margin-block-start:calc(var(--prose-internal-flow)_*_1.333)]!",
"[&&_:where(hr):not(:where(.not-prose,.not-prose_*))]:[border:0]!",
"[&&&_:where(hr):not(:where(.not-prose,.not-prose_*))]:[border-block-start:var(--prose-internal-hairline)_solid_var(--prose-internal-rule)]!",
"[&&_:where(hr):not(:where(.not-prose,.not-prose_*))]:[height:0]!",
"[&&_:where(hr):not(:where(.not-prose,.not-prose_*))]:[color:inherit]!",
"[&&_:where(hr):not(:where(.not-prose,.not-prose_*))_+_:where(:not(h1,h2,h3,h4,h5,h6))]:[margin-block-start:calc(var(--prose-internal-flow)_*_1.333)]!",
"[&_:where(pre):not(:where(.not-prose,.not-prose_*))]:[overflow-x:auto]!",
"[&_:where(pre):not(:where(.not-prose,.not-prose_*))]:[border:var(--prose-internal-hairline)_solid_var(--prose-internal-rule)]!",
"[&_:where(pre):not(:where(.not-prose,.not-prose_*))]:[border-radius:var(--prose-internal-radius-block)]!",
"[&_:where(pre):not(:where(.not-prose,.not-prose_*))]:[background:var(--prose-internal-surface)]!",
"[&_:where(pre):not(:where(.not-prose,.not-prose_*))]:[padding:0.857em_1.143em]!",
"[&_:where(pre):not(:where(.not-prose,.not-prose_*))]:[tab-size:2]!",
"[&_:where(pre_>_code):not(:where(.not-prose,.not-prose_*))]:[display:block]!",
"[&_:where(pre_>_code):not(:where(.not-prose,.not-prose_*))]:[font-size:0.857em]!",
"[&_:where(pre_>_code):not(:where(.not-prose,.not-prose_*))]:[line-height:1.667]!",
"[&&_:where(pre:not(:has(>_code))):not(:where(.not-prose,.not-prose_*))]:[padding:1em_1.333em]!",
"[&&_:where(pre:not(:has(>_code))):not(:where(.not-prose,.not-prose_*))]:[font-size:0.857em]!",
"[&&_:where(pre:not(:has(>_code))):not(:where(.not-prose,.not-prose_*))]:[line-height:1.667]!",
"[&_:where(.prose-scroll):not(:where(.not-prose,.not-prose_*))]:[overflow-x:auto]!",
"[&_:where(table):not(:where(.not-prose,.not-prose_*))]:[width:100%]!",
"[&_:where(table):not(:where(.not-prose,.not-prose_*))]:[border:var(--prose-internal-hairline)_solid_var(--prose-internal-rule)]!",
"[&_:where(table):not(:where(.not-prose,.not-prose_*))]:[border-collapse:separate]!",
"[&_:where(table):not(:where(.not-prose,.not-prose_*))]:[border-spacing:0]!",
"[&_:where(table):not(:where(.not-prose,.not-prose_*))]:[border-radius:var(--prose-internal-radius-block)]!",
"[&&_:where(.prose-scroll)_>_:where(table):not(:where(.not-prose,.not-prose_*))]:[margin-block-start:0]!",
"[&_:where(th,td):not(:where(.not-prose,.not-prose_*))]:[padding:calc(var(--prose-internal-flow)_*_0.667)_var(--prose-internal-flow)]!",
"[&_:where(th,td):not(:where(.not-prose,.not-prose_*))]:[vertical-align:top]!",
"[&_:where(th:not([align]),td:not([align])):not(:where(.not-prose,.not-prose_*))]:[text-align:start]",
"[&_:where(th):not(:where(.not-prose,.not-prose_*))]:[font-weight:var(--hui-font-weight-medium,500)]!",
"[&_:where(thead_th):not(:where(.not-prose,.not-prose_*))]:[background:var(--prose-internal-surface)]!",
"[&_:where(thead_th):not(:where(.not-prose,.not-prose_*))]:[color:var(--prose-internal-muted)]!",
"[&&&_:where(thead_>_tr:first-child_>_th:first-child):not(:where(.not-prose,.not-prose_*))]:[border-start-start-radius:calc(var(--prose-internal-radius-block)_-_var(--prose-internal-hairline))]!",
"[&&&_:where(thead_>_tr:first-child_>_th:last-child):not(:where(.not-prose,.not-prose_*))]:[border-start-end-radius:calc(var(--prose-internal-radius-block)_-_var(--prose-internal-hairline))]!",
"[&&&&_:where(:is(tbody,tfoot)_>_tr_+_tr_>_*,:is(thead,tbody)_+_:is(tbody,tfoot)_>_tr:first-child_>_*):not(:where(.not-prose,.not-prose_*))]:[border-block-start:var(--prose-internal-hairline)_solid_var(--prose-internal-rule)]!",
"[&_:where(img,video):not(:where(.not-prose,.not-prose_*))]:[max-width:100%]!",
"[&_:where(img,video):not(:where(.not-prose,.not-prose_*))]:[height:auto]!",
"[&_:where(figcaption):not(:where(.not-prose,.not-prose_*))]:[margin-block-start:calc(var(--prose-internal-flow)_/_2)]!",
"[&_:where(figcaption):not(:where(.not-prose,.not-prose_*))]:[color:var(--prose-internal-muted)]!",
"[&_:where(figcaption):not(:where(.not-prose,.not-prose_*))]:[font-size:calc(1em_*_6_/_7)]!",
"[&_:where([data-footnotes]):not(:where(.not-prose,.not-prose_*))]:[margin-block-start:calc(var(--prose-internal-flow)_*_1.333)]!",
"[&&_:where([data-footnotes]):not(:where(.not-prose,.not-prose_*))]:[border-block-start:var(--prose-internal-hairline)_solid_var(--prose-internal-rule)]!",
"[&_:where([data-footnotes]):not(:where(.not-prose,.not-prose_*))]:[padding-block-start:calc(var(--prose-internal-flow)_/_3)]!",
"[&_:where([data-footnotes]):not(:where(.not-prose,.not-prose_*))]:[color:var(--prose-internal-muted)]!",
"[&_:where([data-footnotes]):not(:where(.not-prose,.not-prose_*))]:[font-size:calc(1em_*_6_/_7)]!",
"[&&_:where(blockquote,dd,figcaption,thead_th,[data-footnotes])_:where(blockquote,dd,figcaption,th):not(:where(.not-prose,.not-prose_*))]:[color:inherit]!",
"[&&_:where(blockquote,dd,figcaption,[data-footnotes])_:where(li):not(:where(.not-prose,.not-prose_*))::marker]:[color:inherit]!",
"[&&&_>_:where(:first-child)]:[margin-block-start:0]!",
"[&&&_:where(blockquote,td,th,dd,figure,ul,ol,[data-footnotes])_>_:where(:first-child):not(:where(.not-prose_*))]:[margin-block-start:0]!",
"[&&&_:where(li)_>_:where(p,h1,h2,h3,h4,h5,h6):first-child:not(:where(.not-prose_*))]:[margin-block-start:0]!",
].join(" ")
/** Static classes for copying into a template; paste the result into scanned source. */
export function proseTailwindClasses(settings: Record<string, string> = {}) {
const variables = Object.entries(settings).map(([name, value]) => {
if (!/^--prose-[a-z-]+$/.test(name) || /[;{}\[\]\\]/.test(value)) {
throw new Error("Invalid prose setting.")
}
return `[${name}:${value.replaceAll("_", "\\_").replace(/\s+/g, "_")}]`
})
return [proseTailwind, ...variables].join(" ")
}
Standalone CSS
Or copy it into styles/prose.css yourself:
/*
* Prose styles rendered Markdown and plain HTML: put `class="honest-prose"` on
* the element that wraps it. It is plain CSS and needs no build step.
*
* Set these on `.honest-prose`, or on any ancestor, to change it:
*
* --prose-size Body text size.
* --prose-width Maximum text width.
* --prose-leading Body line height, as a number.
* --prose-flow Space between blocks.
* --prose-heading Size of first- and second-level headings.
* --prose-tracking Body letter spacing.
* --prose-color, --prose-muted, --prose-surface,
* --prose-rule, --prose-rule-strong
* --prose-font-mono, --prose-radius, --prose-code-color
*
* Each one falls back to an Honest UI token, then to a value that works with
* no tokens at all. Prose never sets them itself, so a value from a utility
* class or an inline style always applies.
*
* Add `class="not-prose"` to anything inside that brings its own styles,
* such as a component. It keeps its place in the flow and nothing else.
*
* Blocks are spaced with a top margin only, and no rule depends on what comes
* after an element, so text that is still arriving does not move what is
* already on screen.
*/
.honest-prose {
--_size: var(--prose-size, var(--hui-font-size-regular, 1em));
--_leading: var(--prose-leading, 1.6);
--_flow: var(--prose-flow, var(--hui-space-4, 0.85em));
--_heading: var(--prose-heading, 1.143em);
--_color: var(--prose-color, var(--hui-color-foreground-base-primary, currentColor));
--_muted: var(
--prose-muted,
var(--hui-color-foreground-base-secondary, color-mix(in oklab, currentColor 72%, transparent))
);
/* A step off the page, for code blocks and the table header band. */
--_surface: var(
--prose-surface,
var(--hui-color-background-base-secondary, color-mix(in oklab, currentColor 5%, transparent))
);
--_rule: var(
--prose-rule,
var(--hui-color-border-base-primary, color-mix(in oklab, currentColor 18%, transparent))
);
--_rule-strong: var(
--prose-rule-strong,
var(--hui-color-border-base-secondary, color-mix(in oklab, currentColor 34%, transparent))
);
--_font-mono: var(
--prose-font-mono,
var(--hui-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)
);
--_radius: var(--prose-radius, var(--hui-radius-1, 0.25em));
/* Code blocks and tables share one frame radius. */
--_radius-block: var(--hui-radius-code-block, calc(var(--_radius) + 0.25rem));
/* A half-pixel line fades at 1x, so without tokens lines are a full pixel. */
--_hairline: var(--hui-border-width-surface, 1px);
min-width: 0;
max-width: var(--prose-width, none);
overflow-wrap: break-word;
color: var(--_color);
font-size: var(--_size);
line-height: var(--_leading);
letter-spacing: var(--prose-tracking, var(--hui-letter-spacing-regular, normal));
}
/* Flow */
.honest-prose
:where(p, ul, ol, dl, blockquote, pre, table, figure, details, hr, .prose-scroll, .not-prose):not(
:where(.not-prose *)
) {
margin-block: var(--_flow) 0;
}
.honest-prose :where(p, ul, ol, dl, blockquote, pre, figure):not(:where(.not-prose, .not-prose *)) {
margin-inline: 0;
}
/* Headings */
.honest-prose :where(h1, h2, h3, h4, h5, h6):not(:where(.not-prose, .not-prose *)) {
margin-block: calc(var(--_flow) * 1.667) 0;
text-wrap: balance;
}
/* The type uses :is() so it outranks a theme's element rules, such as
`h2:not([data-slot])`. Margins stay at zero specificity above. */
.honest-prose :is(h1, h2, h3, h4, h5, h6):not(:where(.not-prose, .not-prose *)) {
font-family: inherit;
font-size: 1em;
font-weight: var(--hui-font-weight-semibold, 600);
line-height: 1.43;
letter-spacing: inherit;
}
.honest-prose :is(h1, h2):not(:where(.not-prose, .not-prose *)) {
font-size: var(--_heading);
line-height: 1.375;
letter-spacing: var(--hui-letter-spacing-large, -0.011em);
}
/* A heading and the block under it read as one unit. */
.honest-prose :where(h1, h2, h3, h4, h5, h6):not(:where(.not-prose, .not-prose *)) + * {
margin-block-start: calc(var(--_flow) * 0.667);
}
/* Inline text */
/* A quiet underline that firms up on hover. It is always there, so links
never depend on color. */
.honest-prose :where(a):not(:where(.not-prose, .not-prose *)) {
color: inherit;
text-decoration-line: underline;
text-decoration-thickness: max(1px, 0.0625em);
text-decoration-color: color-mix(in oklab, currentColor 50%, transparent);
text-underline-offset: 0.2em;
}
.honest-prose :where(a:hover):not(:where(.not-prose, .not-prose *)) {
text-decoration-color: currentColor;
}
.honest-prose :where(strong, b):not(:where(.not-prose, .not-prose *)) {
font-weight: var(--hui-font-weight-semibold, 600);
}
/* Footnote references do not make their line taller. */
.honest-prose :where(sub, sup):not(:where(.not-prose, .not-prose *)) {
line-height: 0;
}
/* Code shows the characters as typed, so ligatures such as => are off and
the body's letter spacing does not spread the columns. */
.honest-prose :where(pre, code, kbd, samp):not(:where(.not-prose, .not-prose *)) {
font-family: var(--_font-mono);
font-variant-ligatures: none;
letter-spacing: 0;
}
/* Code in a heading steps down a weight, so it is not the heaviest text there. */
.honest-prose :where(h1, h2, h3, h4, h5, h6) :where(code):not(:where(.not-prose, .not-prose *)) {
font-weight: var(--hui-font-weight-medium, 500);
}
/* Inline code is 12px at the 14px body and scales with the text around it,
including inside headings. */
.honest-prose :where(:not(pre) > code, kbd, samp):not(:where(.not-prose, .not-prose *)) {
font-size: 0.857em;
}
/* Inline code and keys are page-colored chips with a hairline. Padding sits
inside the chip, and a chip that wraps keeps its border on both lines. */
.honest-prose :where(:not(pre) > code, kbd):not(:where(.not-prose, .not-prose *)) {
border: var(--_hairline) solid var(--_rule);
border-radius: var(--_radius);
background: var(--hui-color-background-base-primary, color-mix(in oklab, currentColor 4%, transparent));
padding: 0.1em 0.35em;
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}
.honest-prose :where(:not(pre) > code):not(:where(.not-prose, .not-prose *)) {
color: var(--prose-code-color, inherit);
}
/* A key has a lower edge, so it reads as a key and not as code. */
.honest-prose :where(kbd):not(:where(.not-prose, .not-prose *)) {
box-shadow: inset 0 -1px 0 var(--_rule-strong);
}
/* Lists */
.honest-prose :where(ul, ol):not(:where(.not-prose, .not-prose *)) {
padding-inline-start: 1.6em;
}
.honest-prose :where(ul):not(:where(.not-prose, .not-prose *)) {
list-style: disc;
}
.honest-prose :where(ol):not(:where(.not-prose, .not-prose *)) {
list-style: decimal;
}
.honest-prose :where(ul ul):not(:where(.not-prose, .not-prose *)) {
list-style: circle;
}
/* Markers recede behind the text. Browsers give list numbers tabular
figures, which can read like code. */
.honest-prose :where(li):not(:where(.not-prose, .not-prose *))::marker {
color: var(--_muted);
font-variant-numeric: normal;
}
.honest-prose :where(li):not(:where(.not-prose, .not-prose *)) {
margin-block: calc(var(--_flow) / 3) 0;
}
.honest-prose :where(li) > :where(ul, ol):not(:where(.not-prose, .not-prose *)) {
margin-block-start: calc(var(--_flow) / 3);
}
/* In a loose list, paragraphs inside an item sit closer than the items do. */
.honest-prose :where(li > p + p):not(:where(.not-prose, .not-prose *)) {
margin-block-start: calc(var(--_flow) / 2);
}
.honest-prose :where(li:has(> :is(p, pre, blockquote, figure, table, div, dl)) + li):not(:where(.not-prose, .not-prose *)) {
margin-block-start: var(--_flow);
}
/* A task's checkbox sits where its bullet would, so wrapped lines and nested
lists indent like any other list, and a plain item in the same list keeps
its bullet. Markdown draws the checkbox as a markdown-task-mark span. */
.honest-prose :where(li.task-list-item):not(:where(.not-prose, .not-prose *)) {
position: relative;
list-style: none;
}
.honest-prose
:where(
li.task-list-item > :first-child:is(input, [data-slot=markdown-task-mark]),
li.task-list-item > p:first-child > :first-child:is(input, [data-slot=markdown-task-mark])
):not(:where(.not-prose, .not-prose *)) {
position: absolute;
inset-inline-start: -1.6em;
/* Centered on the first line. */
inset-block-start: calc(var(--_leading) * 0.5em);
translate: 0 -50%;
margin: 0;
/* A checkbox has its own font size, which would change the em above. */
font-size: inherit;
}
.honest-prose :where(dt):not(:where(.not-prose, .not-prose *)) {
font-weight: var(--hui-font-weight-medium, 500);
}
.honest-prose :where(dd):not(:where(.not-prose, .not-prose *)) {
margin: 0;
color: var(--_muted);
}
.honest-prose :where(dd + dt):not(:where(.not-prose, .not-prose *)) {
margin-block-start: calc(var(--_flow) * 0.667);
}
/* Quotes and rules */
.honest-prose :where(blockquote):not(:where(.not-prose, .not-prose *)) {
border-inline-start: 2px solid var(--_rule-strong);
padding-inline-start: var(--_flow);
color: var(--_muted);
}
.honest-prose :where(hr):not(:where(.not-prose, .not-prose *)) {
margin-block-start: calc(var(--_flow) * 1.333);
border: 0;
border-block-start: var(--_hairline) solid var(--_rule);
height: 0;
/* Browsers color a rule gray, which the fallback line would mix with. */
color: inherit;
}
/* The same space below a rule as above it. A heading keeps its own. */
.honest-prose :where(hr):not(:where(.not-prose, .not-prose *)) + :where(:not(h1, h2, h3, h4, h5, h6)) {
margin-block-start: calc(var(--_flow) * 1.333);
}
/*
* Code blocks, for a renderer that does not bring a component for them: one
* tinted panel with a hairline. Code View's shell holds a header; a plain
* block has none, so it needs only the panel.
*
* The block keeps the body size, so its spacing matches the blocks around it.
* The code inside is 12px on a 20px line at the 14px body, as in Code View.
*/
.honest-prose :where(pre):not(:where(.not-prose, .not-prose *)) {
overflow-x: auto;
border: var(--_hairline) solid var(--_rule);
border-radius: var(--_radius-block);
background: var(--_surface);
padding: 0.857em 1.143em;
tab-size: 2;
}
.honest-prose :where(pre > code):not(:where(.not-prose, .not-prose *)) {
display: block;
font-size: 0.857em;
line-height: 1.667;
}
/* A plain-HTML block without a code element sets the code size itself. */
.honest-prose :where(pre:not(:has(> code))):not(:where(.not-prose, .not-prose *)) {
padding: 1em 1.333em;
font-size: 0.857em;
line-height: 1.667;
}
/* Tables */
/* Wrap a table in `.prose-scroll` so a wide one scrolls instead of the page. */
.honest-prose :where(.prose-scroll):not(:where(.not-prose, .not-prose *)) {
overflow-x: auto;
}
/*
* The frame is drawn on the table itself, so it needs no wrapper. Separate
* borders let the corners round; collapsed borders cannot. Cells are content,
* so they keep the body size and line height.
*/
.honest-prose :where(table):not(:where(.not-prose, .not-prose *)) {
width: 100%;
border: var(--_hairline) solid var(--_rule);
border-collapse: separate;
border-spacing: 0;
border-radius: var(--_radius-block);
}
.honest-prose :where(.prose-scroll) > :where(table):not(:where(.not-prose, .not-prose *)) {
margin-block-start: 0;
}
/* Every cell has the same padding, so a cell that arrives later does not
change the one before it. */
.honest-prose :where(th, td):not(:where(.not-prose, .not-prose *)) {
padding: calc(var(--_flow) * 0.667) var(--_flow);
vertical-align: top;
}
/* Cells start-align unless the HTML aligns them with an attribute. */
.honest-prose :where(th:not([align]), td:not([align])):not(:where(.not-prose, .not-prose *)) {
text-align: start;
}
.honest-prose :where(th):not(:where(.not-prose, .not-prose *)) {
font-weight: var(--hui-font-weight-medium, 500);
}
/* Column headers sit on a tinted band. Row headers in the body stay plain. */
.honest-prose :where(thead th):not(:where(.not-prose, .not-prose *)) {
background: var(--_surface);
color: var(--_muted);
}
/* Cell backgrounds are not clipped by the table's radius, so the corner
cells round themselves, inside the border. The header row is complete
before it renders, so its last cell is stable. */
.honest-prose :where(thead > tr:first-child > th:first-child):not(:where(.not-prose, .not-prose *)) {
border-start-start-radius: calc(var(--_radius-block) - var(--_hairline));
}
.honest-prose :where(thead > tr:first-child > th:last-child):not(:where(.not-prose, .not-prose *)) {
border-start-end-radius: calc(var(--_radius-block) - var(--_hairline));
}
/* The line is drawn above each row after the first, and above the first row
after a header, including row headers. It looks only backward, so a row
that arrives later needs no restyle, and a table without a header gets no
second line under its border. */
.honest-prose
:where(
:is(tbody, tfoot) > tr + tr > *,
:is(thead, tbody) + :is(tbody, tfoot) > tr:first-child > *
):not(:where(.not-prose, .not-prose *)) {
border-block-start: var(--_hairline) solid var(--_rule);
}
/* Media */
.honest-prose :where(img, video):not(:where(.not-prose, .not-prose *)) {
max-width: 100%;
height: auto;
}
.honest-prose :where(figcaption):not(:where(.not-prose, .not-prose *)) {
margin-block-start: calc(var(--_flow) / 2);
color: var(--_muted);
font-size: calc(1em * 6 / 7);
}
/* Footnotes sit apart from the reply, below a rule, in smaller muted text. */
.honest-prose :where([data-footnotes]):not(:where(.not-prose, .not-prose *)) {
margin-block-start: calc(var(--_flow) * 1.333);
border-block-start: var(--_hairline) solid var(--_rule);
padding-block-start: calc(var(--_flow) / 3);
color: var(--_muted);
font-size: calc(1em * 6 / 7);
}
/* Secondary text inside secondary text keeps its color. Without tokens the
muted color is a fraction of the current one, and would fade again. */
.honest-prose :where(blockquote, dd, figcaption, thead th, [data-footnotes]) :where(blockquote, dd, figcaption, th):not(:where(.not-prose, .not-prose *)),
.honest-prose :where(blockquote, dd, figcaption, [data-footnotes]) :where(li):not(:where(.not-prose, .not-prose *))::marker {
color: inherit;
}
/* Last, so it wins over the flow rules above: nothing is pushed off the top of its container. */
/* In a tight list item, text comes before a block without a paragraph, so an
item drops the margin only from an opening paragraph or heading. */
.honest-prose > :where(:first-child),
.honest-prose :where(blockquote, td, th, dd, figure, ul, ol, [data-footnotes]) > :where(:first-child):not(:where(.not-prose *)),
.honest-prose :where(li) > :where(p, h1, h2, h3, h4, h5, h6):first-child:not(:where(.not-prose *)) {
margin-block-start: 0;
}
@import "tailwindcss";
@import "../styles/prose.css";Usage
<article class="honest-prose">
<h2>Release checklist</h2>
<p>The export fix is ready.</p>
</article>With a Markdown renderer, wrap its output:
<div className="honest-prose">
<ReactMarkdown>{text}</ReactMarkdown>
</div>Syntax highlighting
Honest Prose Syntax adds restrained syntax colors, streaming support, and standalone HTML, React, and server integrations. Honest Markdown enables it automatically. Prose CSS itself remains JavaScript-free.
Variables
Three variables do most of the work. Set them on the .honest-prose element or on anything around it.
The rest are for matching a theme:
Prose reads these variables and never sets them. A value from a class, an inline style, or an ancestor always applies:
<div className="honest-prose [--prose-size:16px] [--prose-leading:1.7] [--prose-flow:18px]">…</div>You can have several prose styles in one app: a tight one for chat replies and a roomier one for documents, each a different set of values on the same class.
The fallback colors use color-mix(). If you set your own contrast-sensitive colors, check them: the muted color carries text.
Behavior
Sizes
Headings are small on purpose. A reply sits inside a page that already has a title, so first- and second-level headings are a little larger than body text, and the rest match it in a heavier weight. For a document with a real title, raise --prose-heading or style h1 yourself.
Streaming
Blocks are spaced with a margin above them, never below. No rule depends on what comes after an element. A paragraph, list item, or table row that arrives later does not restyle what is already on screen.
Opting out
Add class="not-prose" to an element that brings its own styles, such as a component placed between paragraphs. It keeps its space in the flow, and no other rule reaches it or anything inside it. Code View carries this class itself.
Wide tables
Wrap a table in an element with class="prose-scroll", so a wide table scrolls sideways instead of widening the page. Make that wrapper focusable and give it a name, so a keyboard user can scroll it. Markdown does both.
Long code
A code block scrolls sideways when a line is too long. Not every browser lets the keyboard reach a scrolling block, so give one in your own HTML a name and make it focusable, and keep its focus outline:
<pre tabindex="0" role="region" aria-label="Code example"><code>…</code></pre>Markdown's code blocks already do this.
Utility classes
Prose's rules sit outside Tailwind's layers, so a utility for a property Prose sets has no effect on the same element. text-sm on the .honest-prose element does not change its size. Use the variables, or your own CSS written after the import. Utilities for anything Prose does not set, such as width or padding on the wrapper, work as usual.
It is written this way because a theme's own heading rules also sit outside the layers, and would otherwise win. Heading type uses :is() for the same reason, so it outranks an element rule such as h2:not([data-slot]).
Accessibility
Prose changes how elements look and leaves what they are alone. Headings, lists, tables, and links keep their roles.
Links are underlined, so they do not depend on color. Line height is a number without a unit, and spacing uses margins, so text a reader has enlarged or respaced is not clipped.
The preview has been checked with axe and keyboard controls in Chromium. Standalone HTML has also been checked without theme tokens in light and dark colors, at a 320px viewport, with text-spacing overrides, and with forced-colors emulation. Screen-reader use and actual 400% browser zoom have not been checked yet.