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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
simplify slide container styles, and add docs (#10363)
Shahmir Varqhaeed8a821d040
diff --git a/docs/guides/apps.md b/docs/guides/apps.mdindex 1f2747343b..bd004e6648 100644--- a/docs/guides/apps.md+++ b/docs/guides/apps.md@@ -91,6 +91,57 @@ If you prefer a slideshow-like experience, you can use the slides layout. Enable- Add speaker notes at the bottom of each slide and launch speaker view by pressing `S`.- Powered by [reveal.js](https://revealjs.com/), so you can use most of its features like keyboard shortcuts, navigation, etc.+#### Styling slides++The slides layout is rendered with [reveal.js](https://revealjs.com/), so you+can brand a deck with a custom CSS file (see [Theming](configuration/theming.md))+targeted at reveal.js's own classes.++Target `.reveal-viewport` for deck-wide styles, like a background or a logo+that appears on every slide:++```css+.reveal-viewport {+ background-color: #faf8f4;+}++/* Logo pinned to the top-right of every slide */+.reveal-viewport::after {+ content: "";+ position: absolute;+ top: 1.25rem;+ right: 1.5rem;+ width: 7.5rem;+ height: 2.5rem;+ background-image: url("./logo.png");+ background-repeat: no-repeat;+ background-position: right center;+ background-size: contain;+ z-index: 40;+}+```++To target a specific slide, use either its position or a [named cell](configuration/theming.md#targeting-cells):++```css+/* By position (stable as long as the cell order doesn't change) */+.reveal .slides > section:first-of-type { /* ... */ }+.reveal .slides > section:nth-of-type(3) { /* ... */ }++/* By named cell (best when you only care about one specific cell) */+[data-cell-name="title"] { /* ... */ }+```++For a full-bleed background on a single slide, style `.reveal-viewport` with+`:has()` rather than the `<section>` directly — reveal.js letterboxes slide+content, so painting only the `<section>` can leave margins around it:++```css+.reveal-viewport:has(.slides > section.present [data-cell-name="title"]) {+ background: linear-gradient(145deg, #1c1917 0%, #292524 45%, #1f2937 100%);+}+```+#### Notes- The order of the slides is determined by the order of the cells in the notebook.diff --git a/frontend/src/components/slides/__tests__/cell-output-block.test.tsx b/frontend/src/components/slides/__tests__/cell-output-block.test.tsxnew file mode 100644index 0000000000..762a24b2e6--- /dev/null+++ b/frontend/src/components/slides/__tests__/cell-output-block.test.tsx@@ -0,0 +1,40 @@+/* Copyright 2026 Marimo. All rights reserved. */++import { render } from "@testing-library/react";+import { describe, expect, it } from "vitest";+import { cellId } from "@/__tests__/branded";+import { TooltipProvider } from "@/components/ui/tooltip";+import { CellOutputId } from "@/core/cells/ids";+import { createCell, createCellRuntimeState } from "@/core/cells/types";+import { CellOutputBlock } from "../reveal-component";++describe("CellOutputBlock", () => {+ it("renders the cell's data-cell-id and data-cell-name so it can be targeted by custom CSS", () => {+ const id = cellId("test");+ const cell = {+ ...createCell({ id, name: "title" }),+ ...createCellRuntimeState({+ output: {+ channel: "output",+ mimetype: "text/plain",+ data: "hello",+ timestamp: 0,+ },+ }),+ };++ const { container } = render(+ <TooltipProvider>+ <CellOutputBlock cell={cell} />+ </TooltipProvider>,+ );++ const cellElement = container.querySelector(`[data-cell-id="${id}"]`);+ expect(cellElement).toBeTruthy();+ expect(cellElement?.getAttribute("data-cell-name")).toBe("title");++ // The wrapper's `data-cell-id` must coexist with the output's own+ // `CellOutputId`-derived id, without colliding.+ expect(document.getElementById(CellOutputId.create(id))).toBeTruthy();+ });+});diff --git a/frontend/src/components/slides/__tests__/slide-cell-view.test.tsx b/frontend/src/components/slides/__tests__/slide-cell-view.test.tsxnew file mode 100644index 0000000000..154b70a6f1--- /dev/null+++ b/frontend/src/components/slides/__tests__/slide-cell-view.test.tsx@@ -0,0 +1,33 @@+/* Copyright 2026 Marimo. All rights reserved. */++import { render } from "@testing-library/react";+import { beforeAll, describe, expect, it } from "vitest";+import { SetupMocks } from "@/__mocks__/common";+import { cellId } from "@/__tests__/branded";+import { TooltipProvider } from "@/components/ui/tooltip";+import { createCell, createCellRuntimeState } from "@/core/cells/types";+import { SlideCellReadOnlyView } from "../slide-cell-view";++beforeAll(() => {+ SetupMocks.resizeObserver();+});++describe("SlideCellReadOnlyView", () => {+ it("renders the cell's data-cell-id and data-cell-name so it can be targeted by custom CSS", () => {+ const id = cellId("test");+ const cell = {+ ...createCell({ id, name: "title", code: "x = 1" }),+ ...createCellRuntimeState(),+ };++ const { container } = render(+ <TooltipProvider>+ <SlideCellReadOnlyView cell={cell} />+ </TooltipProvider>,+ );++ const cellElement = container.querySelector(`[data-cell-id="${id}"]`);+ expect(cellElement).toBeTruthy();+ expect(cellElement?.getAttribute("data-cell-name")).toBe("title");+ });+});diff --git a/frontend/src/components/slides/reveal-component.tsx b/frontend/src/components/slides/reveal-component.tsxindex 25fb9d5fa1..fadb46ddcf 100644--- a/frontend/src/components/slides/reveal-component.tsx+++ b/frontend/src/components/slides/reveal-component.tsx@@ -13,6 +13,7 @@ import useEvent from "react-use-event-hook";import { CodeIcon, ExpandIcon, EyeOffIcon } from "lucide-react";import { Deck, Fragment, Slide, Stack } from "@revealjs/react";import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";+import { cellDomProps } from "@/components/editor/common";import { Slide as CellOutputSlide } from "@/components/slides/slide";import { SlideScrollContainer } from "@/components/slides/slide-scroll-hint";import { Button } from "@/components/ui/button";@@ -304,6 +305,25 @@ function resolveSlideContentStyle(}}+/**+ * Renders a cell's output wrapped in a `data-cell-id`/`data-cell-name` div+ * (see `cellDomProps`), so it can be targeted by custom CSS in the slides+ * view just like it can in the vertical layout. The wrapper is required+ * because `CellOutputSlide` sets its own `id` from `CellOutputId` (a+ * different scheme than `HTMLCellId`) and its inner `OutputArea` uses+ * `display: contents`, which can't be targeted for background/border styling.+ */+export const CellOutputBlock = ({ cell }: { cell: RuntimeCell }) => (+ <div className="flex flex-col" {...cellDomProps(cell.id, cell.name)}>+ <CellOutputSlide+ cellId={cell.id}+ status={cell.status}+ output={cell.output}+ stale={outputIsStale(cell, false)}+ />+ </div>+);+const SubslideView = ({subslide,resolveShowCode,@@ -340,15 +360,7 @@ const SubslideView = ({{subslide.blocks.map((block, i) => {const rendered = block.cells.map((cell) => {if (!resolveShowCode(cell.id)) {- return (- <CellOutputSlide- key={cell.id}- cellId={cell.id}- status={cell.status}- output={cell.output}- stale={outputIsStale(cell, false)}- />- );+ return <CellOutputBlock key={cell.id} cell={cell} />;}return isEditable ? (<SlideCellView key={cell.id} cell={cell} />@@ -406,14 +418,7 @@ const ParkedPreviewContent = ({<SlideCellReadOnlyView cell={cell} />);}- return (- <CellOutputSlide- cellId={cell.id}- status={cell.status}- output={cell.output}- stale={outputIsStale(cell, false)}- />- );+ return <CellOutputBlock cell={cell} />;};// There is an upstream react bug in dev mode (https://github.com/facebook/react/issues/34840)diff --git a/frontend/src/components/slides/slide-cell-view.tsx b/frontend/src/components/slides/slide-cell-view.tsxindex 8933d59410..966546d3ba 100644--- a/frontend/src/components/slides/slide-cell-view.tsx+++ b/frontend/src/components/slides/slide-cell-view.tsx@@ -202,7 +202,7 @@ export const SlideCellReadOnlyView = ({ cell }: { cell: RuntimeCell }) => {);const editor = (- <div className="marimo-cell">+ <div className="marimo-cell" {...cellDomProps(cell.id, cell.name)}><ReadonlyCodecode={display.code}language={display.language}diff --git a/frontend/src/components/slides/slides.css b/frontend/src/components/slides/slides.cssindex 9007697414..68ab282ba2 100644--- a/frontend/src/components/slides/slides.css+++ b/frontend/src/components/slides/slides.css@@ -15,8 +15,10 @@width: unset;}- /* If the first output is the only child, make it flex 1 */- > *:only-child > .output:only-child {+ /* If the first output is the only child, make it flex 1. Cells are wrapped+ in a `data-cell-id`/`data-cell-name` div (see `cellDomProps`), so `.output`+ is a grandchild rather than a direct child here. */+ > *:only-child:has(> .output:only-child, > * > .output:only-child) {flex: 1;}