Sections & blocks›Actions

core

Actions

A row of actions — each link of a list becomes a button, ranked primary and secondary, and a fence becomes a copyable command line

Source

import Markdoc from '@markdoc/markdoc';
import type { Config, Node, RenderableTreeNode } from '@markdoc/markdoc';
const { Tag } = Markdoc;
import { createComponentRenderable, createContentModelSchema } from '../lib/index.js';
import { RenderableNodeCursor } from '../lib/renderable.js';
import { linkItem } from './common.js';

type AnyTag = InstanceType<typeof Tag>;

export function buildActions(nodes: readonly Node[], config: Config): AnyTag {
	const baseConfig = config;
	const actionConfig = {
		...config,
		nodes: {
			...config.nodes,
			item: linkItem,
			fence: {
				transform(node: Node) {
					const output = new RenderableNodeCursor([
						Markdoc.transform(node, baseConfig),
					] as RenderableTreeNode[]);
					return new Tag('div', {}, [output.next()]);
				},
			},
		},
	};
	const rendered = new RenderableNodeCursor(
		Markdoc.transform([...nodes], actionConfig) as RenderableTreeNode[],
	);

	const items = rendered.flatten().tags('li').toArray() as AnyTag[];
	const hasLink = (n: RenderableTreeNode): boolean =>
		Markdoc.Tag.isTag(n) && (n.name === 'a' || n.children.some(hasLink));
	const primary = items.find(hasLink);
	for (const item of items) {
		item.attributes['data-rank'] = item === primary ? 'primary' : 'secondary';
	}

	return createComponentRenderable({
		rune: 'actions',
		tag: 'div',
		refs: {
			list: rendered.tags('ul', 'ol').toArray() as AnyTag[],
			action: items,
			command: rendered.tags('div').toArray() as AnyTag[],
		},
		children: rendered.toArray(),
	}) as AnyTag;
}

export const actions = createContentModelSchema({
	contentModel: {
		type: 'sequence',
		fields: [{ name: 'items', match: 'list|fence', optional: true, greedy: true }],
	},
	transform(resolved, _attrs, config) {
		const items = resolved.items;
		const nodes = (Array.isArray(items) ? items : items ? [items] : []) as Node[];
		return buildActions(nodes, config);
	},
});

View packages/runes/src/tags/actions.ts on GitHub

{% actions %} turns a plain list of links into a row of buttons. The first link of the whole row is the primary action and the rest are secondary, so a theme styles the rank rather than the list position. A fence becomes a copyable command line in the same row.

It is what hero and cta render their buttons with, and what a composed rune places to get buttons from a slot.

Basic usage

