Skip to Content

Panel

<Clover.Panel /><clover-panel>16 kB added to a page with a Root, gzipped38 kB added to a page with a <clover-root>, styles included, gzipped

What the resource says about itself, in sections: tabs or an accordion.

<Clover.Root iiifContent={url}>
  <Clover.Body />
  <div style={{ height: "24rem", overflowY: "auto" }}>
    <Clover.Panel layout= defaultValue= />
  </div>
</Clover.Root>
<clover-root
  iiif-content="https://clover.iiif.library.northwestern.edu/mocks/paged/manifest.json">
  <clover-body></clover-body>
  <div style="height: 24rem; overflow-y: auto">
    <clover-panel layout= value=></clover-panel>
  </div>
</clover-root>

API reference

Inside a Root<clover-root>, it shows About and each section the resource has data for, or Tab<clover-tab>s of your own: one always open, each loaded the first time it opens. Its tabs and accordion follow WAI-ARIA’s patterns. It is as tall as its sections; to scroll it, give the element around it a height and overflow-y: auto, as the templates do. Its other props, and its ref, go to its element.

Panel

PropTypeDefaultDescription
layout"tabs" | "accordion""tabs"A row of tabs, or sections stacked, each under its heading.
defaultValuestringThe firstThe section open first.
valuestring—The section open, controlled.
onValueChange(value: string) => void—A section was opened.
onClose() => void—A close button, for a panel floating over the page.
closeOnEscapebooleanfalseEscape closes it too; its close button moves to its inner edge.
headingLevelnumber3Its first headings: one below the heading over it.
downloadbooleantrueA Download button beside About’s heading, listing the downloads; false leaves them out.
languagesbooleantrueAbout’s heading offers the languages the resource comes in, the whole Root reading in the one chosen; false leaves them out.
aselement type"aside"The element to render.
childrenReactNode—Tabs: sections of your own, in place of the defaults.
classNamestring—Added to clover-panel.

Tab

One section of a Panel: a tab, or a heading in an accordion. It renders nothing itself.

PropTypeDefaultDescription
valuestringRequiredNames it, for the panel’s value and defaultValue.
labelReactNodeRequiredIts tab’s or heading’s text. Mark another language with lang.
childrenReactNode—What the section shows.

PanelToggle

A round button that shows and hides the panel. As a child of Body, it sits among the Canvas’s controls.

PropTypeDefaultDescription
openbooleanRequiredWhether the panel is showing.
onOpenChange(open: boolean) => voidRequiredCalled with !open when pressed.
controlsstring—The panel’s id, for aria-controls.

About

The panel’s first section, and a part of its own: the resource’s label and thumbnail, summary, metadata, required statement, rights, homepage, see also, downloads and address. For a Canvas shown on its own, it starts with the Manifest the Canvas is part of.

PropTypeDefaultDescription
canvasSummarybooleanfalseThe current Canvas’s summary too, before the resource’s.
downloadbooleantrueAlone, outside a Panel: the downloads, Download’s links, in a section of their own. In a Panel, its heading’s Download button lists them.
languagesbooleantrueAlone, outside a Panel: the languages the resource comes in, over what About says, the whole Root reading in the one chosen. In a Panel, its heading offers them.
headingLevelnumber3Its titles: the label, Rights, Homepage and the rest.
labelbooleantrueThe resource’s label first, as a heading.
thumbnailbooleantrueThe resource’s thumbnail, small, beside the label.
classNamestring—Added to clover-about.

<clover-panel>

The information panel of the clover-root it is in, in tabs or stacked boxes: the sections Clover has data for (About, Contents, Search, a Map, the Transcript, Annotations, the Collection), or its clover-tab children, in their order.

NameTypeDefaultDescription
layout"tabs" | "accordion"tabsA row of tabs, one section shown at a time, or the sections stacked as boxes, each opened by its heading.
valuestring—The tab shown first, by its value; changed later, it shows that tab. The first, by default.
heading-levelnumber3The level of the boxes' headings (accordion), one under the heading the panel sits beneath; its sections' own headings go a level below.
downloadbooleantrueAbout's heading offers the downloads, by a Download button that lists them; "false" leaves them out.
languagesbooleantrueWhere what the resource says of itself comes in several languages, About's heading offers them, and the whole clover-root reads in the one chosen. "false" leaves the choice out.
closablebooleanfalseA close button in the panel. Closing hands focus back to the control that opens it and hides what that control shows (or the panel itself).
close-on-escapebooleanfalseFor a panel over the page: Escape inside it closes it too, and its close button sits at its inner edge.
as"aside" | "div"asideThe element to draw: a complementary landmark, or a box.
clover-value-change{ value: string }—An event. The reader chose a tab, or opened a box.
clover-closeRecord<string, never>—An event. The reader closed the panel. Cancel it (preventDefault) to keep it shown.

<clover-tab>

One tab of the clover-panel it is in: its label, and what it holds, which the panel shows in its section, moved there when the section first opens. It draws nothing itself.

NameTypeDefaultDescription
valuestring—What the tab is called by, for the panel's value.
labelstring—What the tab says.
slot="label"Element—Markup for what the tab says, instead of the label attribute: shown as a copy, so give it no ids.

<clover-panel-toggle>

A button that shows and hides an element, the information panel's or any, by its id: open while it is not hidden. In a clover-body, it is one of the Body's controls; elsewhere, a button where it is.

NameTypeDefaultDescription
controlsstring—The id of what it shows and hides.
clover-open-change{ open: boolean }—An event. The reader pressed it, to show (open) or hide what it controls. Cancel it (preventDefault) to leave that as it is.

<clover-about>

The information panel's first section, on its own: the label and thumbnail, summary, metadata, required statement, rights, homepage, see also, downloads and address.

NameTypeDefaultDescription
canvas-summarybooleanfalseAlso the Canvas in view's summary, before the resource's.
downloadbooleantrue"false" leaves out the downloads.
languagesbooleantrueAlone: outside a clover-panel, where what the resource says of itself comes in several languages, a choice of them over what it says, the whole clover-root reading in the one chosen. "false" leaves it out.
thumbnailbooleantrue"false" leaves out the resource's thumbnail.
labelbooleantrue"false" leaves out the resource's label, its heading.
heading-levelnumber3The level of each section's title, one under the heading it sits beneath. Past 6, each names what it heads instead.

Examples

Sections

With no Tab<clover-tab>s, it shows About, then each section the resource has data for: Collection, Contents, Search, Map, Transcript and Annotations. This newspaper has a Content Search service, and its OCR as annotations, which a search finds in.

<Clover.Root iiifContent="https://clover.iiif.library.northwestern.edu/mocks/content-search/manifest.json"> <Clover.Body /> <div style={{ height: "24rem", overflowY: "auto" }}> <Clover.Panel /> </div> </Clover.Root>
<clover-root iiif-content="https://clover.iiif.library.northwestern.edu/mocks/content-search/manifest.json"> <clover-body></clover-body> <div style="height: 24rem; overflow-y: auto"> <clover-panel></clover-panel> </div> </clover-root>

Tabs or accordion

Use layout="accordion" to stack the sections, each opened by its heading, as the templates do. In a box that scrolls, the headings stay in sight, at its top and its foot.

<Clover.Panel layout="accordion" />
<clover-panel layout="accordion"></clover-panel>

The open section

Use defaultValue to choose the section open first, or value and onValueChangeclover-value-change to control it. The default sections are about, collection, contents, search, map, transcript and annotations. A search started outside the Search section (the Root’s searchQuerysearch-query, or your own clover.search()) opens it, ahead of defaultValue, so its hits come with their list. Focus stays where it is, and a Panel that is shut stays shut until the reader opens it, on Search. A value you control is left as you set it. This film opens on its chapters.

<Clover.Panel defaultValue="contents" />
<clover-panel value="contents"></clover-panel>

Languages

Where what a resource says of itself comes in several languages, About’s heading offers them, shown whichever section is open, and every part in the Root reads IIIF text in the one chosen, a title over it as About. It starts in the Root’s language, which a page sets to read in its own, here French, else in the reader’s. A reader’s choice lasts until the page gives the Root another language. This painting is described in English and French.

<Clover.Root iiifContent="https://iiif.io/api/cookbook/recipe/0006-text-language/manifest.json" language="fr" > <Clover.Body /> <Clover.Panel layout="accordion" /> </Clover.Root>
<clover-root iiif-content="https://iiif.io/api/cookbook/recipe/0006-text-language/manifest.json" language="fr"> <clover-body></clover-body> <clover-panel layout="accordion"></clover-panel> </clover-root>

Sections of your own

Give it Tab<clover-tab>s, and they are its sections, in their order. Each holds Clover’s parts or a component of your own that reads the Root through hooks. Give the parts in them the heading level the panel would: its own in tabs, one below it in an accordion.

function PageNotes({ notes }) { const canvas = Clover.useActiveCanvas(); return <p>{notes[canvas?.id] ?? "No notes for this page."}</p>; } <Clover.Panel> <Clover.Tab value="about" label="About"> <Clover.About /> </Clover.Tab> <Clover.Tab value="notes" label="Notes"> <PageNotes notes={notes} /> </Clover.Tab> </Clover.Panel>;
<clover-panel> <clover-tab value="about" label="About"> <clover-about></clover-about> </clover-tab> <clover-tab value="notes" label="Notes"> <p id="page-notes"></p> </clover-tab> </clover-panel> <script type="module"> const root = document.querySelector("clover-root"); const shown = document.getElementById("page-notes"); const show = () => { const canvas = root.clover.activeCanvas(); shown.textContent = notes[canvas?.id] ?? "No notes for this page."; }; const start = () => { show(); root.clover.subscribe(show); }; if (root.clover) start(); else root.addEventListener("clover-ready", start, { once: true }); </script>

Showing and hiding it

PanelToggle<clover-panel-toggle> shows and hides it: name the panel in its controls, and hide the panel with hidden. A panel floating over the page also takes onCloseclover-close, for a close button, and closeOnEscapeclose-on-escape; move focus into it as it opens.

function Layout({ url }) { const [open, setOpen] = React.useState(true); return ( <Clover.Root iiifContent={url}> <Clover.Body> <Clover.PanelToggle open={open} onOpenChange={setOpen} controls="panel" /> </Clover.Body> <Clover.Panel id="panel" hidden={!open} /> </Clover.Root> ); }
<!-- The toggle follows the panel's own hidden: write hidden on it to start it shut. --> <clover-root iiif-content="https://iiif.io/api/cookbook/recipe/0009-book-1/manifest.json" > <clover-body> <clover-panel-toggle controls="panel"></clover-panel-toggle> </clover-body> <clover-panel id="panel"></clover-panel> </clover-root>

Previous versions

Clover 3.x › Viewer › Information Panel

  • options.informationPanel becomes Default’s panel props, and Tab<clover-tab>s.
  • A plugin’s panel is a Tab<clover-tab> of your own.
  • defaultTab is defaultValue.