Skip to content

[Bug]: Table header not respecting container-level dark mode #4111

@TrevorBurnham

Description

@TrevorBurnham

Browser

No response

Package version

v3.0.1156

React version

No response

Description

I have a table that renders inside of a div with the dark mode class. Previously, that table rendered with the correct dark mode styles. However, the background color in the table header recently became incorrect:

Image

To be clear, the table looks fine if the whole page is in dark mode. The styles are only broken if the page is in light mode but the container around the table is in dark mode.

Source code

No response

Reproduction

Add this demo to pages/table/dark-mode-container.page.tsx and run npm start:dev:

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import Header from '~components/header';
import Link from '~components/link';
import Table, { TableProps } from '~components/table';

import ScreenshotArea from '../utils/screenshot-area';
import { ARIA_LABELS, createSimpleItems, simpleColumns } from './shared-configs';

const items = createSimpleItems(5);

const columnDefinitions: TableProps.ColumnDefinition<(typeof items)[number]>[] = [
  {
    id: 'text',
    cell: item => <Link>{item.text}</Link>,
    header: 'Text',
  },
  {
    id: 'number',
    cell: item => item.number,
    header: 'Number',
  },
];

export default function DarkModeContainerPage() {
  return (
    <>
      <h1>Table in dark mode container</h1>
      <ScreenshotArea disableAnimations={true}>
        <div className="awsui-dark-mode" style={{ padding: '20px', background: '#0f1b2a' }}>
          <Table
            header={<Header>Table in dark mode</Header>}
            columnDefinitions={columnDefinitions}
            items={items}
            ariaLabels={ARIA_LABELS}
          />
        </div>
      </ScreenshotArea>
    </>
  );
}

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions