<t-panel>
Floats its contents in a panel that stays in view while the page scrolls. Put a post's controls in one, and they follow the reader through the prose and formulas they drive.
The panel in the bottom-right corner of this page comes from the example below. Drag it by its header, minimize it with −, and scroll: the numbers in it keep updating the text.
Save
at
for
After
Attributes
| Attribute | Default | Description |
|---|---|---|
corner | bottom-right | Where the panel starts: top-left, top-right, bottom-left or bottom-right. It sits 16px from the edges of the viewport. |
label | A caption on the header, which stays visible when the panel is minimized. Also the panel's accessible name. Long labels are cut off with an ellipsis. | |
width | fits the content | The width in pixels. Set it to reflow long text. |
collapsed | Start minimized, showing only the header. |
The panel is never dismissed, only minimized, so its contents are always one click away. Minimizing keeps the panel's width, so the header stays a readable bar.
Behavior
- Drag the header to move the panel. It's kept fully on screen, also when the window is resized.
- The button on the header minimizes and expands the panel, with a short folding animation
(none if the reader prefers reduced motion). From JavaScript, set the
collapsedproperty or attribute. - The contents keep their scope. The panel doesn't move its children anywhere, so a
<t-panel>inside a<t-scope>uses that scope's variables, like the example above. - Without JavaScript, the contents show in place, as ordinary content.
- It's
position: fixed. An ancestor with atransform,filterorcontaincreates a new containing block, which pins the panel to that ancestor instead of the viewport. Put the<t-panel>outside such elements. - The panel is at
z-index: 1000. Override it witht-panel { z-index: … }.
Styling
The panel uses --tangle-surface for its background, so it follows the theme. Its pieces are
exposed as CSS shadow parts:
| Selector | Matches |
|---|---|
t-panel | The panel itself: border, background, shadow, z-index. |
t-panel::part(header) | The draggable header bar. |
t-panel::part(label) | The caption on the header. |
t-panel::part(toggle) | The minimize button. |
t-panel::part(body) | The box around the contents, with its padding. |
t-panel[collapsed] | A minimized panel. |
t-panel {
border-radius: 0;
box-shadow: none;
}
t-panel::part(header) {
background: var(--tangle-accent);
color: white;
}