Skip to content

feat(Table): add skeleton loading variant - #1229

Merged
mdevils merged 18 commits into
mainfrom
feat/table-loading-skeleton
Oct 16, 2026
Merged

mdevils merged 18 commits into
mainfrom
feat/table-loading-skeleton

Conversation

@mdevils

@mdevils mdevils commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Feature

Table's loading prop shows one centered spinner. It says nothing about the shape of the data, and the rows jump in when they arrive. There is also no shared skeleton component, so every place that wants one builds its own.

Solution

  • New Skeleton component, in two shapes:
    <Skeleton />                                            // one line of text
    <Skeleton size="sm" lines={3} width="60%" />            // the last line is 75% wide
    <Skeleton shape="rectangle" width="xxl" height="xxl" />
    width and height take a space key or any CSS length. Props that don't fit the shape are type errors.
  • Table gets loadingVariant="skeleton" and skeletonRowCount. Placeholder rows are real cells with a <Skeleton> in each, so they line up with the columns and follow the table's size and rowHeight. The default is still spinner.
  • The table sets aria-busy while loading, in both variants.

Details

  • One wave for the whole page. The shimmer gradient is fixed to the viewport, and each shimmer is pinned to the page's animation clock when it starts. So all skeletons sweep together, at the same speed, whatever their size or when they mounted. iOS Safari ignores background-attachment: fixed; there each skeleton still shimmers, just not in sync.
  • Under reduced motion it's a static fill.
  • Narrower than CUI-295 on purpose: only text and rectangle, no isLoading / children. size is sm / md until the t-shirt scale is decided.
  • Placeholder rows are aria-hidden. jsx-a11y counts <tr> / <td> as interactive, so two inline disables say why that's fine.

Review focus

  • handleAnimationStart in Skeleton.tsx: it changes startTime on CSS animations. It should touch only the shimmer, never a consumer's animation.
  • The <tbody> conditions in Table.tsx: the spinner and no-data rows must behave exactly as before.
  • SkeletonProps: is this shape-specific API what we want, before it's public?

Links and tickets

CUI-311, and part of CUI-295.

Good to know

New visual specs for Skeleton and the Table LoadingSkeleton story, with snapshots generated in Docker. No existing snapshot changed.

Checklist

  • Breaking changes? (add migration notes in changesets)
  • Visual changes? (specify in changesets) — a new component; Table only changes when you opt in
  • Design review needed?

Contribution

  • Sufficient research before PR
  • Self-reviewed the PR
  • Manually tested the changes (when applies - visual confirmation in Storybook) — stories checked in Chrome, both themes, including mid-sweep and with reduced motion
  • build and build-storybook work locally
  • Tests and Stories are aligned with the changes

Accessibility

  • Keyboard — not applicable: nothing interactive is added, and tab order is unchanged
  • Names — skeletons are always aria-hidden; the table is aria-busy while loading
  • Vision — colors come from tokens; the shimmer stops under prefers-reduced-motion

Checked: 4.1.2 Name, Role, Value and 2.3.3 Animation from Interactions. Not checked: the Storybook axe panel and a real screen reader.

Screenshots

See the Storybook preview: Display/Skeleton, and Display/Table → Loading Skeleton.

@changeset-bot

changeset-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 52ddc6e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clickhouse/click-ui Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/components/Table/Table.tsx Resolved
@mdevils

mdevils commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 6f0c360: the placeholders are now real <td>s, one per column, instead of bars inside the single spanned cell the spinner uses.

The first version was wrong about table structure — the bars did not line up with the columns they stand in for, and the DOM claimed one cell where the loaded table will have many.

That means the earlier note about control-has-associated-label no longer applies. What remains is no-aria-hidden-on-focusable: jsx-a11y treats <tr> and <td> as interactive, so marking a decorative row aria-hidden trips it. Neither element is focusable without a tabindex, so the two inline disables carry that reason rather than bending the markup around a false positive. Happy to take a different approach if you would rather not have the disables — the alternative I know of is giving every placeholder cell hidden text, which makes a screen reader read "Loading" once per cell.

The visually hidden "Loading data" text went away with the spanned cell; aria-busy on the table is now the whole announcement, as it is for Button.

Full suite green again locally: typecheck, lint (0 errors, suppressions file untouched), format, circular-dependency check, 654 unit tests, build, storybook:build.

@XOP
XOP requested review from DreaminDani and XOP September 25, 2026 16:28
@DreaminDani

Copy link
Copy Markdown
Contributor

Reassigning design review to @lifesized since his team uses this component way more than I do.

@DreaminDani
DreaminDani removed their request for review September 25, 2026 17:12
Comment thread src/components/Table/index.ts Resolved
Comment thread src/components/Table/Table.module.css Resolved
Comment thread src/components/Table/Table.tsx Resolved
Comment thread src/components/Table/Table.tsx Resolved
@XOP XOP added the enhancement New feature or request label Sep 28, 2026
`loading` draws a centered spinner, which gives no sense of the shape of
the data that is coming. `loadingVariant="skeleton"` draws placeholder
rows instead, with `skeletonRowCount` to choose how many.

The default is unchanged, so existing consumers see the spinner they have
today. The placeholder bars are decorative and the cell keeps the same
"Loading data" text the spinner variant announces, visually hidden, so
the state is still read out. The table sets `aria-busy` while loading in
either variant.
The first version drew the placeholders inside the single spanned cell
the spinner uses, which is not a table row: the bars did not line up
with the columns and the DOM said one cell where the data will have
many. Each placeholder is now a <td> per column.

jsx-a11y counts <tr> and <td> as interactive, so aria-hidden on a
decorative row trips no-aria-hidden-on-focusable. Neither is focusable
without a tabindex, so the two disables carry that reason rather than
reshaping the markup around a false positive.
The header count plus the selection and actions columns was spelled out
twice, once for the skeleton rows and once for the spanned loading and
no-data row.
Export TableLoadingVariant from the package root, size skeleton bars by table size, and drop needless cn calls.
Show the skeleton stories at full width with 6 columns of different widths and 10 rows, and add a story with merged skeleton cells. Add visual specs for Skeleton and the new Table stories.
Fix the gradient to the viewport so every skeleton shows a slice of the same wave, moving at the same speed whatever its size. Under reduced motion the gradient is dropped instead of freezing mid-wave.
Text skeletons draw one or more lines, the last of several at 75% width. Rectangles take a height. Width and height accept a space key or any CSS length, and props that do not fit the shape are type errors. The shimmer is now a 1.25s sweep of the fill's opacity with a 0.25s pause.
Remove colSpan from row cells, the merged-cells skeleton story, its test and its snapshots.
CSS animations start when their element mounts, so a skeleton added later swept out of step with the others. Pin each sweep to the document timeline's origin.
Pin the shimmer to the document timeline on animationstart instead of on mount, so animations created later (reduced motion turned off, a hidden parent shown) stay in phase. Leave consumer animations alone, drop the layout effect that warned during server rendering, and stop object properties such as toString passing as space keys.
A prefix check also matched consumer keyframes such as skeleton-shimmer-custom and pinned them. Match the exact name CSS Modules generates.
@mdevils
mdevils force-pushed the feat/table-loading-skeleton branch from ab2507c to 5a705a4 Compare October 14, 2026 10:12
@mdevils
mdevils requested a review from XOP October 14, 2026 15:41
Comment thread src/components/Skeleton/Skeleton.tsx Resolved
Comment thread src/components/Skeleton/Skeleton.tsx Resolved
Comment thread src/components/Skeleton/Skeleton.tsx Resolved
- Rename the rest props to `props`.
- `width` and `height` take plain CSS values; drop the space keys until the new token schema lands.
- Size text lines from the font: each bar is 1em tall in a 1lh line, using the `Text` font for its size, so skeleton text is as tall as real text. Table cells use `md`, their font at every table size, and lay the skeleton out like their truncated text, so placeholder rows match data rows.
- Animate only under `prefers-reduced-motion: no-preference`; the static fill is the default.
- Drop pinning the shimmer to the page clock. Skeletons on screen together still share one sweep through the viewport-fixed gradient.

@XOP XOP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the updates!

Animating background-position repainted every skeleton on every frame: about 5% of the main thread for a 10-row table, 12.5% for 60 rows. Each bar now shows a viewport-wide fixed layer, clipped to the bar, that slides with transform, so the browser animates it without repainting. Skeletons on screen together still share one sweep, without relying on background-attachment: fixed, which iOS Safari ignores.
@stoler
stoler self-requested a review October 15, 2026 16:57
@workflow-authentication-public

Copy link
Copy Markdown
Contributor

Storybook Preview Deployed

✅ Preview URL: https://click-k1l09zx31-clickhouse.vercel.app

Built from commit: 74927b4b5a397170a1766cd653b909f5cab112b5

@workflow-authentication-public

Copy link
Copy Markdown
Contributor

Chromatic Storybook

Check Status Link
Storybook ✅ 663 stories published Open Storybook
UI Tests ⏳ 8 changes must be accepted as baselines Open build

Built from commit: 52ddc6ec045c736568b21ccd3b8772ff9e8118b8 · Chromatic run

Statuses as of the end of the run. The build link shows the live review state.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 52ddc6e. Configure here.

@mdevils
mdevils merged commit b050934 into main Oct 16, 2026
10 checks passed
@mdevils
mdevils deleted the feat/table-loading-skeleton branch October 16, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants