Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

improvement: add configuration to specifcy where the cell's output should be (above/below) (#689)

Myles Scolnick681071361256
diff --git a/frontend/src/components/app-config/user-config-form.tsx b/frontend/src/components/app-config/user-config-form.tsx
index 0ea4dbda0f..81bcb46145 100644
--- a/frontend/src/components/app-config/user-config-form.tsx
+++ b/frontend/src/components/app-config/user-config-form.tsx
@@ -238,7 +238,37 @@ export const UserConfigForm: React.FC = () => {
/>
</span>
</FormControl>
+ <FormDescription>
+ When unchecked, code completion is still available through a
+ hotkey.
+ </FormDescription>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <FormField
+ control={form.control}
+ name="display.cell_output"
+ render={({ field }) => (
+ <FormItem className="mb-2">
+ <FormLabel>Cell output area</FormLabel>
+ <FormControl>
+ <NativeSelect
+ onChange={(e) => field.onChange(e.target.value)}
+ value={field.value}
+ className="inline-flex mx-2"
+ >
+ {["above", "below"].map((option) => (
+ <option value={option} key={option}>
+ {option}
+ </option>
+ ))}
+ </NativeSelect>
+ </FormControl>
<FormMessage />
+ <FormDescription>
+ Where to display cell's output.
+ </FormDescription>
</FormItem>
)}
/>
diff --git a/frontend/src/components/editor/Cell.tsx b/frontend/src/components/editor/Cell.tsx
index 2960534587..8ac8d821da 100644
--- a/frontend/src/components/editor/Cell.tsx
+++ b/frontend/src/components/editor/Cell.tsx
@@ -375,7 +375,7 @@ const CellComponent = (
cellId={cellId}
title={cellTitle()}
>
- {outputArea}
+ {userConfig.display.cell_output === "above" && outputArea}
<div className="tray">
<div className="absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-2 hover-action">
<CreateCellButton
@@ -455,6 +455,7 @@ const CellComponent = (
) : null}
</div>
</div>
+ {userConfig.display.cell_output === "below" && outputArea}
<ConsoleOutput
consoleOutputs={consoleOutputs}
stale={consoleOutputStale}
diff --git a/frontend/src/components/editor/Output.tsx b/frontend/src/components/editor/Output.tsx
index cebbc8f67d..35fd693984 100644
--- a/frontend/src/components/editor/Output.tsx
+++ b/frontend/src/components/editor/Output.tsx
@@ -168,37 +168,41 @@ const ExpandableOutput = React.memo(
return (
<>
- <div className="increase-pointer-area-x" />
- <div
- {...props}
- className={cn("relative", props.className)}
- ref={containerRef}
- style={isExpanded ? { maxHeight: "none" } : undefined}
- >
- {children}
- </div>
- {(isOverflowing || isExpanded) && (
- <Button
- className={cn(
- "absolute top-1 -right-10",
- // Force show button if expanded
- !isExpanded && "hover-action"
- )}
- onClick={() => setIsExpanded(!isExpanded)}
- size="xs"
- variant="text"
+ <div>
+ {(isOverflowing || isExpanded) && (
+ <div className="relative">
+ <Button
+ className={cn(
+ "absolute top-6 -right-12 z-10",
+ // Force show button if expanded
+ !isExpanded && "hover-action"
+ )}
+ onClick={() => setIsExpanded(!isExpanded)}
+ size="xs"
+ variant="text"
+ >
+ {isExpanded ? (
+ <Tooltip content="Collapse output" side="left">
+ <ChevronsDownUpIcon className="h-4 w-4" />
+ </Tooltip>
+ ) : (
+ <Tooltip content="Expand output" side="left">
+ <ChevronsUpDownIcon className="h-4 w-4" />
+ </Tooltip>
+ )}
+ </Button>
+ </div>
+ )}
+ <div
+ {...props}
+ className={cn("relative", props.className)}
+ ref={containerRef}
+ style={isExpanded ? { maxHeight: "none" } : undefined}
>
- {isExpanded ? (
- <Tooltip content="Collapse output" side="left">
- <ChevronsDownUpIcon className="h-4 w-4" />
- </Tooltip>
- ) : (
- <Tooltip content="Expand output" side="left">
- <ChevronsUpDownIcon className="h-4 w-4" />
- </Tooltip>
- )}
- </Button>
- )}
+ {children}
+ </div>
+ </div>
+ <div className="increase-pointer-area-x contents" />
</>
);
}
diff --git a/frontend/src/core/config/config-schema.ts b/frontend/src/core/config/config-schema.ts
index a9c3f308fc..2426b9ccd9 100644
--- a/frontend/src/core/config/config-schema.ts
+++ b/frontend/src/core/config/config-schema.ts
@@ -43,10 +43,12 @@ export const UserConfigSchema = z
.object({
theme: z.enum(["light", "dark", "system"]).default("light"),
code_editor_font_size: z.number().nonnegative().default(14),
+ cell_output: z.enum(["above", "below"]).default("above"),
})
.default({
theme: "light",
code_editor_font_size: 14,
+ cell_output: "above",
}),
experimental: z
.object({
diff --git a/frontend/src/css/Cell.css b/frontend/src/css/Cell.css
index 9f57841d56..f8d8ff804d 100644
--- a/frontend/src/css/Cell.css
+++ b/frontend/src/css/Cell.css
@@ -14,6 +14,8 @@
border: 1px solid transparent;
box-shadow: var(--light-shadow);
+ @apply divide-y divide-[var(--gray-5)];
+
&:focus-visible {
/* focus-visible outlines the entire cell body in black, but the cell's
* body is an irregular shape because of pseudo-elements that extend
@@ -30,9 +32,14 @@
overflow: auto;
}
- .output-area {
- border-top-left-radius: 8px;
- border-top-right-radius: 8px;
+ & > :first-child {
+ border-top-left-radius: 9px;
+ border-top-right-radius: 9px;
+ }
+
+ & > :last-child {
+ border-bottom-left-radius: 9px;
+ border-bottom-right-radius: 9px;
}
&:hover {
@@ -97,6 +104,8 @@
&.needs-run {
box-shadow: var(--light-shadow-stale);
+ @apply divide-[var(--stale-color)];
+
&:hover {
box-shadow: var(--medium-shadow-stale);
}
@@ -111,10 +120,6 @@
border: 1px solid transparent;
}
- .output-area {
- border-bottom: 1px solid var(--stale-color);
- }
-
.RunButton {
visibility: visible;
}
@@ -235,6 +240,7 @@
.tray {
display: flex;
position: relative;
+ z-index: 1;
&:first-child .cm-editor {
border-top-left-radius: 9px;
@@ -358,14 +364,8 @@
.output-area {
padding: 0.25rem 1.85rem;
- border: 1px solid transparent;
- border-bottom: 1px solid var(--gray-5);
}
.console-output-area {
- border-top: 1px solid var(--gray-5);
- border-bottom: 1px solid var(--gray-3);
- border-right: 1px solid var(--gray-3);
- border-left: 1px solid var(--gray-3);
background-color: var(--gray-1);
}
diff --git a/frontend/src/stories/cell.stories.tsx b/frontend/src/stories/cell.stories.tsx
index 8061e3eb97..aa0a2dee80 100644
--- a/frontend/src/stories/cell.stories.tsx
+++ b/frontend/src/stories/cell.stories.tsx
@@ -60,6 +60,7 @@ const props: CellProps = {
display: {
theme: "light",
code_editor_font_size: 14,
+ cell_output: "above",
},
runtime: {
auto_instantiate: true,
diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js
index 056358b8b5..1e30e91340 100644
--- a/frontend/tailwind.config.js
+++ b/frontend/tailwind.config.js
@@ -125,6 +125,8 @@ module.exports = {
plugin(function ({ addUtilities }) {
const newUtilities = {
".increase-pointer-area-x": {
+ border: "none",
+
"&::before": {
content: '""',
position: "absolute",
diff --git a/marimo/_config/config.py b/marimo/_config/config.py
index af3eef82a0..0ae63d2032 100644
--- a/marimo/_config/config.py
+++ b/marimo/_config/config.py
@@ -77,10 +77,12 @@ class DisplayConfig(TypedDict, total=False):
- `theme`: `"light"`, `"dark"`, or `"system"`
- `code_editor_font_size`: font size for the code editor
+ - `cell_output`: `"above"` or `"below"`
"""
theme: Literal["light", "dark", "system"]
code_editor_font_size: int
+ cell_output: Literal["above", "below"]
@mddoc
@@ -142,6 +144,7 @@ DEFAULT_CONFIG: MarimoConfig = {
"display": {
"theme": "light",
"code_editor_font_size": 14,
+ "cell_output": "above",
},
"formatting": {"line_length": 79},
"keymap": {"preset": "default"},