{% actions %}
- [Get started](/docs/getting-started)
- [View on GitHub](https://github.com/refrakt-md/refrakt)
{% /actions %}
<div data-rune="actions">
  <ul data-name="list">
    <li data-rank="primary" data-name="action">
      <a href="/docs/getting-started">
        <span>Get started</span>
      </a>
    </li>
    <li data-rank="secondary" data-name="action">
      <a href="https://github.com/refrakt-md/refrakt">
        <span>View on GitHub</span>
      </a>
    </li>
  </ul>
</div>
<div class="rf-actions" data-rune="actions" data-density="full">
  <ul data-name="list" class="rf-actions__list">
    <li data-rank="primary" data-name="action" class="rf-actions__action">
      <a href="/docs/getting-started">
        <span>Get started</span>
      </a>
    </li>
    <li data-rank="secondary" data-name="action" class="rf-actions__action">
      <a href="https://github.com/refrakt-md/refrakt">
        <span>View on GitHub</span>
      </a>
    </li>
  </ul>
</div>

How Markdown is read

You writeIt becomes
A list of linksA row of buttons, one per list item
The first link of the whole rowThe primary action; every other link is secondary
A code fenceA copyable command line beside the buttons

With a command line

A fence is a command block, unranked, beside the buttons. On a narrow screen the row stacks, and the command line and the buttons share its width.

{% actions %}
```shell
npx create-refrakt
```

- [Read the docs](/docs/getting-started)
{% /actions %}
<div data-rune="actions">
  <div data-name="command">
    <div class="rf-codeblock">
      <pre data-language="shell">
        <code data-language="shell">npx create-refrakt
</code>
      </pre>
    </div>
  </div>
  <ul data-name="list">
    <li data-rank="primary" data-name="action">
      <a href="/docs/getting-started">
        <span>Read the docs</span>
      </a>
    </li>
  </ul>
</div>
npx create-refrakt
<div class="rf-actions" data-rune="actions" data-density="full">
  <div data-name="command" class="rf-actions__command">
    <div class="rf-codeblock">
      <pre data-language="shell"><code data-language="shell">npx create-refrakt
</code></pre>
    </div>
  </div>
  <ul data-name="list" class="rf-actions__list">
    <li data-rank="primary" data-name="action" class="rf-actions__action">
      <a href="/docs/getting-started">
        <span>Read the docs</span>
      </a>
    </li>
  </ul>
</div>

Rank

Rank is positional over the whole row: the first link is primary, wherever it is. A row written as a list, a fence and another list has one primary action, the first link of the first list. Every other link is secondary.

In a composed rune

A composition places actions around a slot, so its authors keep writing a plain list:

{% section media-position=$attrs["media-position"] %}
	{% slot name="media" /%}

	---

	{% slot name="headline" /%}

	{% slot name="blurb" /%}

	{% actions %}{% slot name="actions" /%}{% /actions %}
{% /section %}

In a bar

Inside a bar, actions are metadata actions rather than a page's call to action: compact, at the height of the badges beside them, and tonal rather than filled, a primary included. They stay in a row on a phone. Each link may carry an icon, and a link to a drawer on the page opens it.

{% bar %}
	{% badge sentiment="positive" %}Stable{% /badge %}

	---

	{% actions %}
	- [{% icon name="package" /%} Install](#actions-install)
	- [{% icon name="code" /%} Source](#actions-source)
	{% /actions %}
{% /bar %}

{% drawer id="actions-install" title="Install" %}
```shell
npm install @refrakt-md/marketing
```
{% /drawer %}

{% drawer id="actions-source" title="Source" size="lg" tint-mode="dark" %}
	{% snippet path="packages/runes/src/tags/actions.ts" /%}
{% /drawer %}
<div data-rune="bar" data-zone-layout="bar">
  <div>
    <p>
      <span class="rf-badge" data-rune="badge" data-meta-sentiment="positive" data-meta-type="tag">Stable</span>
    </p>
  </div>
  <div data-align="end">
    <div data-rune="actions">
      <ul data-name="list">
        <li data-rank="primary" data-name="action">
          <a href="#actions-install">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="rf-icon" data-icon="package">
              <path d="M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"></path>
              <path d="M12 22V12"></path>
              <polyline points="3.29 7 12 12 20.71 7"></polyline>
              <path d="m7.5 4.27 9 5.15"></path>
            </svg>
            <span> Install</span>
          </a>
        </li>
        <li data-rank="secondary" data-name="action">
          <a href="#actions-source">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="rf-icon" data-icon="code">
              <path d="m16 18 6-6-6-6"></path>
              <path d="m8 6-6 6 6 6"></path>
            </svg>
            <span> Source</span>
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>
<section id="drawer-actions-install" data-rune="drawer" data-rune-fields="{&quot;side&quot;:&quot;right&quot;,&quot;size&quot;:&quot;md&quot;}" data-drawer-id="actions-install">
  <header data-name="header">
    <h3 data-drawer-title-auto="true" data-name="title">Install</h3>
    <button type="button" aria-label="Close" hidden data-name="close">×</button>
  </header>
  <div data-name="body">
    <div class="rf-codeblock">
      <pre data-language="shell">
        <code data-language="shell">npm install @refrakt-md/marketing
</code>
      </pre>
    </div>
  </div>
</section>
<section id="drawer-actions-source" data-rune="drawer" data-rune-fields="{&quot;side&quot;:&quot;right&quot;,&quot;size&quot;:&quot;lg&quot;}" data-drawer-id="actions-source">
  <header data-name="header">
    <h3 data-drawer-title-auto="true" data-name="title">Source</h3>
    <button type="button" aria-label="Close" hidden data-name="close">×</button>
  </header>
  <div data-name="body">
    <div class="rf-codeblock">
      <pre data-language="typescript" data-source="packages/runes/src/tags/actions.ts">
        <code data-language="typescript" data-source="packages/runes/src/tags/actions.ts">import Markdoc from '@markdoc/markdoc';
import type { Config, Node, RenderableTreeNode } from '@markdoc/markdoc';
const { Tag } = Markdoc;
import { createComponentRenderable, createContentModelSchema } from '../lib/index.js';
import { RenderableNodeCursor } from '../lib/renderable.js';
import { linkItem } from './common.js';

type AnyTag = InstanceType&lt;typeof Tag&gt;;

export function buildActions(nodes: readonly Node[], config: Config): AnyTag {
	const baseConfig = config;
	const actionConfig = {
		...config,
		nodes: {
			...config.nodes,
			item: linkItem,
			fence: {
				transform(node: Node) {
					const output = new RenderableNodeCursor([
						Markdoc.transform(node, baseConfig),
					] as RenderableTreeNode[]);
					return new Tag('div', {}, [output.next()]);
				},
			},
		},
	};
	const rendered = new RenderableNodeCursor(
		Markdoc.transform([...nodes], actionConfig) as RenderableTreeNode[],
	);

	const items = rendered.flatten().tags('li').toArray() as AnyTag[];
	const hasLink = (n: RenderableTreeNode): boolean =&gt;
		Markdoc.Tag.isTag(n) &amp;&amp; (n.name === 'a' || n.children.some(hasLink));
	const primary = items.find(hasLink);
	for (const item of items) {
		item.attributes['data-rank'] = item === primary ? 'primary' : 'secondary';
	}

	return createComponentRenderable({
		rune: 'actions',
		tag: 'div',
		refs: {
			list: rendered.tags('ul', 'ol').toArray() as AnyTag[],
			action: items,
			command: rendered.tags('div').toArray() as AnyTag[],
		},
		children: rendered.toArray(),
	}) as AnyTag;
}

export const actions = createContentModelSchema({
	contentModel: {
		type: 'sequence',
		fields: [{ name: 'items', match: 'list|fence', optional: true, greedy: true }],
	},
	transform(resolved, _attrs, config) {
		const items = resolved.items;
		const nodes = (Array.isArray(items) ? items : items ? [items] : []) as Node[];
		return buildActions(nodes, config);
	},
});
</code>
      </pre>
    </div>
  </div>
  <meta data-field="tint-mode" content="dark">
</section>

Install

npm install @refrakt-md/marketing

Source

import Markdoc from '@markdoc/markdoc';
import type { Config, Node, RenderableTreeNode } from '@markdoc/markdoc';
const { Tag } = Markdoc;
import { createComponentRenderable, createContentModelSchema } from '../lib/index.js';
import { RenderableNodeCursor } from '../lib/renderable.js';
import { linkItem } from './common.js';

type AnyTag = InstanceType<typeof Tag>;

export function buildActions(nodes: readonly Node[], config: Config): AnyTag {
	const baseConfig = config;
	const actionConfig = {
		...config,
		nodes: {
			...config.nodes,
			item: linkItem,
			fence: {
				transform(node: Node) {
					const output = new RenderableNodeCursor([
						Markdoc.transform(node, baseConfig),
					] as RenderableTreeNode[]);
					return new Tag('div', {}, [output.next()]);
				},
			},
		},
	};
	const rendered = new RenderableNodeCursor(
		Markdoc.transform([...nodes], actionConfig) as RenderableTreeNode[],
	);

	const items = rendered.flatten().tags('li').toArray() as AnyTag[];
	const hasLink = (n: RenderableTreeNode): boolean =>
		Markdoc.Tag.isTag(n) && (n.name === 'a' || n.children.some(hasLink));
	const primary = items.find(hasLink);
	for (const item of items) {
		item.attributes['data-rank'] = item === primary ? 'primary' : 'secondary';
	}

	return createComponentRenderable({
		rune: 'actions',
		tag: 'div',
		refs: {
			list: rendered.tags('ul', 'ol').toArray() as AnyTag[],
			action: items,
			command: rendered.tags('div').toArray() as AnyTag[],
		},
		children: rendered.toArray(),
	}) as AnyTag;
}

export const actions = createContentModelSchema({
	contentModel: {
		type: 'sequence',
		fields: [{ name: 'items', match: 'list|fence', optional: true, greedy: true }],
	},
	transform(resolved, _attrs, config) {
		const items = resolved.items;
		const nodes = (Array.isArray(items) ? items : items ? [items] : []) as Node[];
		return buildActions(nodes, config);
	},
});
<div data-zone-layout="bar" class="rf-bar" data-rune="bar" data-density="full">
  <div>
    <p>
      <span class="rf-badge rf-badge" data-meta-sentiment="positive" data-meta-type="tag" data-rune="badge" data-density="full">Stable</span>
    </p>
  </div>
  <div data-align="end">
    <div class="rf-actions rf-actions--in-bar" data-rune="actions" data-density="full">
      <ul data-name="list" class="rf-actions__list">
        <li data-rank="primary" data-name="action" class="rf-actions__action">
          <a href="#drawer-actions-install" data-target-type="drawer">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="rf-icon" data-icon="package">
              <path d="M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"></path>
              <path d="M12 22V12"></path>
              <polyline points="3.29 7 12 12 20.71 7"></polyline>
              <path d="m7.5 4.27 9 5.15"></path>
            </svg>
            <span> Install</span>
          </a>
        </li>
        <li data-rank="secondary" data-name="action" class="rf-actions__action">
          <a href="#drawer-actions-source" data-target-type="drawer">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="rf-icon" data-icon="code">
              <path d="m16 18 6-6-6-6"></path>
              <path d="m8 6-6 6 6 6"></path>
            </svg>
            <span> Source</span>
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>
<section id="drawer-actions-install" class="rf-drawer rf-drawer--right rf-drawer--md" data-drawer-id="actions-install" data-side="right" data-size="md" data-rune="drawer" data-density="compact">
  <header data-name="header" class="rf-drawer__header" data-section="header">
    <h3 data-name="title" class="rf-drawer__title">Install</h3>
    <button type="button" aria-label="Close" hidden data-name="close" class="rf-drawer__close">×</button>
  </header>
  <div data-name="body" class="rf-drawer__body" data-section="body">
    <div class="rf-codeblock">
      <pre data-language="shell"><code data-language="shell">npm install @refrakt-md/marketing
</code></pre>
    </div>
  </div>
</section>
<section id="drawer-actions-source" class="rf-drawer rf-drawer--right rf-drawer--lg" data-drawer-id="actions-source" data-side="right" data-size="lg" data-color-scheme="dark" data-rune="drawer" data-density="compact">
  <header data-name="header" class="rf-drawer__header" data-section="header">
    <h3 data-name="title" class="rf-drawer__title">Source</h3>
    <button type="button" aria-label="Close" hidden data-name="close" class="rf-drawer__close">×</button>
  </header>
  <div data-name="body" class="rf-drawer__body" data-section="body">
    <div class="rf-codeblock">
      <pre data-language="typescript" data-source="packages/runes/src/tags/actions.ts"><code data-language="typescript" data-source="packages/runes/src/tags/actions.ts">import Markdoc from '@markdoc/markdoc';
import type { Config, Node, RenderableTreeNode } from '@markdoc/markdoc';
const { Tag } = Markdoc;
import { createComponentRenderable, createContentModelSchema } from '../lib/index.js';
import { RenderableNodeCursor } from '../lib/renderable.js';
import { linkItem } from './common.js';

type AnyTag = InstanceType&lt;typeof Tag&gt;;

export function buildActions(nodes: readonly Node[], config: Config): AnyTag {
	const baseConfig = config;
	const actionConfig = {
		...config,
		nodes: {
			...config.nodes,
			item: linkItem,
			fence: {
				transform(node: Node) {
					const output = new RenderableNodeCursor([
						Markdoc.transform(node, baseConfig),
					] as RenderableTreeNode[]);
					return new Tag('div', {}, [output.next()]);
				},
			},
		},
	};
	const rendered = new RenderableNodeCursor(
		Markdoc.transform([...nodes], actionConfig) as RenderableTreeNode[],
	);

	const items = rendered.flatten().tags('li').toArray() as AnyTag[];
	const hasLink = (n: RenderableTreeNode): boolean =&gt;
		Markdoc.Tag.isTag(n) &amp;&amp; (n.name === 'a' || n.children.some(hasLink));
	const primary = items.find(hasLink);
	for (const item of items) {
		item.attributes['data-rank'] = item === primary ? 'primary' : 'secondary';
	}

	return createComponentRenderable({
		rune: 'actions',
		tag: 'div',
		refs: {
			list: rendered.tags('ul', 'ol').toArray() as AnyTag[],
			action: items,
			command: rendered.tags('div').toArray() as AnyTag[],
		},
		children: rendered.toArray(),
	}) as AnyTag;
}

export const actions = createContentModelSchema({
	contentModel: {
		type: 'sequence',
		fields: [{ name: 'items', match: 'list|fence', optional: true, greedy: true }],
	},
	transform(resolved, _attrs, config) {
		const items = resolved.items;
		const nodes = (Array.isArray(items) ? items : items ? [items] : []) as Node[];
		return buildActions(nodes, config);
	},
});
</code></pre>
    </div>
  </div>
</section>

The same row on its own, outside a bar, is the full-size buttons of Basic usage.

Attributes

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.

AttributeTypeRequiredDescription
bgstring—Background preset applied to this block
bg-fromstring—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-tostring—Gradient end colour — a semantic token name
bg-viastring—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)
elevation

How far the rune sits off the page, from sunken to overlay. The theme decides what each step looks like.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
reveal"none" | "fade" | "slide" | "scale" | "blur"—Scroll-reveal entrance character (none|fade|slide|scale|blur); the theme owns the choreography
staggerboolean—Cascade this block's items in as it reveals (no-op on single-child runes)
spacing

Block-level rhythm override.

AttributeTypeRequiredDescription
spacing"flush" | "tight" | "default" | "loose" | "breathe"—Vertical spacing above and below this block
substrate

Generated pattern fills behind the content, drawn by the theme.

AttributeTypeRequiredDescription
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.

AttributeTypeRequiredDescription
tintstring—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.

AttributeTypeRequiredDescription
width"compact" | "narrow" | "content" | "wide" | "full"—Maximum width constraint for this block
Not availableWhy
dropcap, readingthis rune declares no prose body
framethis rune declares neither a `frameTarget` nor a media section
prominencethis rune has no page-section header or featured quotation