Skip to content

feat(Table): Add whitespace below Caption#2515

Open
VincentSmedinga wants to merge 8 commits intodevelopfrom
feat/DES-1722-table-caption-side
Open

feat(Table): Add whitespace below Caption#2515
VincentSmedinga wants to merge 8 commits intodevelopfrom
feat/DES-1722-table-caption-side

Conversation

@VincentSmedinga
Copy link
Copy Markdown
Contributor

@VincentSmedinga VincentSmedinga commented Apr 1, 2026

Describe the pull request

Thank you for contributing to the project!
Please use this template to help us handle your PR smoothly.

What

  1. Applies a margin below a Table Caption.
  2. Adds instructions for making a Table Caption with both a Heading and additional content accessible.

Why

  1. There isn’t enough whitespace between the caption and the body of the table.
  2. While working on the spacing, I came across a best practice for the markup of a table caption with both a heading and a description, so I decided to document it. Moving this into a separate PR seems unnecessary – it’s in the Storybook package which doesn’t publish a changelog.

How

n/a

Checklist

Before submitting your pull request, please ensure you have done the following. Check each checkmark if you have done so or if it wasn't necessary:

  • Add or update unit tests
  • Add or update documentation
  • Add or update stories
  • Add or update exports in index.* files
  • Comment /chromatic test and verify visual regression tests pass
  • Start the PR title with a Conventional Commit prefix, as explained here.

Additional notes

  • At first, I also implemented an option to place the Caption below the Table. But that does’t seem to be so useful after all, so I’ve removed it again.
  • Then I added some documentation and an example of what I learned.

Allow positioning the caption below the table with `side="bottom"`.
Add explicit generic parameters to `forwardRef` in TableCaption so
TypeScript preserves the custom `side` prop.
Add an explicit type annotation to the Table compound component to
ensure sub-component prop types are not lost by `Object.assign`.
Copilot AI review requested due to automatic review settings April 1, 2026 11:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for rendering a table caption visually below the table via a new side="bottom" prop on TableCaption, with accompanying styling and design token support, and adjusts TypeScript typing to preserve compound-component subcomponent prop types.

Changes:

  • Add side?: 'bottom' to TableCaption and apply a ams-table__caption--bottom modifier class when set.
  • Update table caption styling to support bottom positioning and add configurable margins via CSS variables.
  • Strengthen TypeScript types for forwardRef usage and the Table compound component to preserve subcomponent prop types.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/Table/TableCaption.tsx Adds side="bottom" prop and modifier class; uses explicit generics on forwardRef for better prop preservation.
packages/react/src/Table/Table.tsx Adds explicit compound-component typing to preserve subcomponent prop types through Object.assign.
packages/css/src/components/table/table.scss Adds bottom-caption styling (caption-side: bottom) and margin handling for top vs bottom captions.
packages-proprietary/tokens/src/components/ams/table.tokens.json Introduces caption margin design tokens used by the updated SCSS variables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react/src/Table/TableCaption.tsx Outdated
@VincentSmedinga VincentSmedinga requested a review from a team as a code owner April 1, 2026 14:02
@github-actions github-actions bot temporarily deployed to demo-DES-1722-table-caption-side April 1, 2026 14:02 Destroyed
This is not really useful.
@github-actions github-actions bot temporarily deployed to demo-DES-1722-table-caption-side April 1, 2026 16:19 Destroyed
@github-actions github-actions bot temporarily deployed to demo-DES-1722-table-caption-side April 1, 2026 16:22 Destroyed
@VincentSmedinga VincentSmedinga changed the title feat(Table): Allow positioning the Caption below the table feat(Table): Add whitespace below Caption Apr 1, 2026
@VincentSmedinga VincentSmedinga marked this pull request as draft April 1, 2026 16:27
@github-actions github-actions bot temporarily deployed to demo-DES-1722-table-caption-side April 1, 2026 16:38 Destroyed
@VincentSmedinga VincentSmedinga marked this pull request as ready for review April 1, 2026 16:38
Copy link
Copy Markdown
Contributor

@RubenSibon RubenSibon left a comment

Choose a reason for hiding this comment

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

This PR's title and description does not seem to match the changes it makes. It also adds a Story. Can you adjust?

@RubenSibon
Copy link
Copy Markdown
Contributor

/chromatic test

The old one is outdated.

@RubenSibon
Copy link
Copy Markdown
Contributor

/chromatic test

The old one is outdated.

@Evi-2003, with the change to kick of the builds manually we do have to be alert if an existing build is out-of-date. It does add some cognitive load. It's absolutely not a major inconvenience, but still good to be aware of.

Copy link
Copy Markdown
Contributor

@RubenSibon RubenSibon left a comment

Choose a reason for hiding this comment

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

Adjust the test Story for Chromatic.

@VincentSmedinga
Copy link
Copy Markdown
Contributor Author

VincentSmedinga commented Apr 11, 2026

This PR's title and description does not seem to match the changes it makes. It also adds a Story. Can you adjust?

@RubenSibon Sure, I’ve updated the PR description. We don’t usually mention documentation changes in the changelog, so I’ve left the title alone.

I’ve added a Paragraph into the Table Caption of the test story as well, so Chromatic tests both the whitespace below the caption and the accessible name of the table.

@github-actions github-actions bot temporarily deployed to demo-DES-1722-table-caption-side April 11, 2026 20:31 Destroyed
@VincentSmedinga
Copy link
Copy Markdown
Contributor Author

/Chromatic test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants