Skip to content

Sticky

Stays in view while the page, or the box around it, scrolls: a bar above a long table, the actions under a long form.

import { Sticky } from '@sypnia/ui/react'

On this page
  1. A bar that stays
  2. When to use it
  3. For everyone
  4. Props

A bar that stays

3 selected
  • Row 1
  • Row 2
  • Row 3
  • Row 4
  • Row 5
  • Row 6
  • Row 7
  • Row 8
  • Row 9
  • Row 10
  • Row 11
  • Row 12
  • Row 13
  • Row 14
  • Row 15
  • Row 16
  • Row 17
  • Row 18
  • Row 19
  • Row 20
  • Row 21
  • Row 22
  • Row 23
  • Row 24
Code
import { Button, ScrollArea, Sticky } from '@sypnia/ui/react';

// Scroll the box: the bar stays at the top of it.
export default function Bar() {
  return (
    <ScrollArea label="Rows" maxHeight="14rem">
      <Sticky><div className="sy-row" style={{ padding: 'var(--s-2) var(--s-3)', background: 'var(--bg-raised)', borderBottom: '1px solid var(--line)' }}><strong>3 selected</strong><Button size="sm">Export</Button></div></Sticky>
      <ul style={{ margin: 0, padding: 'var(--s-3)', listStyle: 'none' }}>{Array.from({ length: 24 }, (_, i) => <li key={i} style={{ padding: '0.35rem 0' }}>Row {i + 1}</li>)}</ul>
    </ScrollArea>
  );
}

When to use it

Use it when

  • Actions or a summary the person needs while going through a long list.

Do not use it when

  • Several sticky bars on one screen: they eat the room on phones.

For everyone

  • Focus order is unchanged; the content under it scrolls clear of it.

Props

StickyTypeDefault
className string
edge "bottom" | "top" top
offset string
  1. A bar that stays
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms