Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

docs(ChatLayout): a reply gets one right edge with contentWidth="100%"; Markdown keeps its 680px measure (#6608)

Manohar Paturib6b0c68ad570
diff --git a/.changeset/one-right-edge-for-chat-markdown.md b/.changeset/one-right-edge-for-chat-markdown.md
new file mode 100644
index 0000000000..71f3d84f95
--- /dev/null
+++ b/.changeset/one-right-edge-for-chat-markdown.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[docs] ChatLayout's guidance explains how a reply gets one right edge: Markdown prose keeps its 680px measure while code blocks and tables span the message column, so pass `contentWidth="100%"` to the reply's Markdown. Markdown's default measure is unchanged. (#5598)
+
+@ManoharPaturi
diff --git a/packages/core/src/Chat/ChatLayout.doc.mjs b/packages/core/src/Chat/ChatLayout.doc.mjs
index 4c6aab35ab..7d6ec5361e 100644
--- a/packages/core/src/Chat/ChatLayout.doc.mjs
+++ b/packages/core/src/Chat/ChatLayout.doc.mjs
@@ -79,6 +79,10 @@ export const docs = {
guidance: true,
description: "Give a full-page ChatLayout a container 100dvh tall, not 100vh: where a phone browser's toolbar collapses, 100vh is the viewport with the toolbar hidden, so the composer would start below the screen's edge.",
},
+ {
+ guidance: true,
+ description: 'Markdown prose keeps its 680px measure, while code blocks and tables span the message column. To give a reply one right edge, pass contentWidth="100%" to its Markdown.',
+ },
{
guidance: false,
description: "Don't apply a fixed height on the layout; let it fill its container with flex: 1.",
@@ -142,6 +146,7 @@ export const docsDense = {
{guidance: true, description: 'Provide emptyState so new conversations show a prompt, not blank screen.'},
{guidance: true, description: 'Use scrollRef when chat is embedded in a page where a parent element handles scrolling.'},
{guidance: true, description: 'full-page: container 100dvh not 100vh (100vh = viewport w/ phone toolbar hidden; composer starts below screen edge)'},
+ {guidance: true, description: 'Markdown prose keeps 680px measure; code/tables span column. One right edge: pass contentWidth="100%" to Markdown.'},
{guidance: false, description: 'Apply fixed height on layout; let it fill container with flex: 1.'},
{guidance: false, description: 'Render multiple ChatLayout instances in same scroll container; each expects to own its scroll context.'},
],
diff --git a/packages/core/src/Markdown/Markdown.test.tsx b/packages/core/src/Markdown/Markdown.test.tsx
index 2a7a52c1d0..05d6169d79 100644
--- a/packages/core/src/Markdown/Markdown.test.tsx
+++ b/packages/core/src/Markdown/Markdown.test.tsx
@@ -1381,3 +1381,55 @@ describe('inlinePlugins', () => {
});
});
});
+
+describe('Markdown contentWidth', () => {
+ function maxWidthStyles(container: HTMLElement): string[] {
+ return Array.from(container.querySelectorAll('*'))
+ .map(el => el.getAttribute('style') ?? '')
+ .filter(style => style.includes('--x-maxWidth'));
+ }
+
+ it('caps default prose at the 680px measure', () => {
+ const {container} = render(
+ <Markdown>{'Hello world paragraph.\n\n```\ncode\n```'}</Markdown>,
+ );
+ expect(
+ maxWidthStyles(container).some(style =>
+ style.includes('--x-maxWidth: 680px'),
+ ),
+ ).toBe(true);
+ // A code block spans the column, with the prose measure as its floor.
+ expect(container.querySelector('pre')?.getAttribute('style')).toContain(
+ '--x-minWidth: min(680px, 100%)',
+ );
+ });
+
+ it('lets prose span the column with contentWidth="100%"', () => {
+ const {container} = render(
+ <Markdown contentWidth="100%">{'Hello world paragraph.'}</Markdown>,
+ );
+ const proseStyles = maxWidthStyles(container);
+ expect(proseStyles.length).toBeGreaterThan(0);
+ for (const style of proseStyles) {
+ expect(style).toContain('--x-maxWidth: 100%');
+ }
+ });
+
+ it('keeps an explicit numeric contentWidth in pixels', () => {
+ const {container} = render(
+ <Markdown contentWidth={640}>{'Hello world paragraph.'}</Markdown>,
+ );
+ const proseStyles = maxWidthStyles(container);
+ expect(proseStyles.length).toBeGreaterThan(0);
+ for (const style of proseStyles) {
+ expect(style).toContain('--x-maxWidth: 640px');
+ }
+ });
+
+ it('still drops the prose cap entirely for contentWidth={0}', () => {
+ const {container} = render(
+ <Markdown contentWidth={0}>{'Hello world paragraph.'}</Markdown>,
+ );
+ expect(maxWidthStyles(container)).toEqual([]);
+ });
+});