core
PullQuote
A featured quotation with its attribution, or a pull quote repeating words from the text
Source
import Markdoc from '@markdoc/markdoc';
import type { Node } from '@markdoc/markdoc';
const { Tag } = Markdoc;
type Tag = InstanceType<typeof Markdoc.Tag>;
import type { ContentModel } from '@refrakt-md/types';
import {
createContentModelSchema,
createComponentRenderable,
renderNodes,
fieldMetas,
} from '../lib/index.js';
import { QUOTE_ATTR, withoutQuoteRole } from '../nodes.js';
import { OWNER_ATTR, SLOT_ATTR } from '../lib/schema-table.js';
import {
attributionFrom,
attributionItemModel,
insideAttributionItemModel,
renderAttribution,
splitInsideAttribution,
} from '../lib/attribution.js';
const alignValues = ['left', 'center', 'right'] as const;
const variantValues = ['default', 'accent', 'editorial'] as const;
export const pullQuoteSections = { quote: 'body' } as const;
const pullQuoteModel: ContentModel = {
when: [
{
condition: { hasChild: 'blockquote' },
model: {
type: 'sequence',
fields: [
{
name: 'quote',
match: 'blockquote',
model: {
type: 'sequence',
fields: [
{ name: 'body', match: 'any', greedy: true, optional: true },
{
name: 'attribution',
match: 'paragraph',
optional: true,
position: 'last',
itemModel: insideAttributionItemModel,
},
],
},
},
{
name: 'attribution',
match: 'paragraph',
optional: true,
itemModel: attributionItemModel,
},
],
},
},
],
default: {
type: 'sequence',
fields: [{ name: 'body', match: 'any', greedy: true, optional: true }],
},
};
function mapVariant(value: unknown, attrs: Record<string, unknown>): string | undefined {
if (value !== 'accent') return undefined;
if (attrs.tint === undefined) attrs.tint = 'subtle';
return 'prominent';
}
export const pullquote = createContentModelSchema({
sections: pullQuoteSections,
provides: ['prose', 'featured-quotation'],
attributes: {
author: {
type: String,
required: false,
description: 'Who said it: the attribution, when it is not written as a paragraph',
},
source: {
type: String,
required: false,
description: 'Where it is from: a role, a work or a date, beside `author`',
},
align: {
type: String,
required: false,
matches: alignValues.slice(),
description: 'Placement of the quote in the text: centred, or floated left or right',
},
excerpt: {
type: Boolean,
required: false,
description:
'The words already appear in the text: a pull quote, hidden from assistive technology so a screen reader does not read them twice',
},
variant: {
type: String,
required: false,
matches: variantValues.slice(),
deprecated: true,
description:
'Deprecated: a look name. `accent` maps to `tint` and `prominence="prominent"`; the others to nothing',
} as any,
},
deprecations: {
variant: { newName: 'prominence', transform: mapVariant },
},
contentModel: pullQuoteModel,
transform(resolved, attrs, config) {
const inside = splitInsideAttribution(resolved.quote as Node | undefined);
const authored = resolved.quote
? (renderNodes(inside?.quote ?? (resolved.quote as Node), config).toArray() as Tag[])
: [];
const quote = authored.length
? withoutQuoteRole(authored[0])
: new Tag('blockquote', {}, renderNodes(resolved.body as Node[], config).toArray());
const fromAttrs =
typeof attrs.author === 'string' && attrs.author.trim()
? { name: attrs.author, source: attrs.source as string | undefined }
: undefined;
const after = fromAttrs ? undefined : attributionFrom(resolved.attributionData);
const attribution = renderAttribution(fromAttrs ?? after ?? inside?.attribution ?? {});
if (attribution && after) {
const marks = (resolved.attribution as Node | undefined)?.attributes ?? {};
for (const name of [OWNER_ATTR, SLOT_ATTR]) {
if (marks[name] !== undefined) attribution.attributes[name] = marks[name];
}
}
const excerpt = attrs.excerpt === true;
const figureChildren = attribution ? [quote, attribution] : [quote];
const refs: Record<string, Tag> = { quote };
if (attribution) refs.attribution = attribution;
const properties = fieldMetas(attrs, config, { align: 'center' });
if (!excerpt) {
const root = createComponentRenderable({
rune: 'pull-quote',
tag: 'figure',
properties,
refs,
children: figureChildren,
});
root.attributes[QUOTE_ATTR] = 'featured';
return root;
}
const figure = new Tag('figure', {}, figureChildren);
const root = createComponentRenderable({
rune: 'pull-quote',
tag: 'aside',
properties,
refs: { ...refs, figure },
children: [figure],
});
root.attributes[QUOTE_ATTR] = 'excerpt';
root.attributes['aria-hidden'] = 'true';
return root;
},
});
A featured quotation: a statement presented for its own sake, set apart from the text with who said it. With excerpt, a pull quote: words from the text around it, repeated large for a skimming eye.
You choose what the quote is; the theme decides how it looks. {% quote %} is the same rune.
A featured quotation
Wrap a blockquote. A paragraph after it, **Name** — Source, is its attribution: the name in bold, then the source after a dash or a comma.
{% pullquote %}
> Design is not just what it looks like and feels like. Design is how it works.
**Steve Jobs** — Apple
{% /pullquote %}<figure data-rune="pull-quote" data-rune-fields="{"align":"center"}" data-quote="featured">
<blockquote data-name="quote">
<p>Design is not just what it looks like and feels like. Design is how it works.</p>
</blockquote>
<figcaption data-name="attribution">
<cite data-name="name">Steve Jobs</cite>
<span data-name="source">Apple</span>
</figcaption>
</figure>Design is not just what it looks like and feels like. Design is how it works.
<figure class="rf-pullquote rf-pullquote--center" data-quote="featured" data-align="center" data-elevation="flush" data-rune="pull-quote" data-density="compact">
<blockquote data-name="quote" class="rf-pullquote__quote" data-section="body" data-reading="prose">
<p>Design is not just what it looks like and feels like. Design is how it works.</p>
</blockquote>
<figcaption data-name="attribution" class="rf-pullquote__attribution">
<cite data-name="name" class="rf-pullquote__name">Steve Jobs</cite>
<span data-name="source" class="rf-pullquote__source">Apple</span>
</figcaption>
</figure>It renders as a <figure> holding the <blockquote>, with the attribution as its <figcaption> and the name in <cite>. The attribution is read only after a quote; the source is optional.
The attribution can also be the quote's own last line, opening with a dash: — **Name**, Source. The dash marks it, so a quote that ends in bold text is not read as its source.
{% pullquote %}
> The best way to predict the future is to invent it.
>
> — **Alan Kay**, 1971
{% /pullquote %}<figure data-rune="pull-quote" data-rune-fields="{"align":"center"}" data-quote="featured">
<blockquote data-name="quote">
<p>The best way to predict the future is to invent it.</p>
</blockquote>
<figcaption data-name="attribution">
<cite data-name="name">Alan Kay</cite>
<span data-name="source">1971</span>
</figcaption>
</figure>The best way to predict the future is to invent it.
<figure class="rf-pullquote rf-pullquote--center" data-quote="featured" data-align="center" data-elevation="flush" data-rune="pull-quote" data-density="compact">
<blockquote data-name="quote" class="rf-pullquote__quote" data-section="body" data-reading="prose">
<p>The best way to predict the future is to invent it.</p>
</blockquote>
<figcaption data-name="attribution" class="rf-pullquote__attribution">
<cite data-name="name" class="rf-pullquote__name">Alan Kay</cite>
<span data-name="source" class="rf-pullquote__source">1971</span>
</figcaption>
</figure>How Markdown is read
| You write | It becomes |
|---|---|
| A blockquote | The quotation |
A paragraph after the blockquote, **Name** — Source | The attribution: the bold name, then the source after a dash or a comma |
A last line inside the blockquote that opens with a dash, — **Name**, Source | The attribution |
| Text with no blockquote around it | The quotation itself |
A pull quote
When the words already appear in the text, add excerpt. The quote renders as an <aside aria-hidden="true">, so a screen reader does not read the passage twice. It looks the same as a featured quotation.
{% pullquote excerpt=true align="right" %}
> The best interface is no interface.
{% /pullquote %}<aside data-rune="pull-quote" data-rune-fields="{"align":"right"}" data-quote="excerpt" aria-hidden="true">
<figure data-name="figure">
<blockquote data-name="quote">
<p>The best interface is no interface.</p>
</blockquote>
</figure>
</aside><aside class="rf-pullquote rf-pullquote--right" data-quote="excerpt" aria-hidden="true" data-align="right" data-elevation="flush" data-rune="pull-quote" data-density="compact">
<figure data-name="figure" class="rf-pullquote__figure">
<blockquote data-name="quote" class="rf-pullquote__quote" data-section="body" data-reading="prose">
<p>The best interface is no interface.</p>
</blockquote>
</figure>
</aside>How loud it is
prominence sets how loud the quote is, on the same scale that sizes a section's header: quiet and normal are a quotation's own size, prominent and display set it apart, and marquee makes it a page's centrepiece.
{% pullquote prominence="display" %}
> Simplicity is the ultimate sophistication.
{% /pullquote %}<figure data-rune="pull-quote" data-rune-fields="{"align":"center"}" data-quote="featured" prominence="display">
<blockquote data-name="quote">
<p>Simplicity is the ultimate sophistication.</p>
</blockquote>
</figure>Simplicity is the ultimate sophistication.
<figure class="rf-pullquote rf-pullquote--center" data-quote="featured" data-align="center" data-elevation="flush" data-prominence="display" data-rune="pull-quote" data-density="compact">
<blockquote data-name="quote" class="rf-pullquote__quote" data-section="body" data-reading="prose">
<p>Simplicity is the ultimate sophistication.</p>
</blockquote>
</figure>A tinted panel is the universal tint:
{% pullquote tint="subtle" prominence="prominent" %}
> Words can be like X-rays if you use them properly — they'll go through anything.
**Aldous Huxley**
{% /pullquote %}<figure data-rune="pull-quote" data-rune-fields="{"align":"center"}" data-quote="featured" prominence="prominent">
<blockquote data-name="quote">
<p>Words can be like X-rays if you use them properly — they'll go through anything.</p>
</blockquote>
<figcaption data-name="attribution">
<cite data-name="name">Aldous Huxley</cite>
</figcaption>
<meta data-field="tint" content="subtle">
</figure>Words can be like X-rays if you use them properly — they'll go through anything.
<figure class="rf-pullquote rf-pullquote--center rf-pullquote--tinted" data-quote="featured" data-align="center" data-elevation="flush" data-prominence="prominent" data-tint="subtle" data-tint-dark="" data-rune="pull-quote" data-density="compact" style="--tint-bg: var(--rf-color-surface); --tint-surface: var(--rf-color-surface-hover); --tint-text: var(--rf-color-text); --tint-muted: var(--rf-color-muted); --tint-primary: var(--rf-color-primary); --tint-border: var(--rf-color-border); --tint-dark-bg: var(--rf-color-surface); --tint-dark-surface: var(--rf-color-surface-hover); --tint-dark-text: var(--rf-color-text); --tint-dark-muted: var(--rf-color-muted); --tint-dark-primary: var(--rf-color-primary); --tint-dark-border: var(--rf-color-border)">
<blockquote data-name="quote" class="rf-pullquote__quote" data-section="body" data-reading="prose">
<p>Words can be like X-rays if you use them properly — they'll go through anything.</p>
</blockquote>
<figcaption data-name="attribution" class="rf-pullquote__attribution">
<cite data-name="name" class="rf-pullquote__name">Aldous Huxley</cite>
</figcaption>
</figure>Placement
align places the quote: centred in the measure (the default), or floated left or right beside the text, set against a rule.
Attributes
| Attribute | Type | Required | Description |
|---|---|---|---|
author | string | — | Who said it: the attribution, when it is not written as a paragraph |
source | string | — | Where it is from: a role, a work or a date, beside `author` |
align | "left" | "center" | "right" | — | Placement of the quote in the text: centred, or floated left or right |
excerpt | boolean | — | The words already appear in the text: a pull quote, hidden from assistive technology so a screen reader does not read them twice |
variant | "default" | "accent" | "editorial" | — | Deprecated: a look name. `accent` maps to `tint` and `prominence="prominent"`; the others to nothing |
Universal attributes
bg
The background layer: image, video, gradient, flat overlay wash and legibility scrim, in a single injected layer behind the rune's content.
| Attribute | Type | Required | Description |
|---|---|---|---|
bg | string | — | Background preset applied to this block |
bg-from | string | — | Gradient start colour — a semantic token name (→ var(--rf-color-*)) |
bg-gradient | "to-t" | "to-b" | "to-l" | "to-r" | "to-tr" | "to-br" | "to-bl" | "to-tl" | — | Gradient direction (bounded named set) |
bg-gradient-type | "linear" | "radial" | "conic" | — | Gradient type |
bg-to | string | — | Gradient end colour — a semantic token name |
bg-via | string | — | Optional middle gradient stop — a semantic token name |
scrim | "top" | "bottom" | "left" | "right" | "none" | — | Scrim direction (heaviest edge); presence turns the scrim on, "none" opts out of the default cover scrim |
scrim-blur | "none" | "sm" | "md" | "lg" | — | Frost scrim blur amount |
scrim-strength | "sm" | "md" | "lg" | — | Gradient scrim strength |
scrim-tone | "dark" | "light" | — | Whether the scrim darkens (for light text) or lightens (for dark text) |
scrim-type | "gradient" | "frost" | — | Scrim treatment: gradient (default) or frost (backdrop blur) |
dropcap
Per-instance drop-cap opt-in.
| Attribute | Type | Required | Description |
|---|---|---|---|
dropcap | boolean | — | Style the opening letter of a prose body as a drop cap. Honoured only when the body reads as prose; ignored otherwise. |
elevation
How far the rune sits off the page, from sunken to overlay. The theme decides what each step looks like.
| Attribute | Type | Required | Description |
|---|---|---|---|
elevation | "sunken" | "flush" | "flat" | "raised" | "floating" | "overlay" | "none" | "sm" | "md" | "lg" | — | Surface depth, from sunken to overlay. Deprecated: none, sm, md and lg (read as flat, raised, raised and floating) |
inset
Internal padding override.
| Attribute | Type | Required | Description |
|---|---|---|---|
inset | "flush" | "tight" | "default" | "loose" | "breathe" | — | Inner padding of this block |
motion
Scroll-reveal entrance. You choose its character; the theme decides how it moves.
| Attribute | Type | Required | Description |
|---|---|---|---|
reveal | "none" | "fade" | "slide" | "scale" | "blur" | — | Scroll-reveal entrance character (none|fade|slide|scale|blur); the theme owns the choreography |
stagger | boolean | — | Cascade this block's items in as it reveals (no-op on single-child runes) |
prominence
Header emphasis. Scales a rune's header, or its featured quotation; the theme decides the type size for each step.
| Attribute | Type | Required | Description |
|---|---|---|---|
prominence | "quiet" | "normal" | "prominent" | "display" | "marquee" | — | Emphasis of a page-section header or a featured quotation (only on runes that have one) |
reading
Editorial register for body text. You pick the register; the theme decides how it looks.
| Attribute | Type | Required | Description |
|---|---|---|---|
reading | "fine" | "ui" | "prose" | — | Reading register for this block’s body: fine | ui | prose. The theme sets how each one looks. |
spacing
Block-level rhythm override.
| Attribute | Type | Required | Description |
|---|---|---|---|
spacing | "flush" | "tight" | "default" | "loose" | "breathe" | — | Vertical spacing above and below this block |
substrate
Generated pattern fills behind the content, drawn by the theme.
| Attribute | Type | Required | Description |
|---|---|---|---|
substrate | "dots" | "grid" | "lines" | "cross" | "checker" | "none" | — | Generated surface pattern |
substrate-fill | "inherit" | "inset" | — | Surface fill the pattern sits on (full colour stays with tint) |
substrate-opacity | "sm" | "md" | "lg" | — | Pattern ink strength |
substrate-size | "sm" | "md" | "lg" | — | Pattern cell size |
substrate-target | "self" | "media" | — | Which surface the pattern fills (overrides the rune/theme default) |
tint
Per-rune colour override: a named tint from the theme registry, with inline per-token overrides layered on top.
| Attribute | Type | Required | Description |
|---|---|---|---|
tint | string | — | Color tint preset applied to this block |
tint-mode | "auto" | "dark" | "light" | — | Whether the tint adapts to auto, dark, or light mode |
width
The track a block rune occupies.
| Attribute | Type | Required | Description |
|---|---|---|---|
width | "compact" | "narrow" | "content" | "wide" | "full" | — | Maximum width constraint for this block |
| Not available | Why |
|---|---|
| frame | this rune declares neither a `frameTarget` nor a media section |