Skip to content

Add Emotion container query utilities - #9264

Merged
tkajtoch merged 8 commits into
elastic:mainfrom
tkajtoch:feat/emotion-container-query-utils
Dec 16, 2025
Merged

tkajtoch merged 8 commits into
elastic:mainfrom
tkajtoch:feat/emotion-container-query-utils

Conversation

@tkajtoch

@tkajtoch tkajtoch commented Dec 9, 2025 •

Copy link
Copy Markdown
Contributor

Summary

Resolves #8964

This PR adds basic Emotion container query utilities to EUI: euiContainer(), euiContainerCSS(), and euiContainerQuery().

Why are we making this change?

Because CSS container queries are baseline now, and they are tremendously useful. They will be nice to have for some upcoming Kibana features.

Impact to users

New exports; no impact to users

QA

Remove or strikethrough items that do not apply to your PR.

  1. Go to https://eui.elastic.co/pr_9264/docs/components/containers/resizable-container/#horizontal-resizing
  2. Paste the following code into the interactive demo source field
    import React from 'react';
    import { EuiText, EuiResizableContainer } from '@elastic/eui';
    import { faker } from '@faker-js/faker';
    
    const text = (
      <>
        <p>{faker.lorem.paragraphs()}</p>
        <p>{faker.lorem.paragraphs()}</p>
        <p>{faker.lorem.paragraphs()}</p>
      </>
    );
    
    export default () => (
      <EuiResizableContainer style={{ height: '200px' }}>
        {(EuiResizablePanel, EuiResizableButton) => (
          <>
            <EuiResizablePanel initialSize={50} minSize="30%" tabIndex={0} css={euiContainerCSS('test-left', 'inline-size')}>
              <EuiText>
                <div>{text}</div>
                <a href="">Hello world</a>
              </EuiText>
            </EuiResizablePanel>
    
            <EuiResizableButton accountForScrollbars="before" />
    
            <EuiResizablePanel initialSize={50} minSize="200px" tabIndex={0} css={euiContainerCSS('test-right', 'inline-size')}>
              <EuiText css={css`${euiContainerQuery('(width > 300px)', 'test-right')} { background: red; }`}>{text}</EuiText>
            </EuiResizablePanel>
          </>
        )}
      </EuiResizableContainer>
    );
  3. Move the resizable horizontal bar left and right and observe the right side EuiText changing background color to red when the right side container width is smaller than 300px (excluding padding, so 332px total width)

@tkajtoch tkajtoch self-assigned this Dec 9, 2025
@tkajtoch
tkajtoch marked this pull request as ready for review December 12, 2025 17:15
@tkajtoch
tkajtoch requested a review from a team as a code owner December 12, 2025 17:15
@acstll
acstll self-requested a review December 15, 2025 12:02

@acstll acstll 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.

A single question regarding the API, everything else looking and working perfectly!

export const euiContainer = (
name: string,
type?: EuiContainerType,
scrollState?: boolean

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.

[no action required] I like this API to make it easy to understand/follow the spec, when it has 2 values "one must be scroll-state and the other can be inline-size or size" 👍

Comment on lines +36 to +37
name: string,
type?: EuiContainerType,

@acstll acstll Dec 15, 2025 •

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.

[question] I can understand the param order is matching the container shorthand, where the name is mandatory and the type is optional, but a container with the default type normal is not so useful, it only allows for style(--foo: bar) kind of queries…

it makes me wonder whether having type be optional could create confusion; consumers expecting euiContainerCSS('my-container') together with euiContainerQuery('(width < 600px)', 'my-container') to work…

have you considered inverting the param order and have the name be optional instead (falling back to none)?

  type: EuiContainerType,
  name?: string,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f00493b.

@acstll acstll 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.

🟢 Everything working as expected. I really like how the utils are aligned with the CSS spec. Thank you!

@tkajtoch
tkajtoch enabled auto-merge (squash) December 16, 2025 13:34
@elasticmachine

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @tkajtoch

@elasticmachine

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @tkajtoch

@tkajtoch
tkajtoch merged commit 3656752 into elastic:main Dec 16, 2025
weronikaolejniczak added a commit to elastic/kibana that referenced this pull request Jan 14, 2026
## Dependency updates

- `@elastic/eui`: `v111.0.0` ⏩ `v111.1.0`
- `@elastic/eui-theme-borealis`: `v5.2.0` ⏩ `v5.3.0`

---

## Changes

- Removed `euiBasicTable.tableCaptionWithPagination`,
`euiBasicTable.tableAutoCaptionWithPagination`,
`euiBasicTable.tableSimpleAutoCaptionWithPagination`,
`euiBasicTable.tableAutoCaptionWithoutPagination` i18n tokens
- Added `euiBasicTable.caption.itemCountPart.withTotalItemCount`,
`euiBasicTable.caption.paginationPart.withPageCount`,
`euiBasicTable.caption.tableName`, `euiBasicTable.caption.emptyState`
i18n tokens
- Updated snapshot tests
- Updated a couple of Jest assertions due to [this EUI
change](https://github.com/elastic/eui/pull/9254/changes)), see
127ab80

## Package updates

### `@elastic/eui`
[v111.1.0](https://github.com/elastic/eui/releases/tag/v111.1.0)

- Added `dashedCircle` icon
([#9278](elastic/eui#9278))
- Added `crossProjectSearch` icon
([#9275](elastic/eui#9275))
- Added component token `components.tourStepIndicatorInactiveColor` and
`components.tourStepIndicatorActiveColor`
([#9271](elastic/eui#9271))
- Remapped `EuiBeacon` component `success` variant to use `success`
color token instead of `accentSecondary`
([#9271](elastic/eui#9271))
- Added `EuiSplitButton` and its respective sub-components
`EuiSplitButton.ActionPrimary` and `EuiSplitButton.ActionSecondary`
([#9269](elastic/eui#9269))
- Added `productRobot` icon
([#9259](elastic/eui#9259))
- Added beta `euiContainer()`, `euiContainerCSS()`, and
`euiContainerQuery()` Emotion utilities to help work with CSS Container
Queries ([#9264](elastic/eui#9264))
- Added `useEuiContainerQuery` hook to observe container query changes
in JavaScript ([#9251](elastic/eui#9251))
- Updated EuiFlexGroup's `gutterSize` from `l` to `m`
([#9132](elastic/eui#9132))
- Updated EuiSpacer's `size` from `l` to `m`
([#9132](elastic/eui#9132))
- Updated EuiHorizontalRule's `margin` from `l` to `m`
([#9132](elastic/eui#9132))
- Updated EuiPageHeader's tab `size` from `l` to `m`
([#9132](elastic/eui#9132))
- Updated EuiEmptyPrompt's spacer `size` between title and text from `m`
to `s` ([#9132](elastic/eui#9132))
- Updated EuiSearchBar's `gutterSize` from `m` to `s`
([#9132](elastic/eui#9132))

<img width="2158" height="392" alt="image"
src="https://github.com/user-attachments/assets/e217f5a5-5b4f-48df-830d-a60861939945"
/>
<img width="1692" height="608" alt="image"
src="https://github.com/user-attachments/assets/d1f49e86-ad8c-4d80-9d02-54c73baae616"
/>
<img width="2182" height="302" alt="image"
src="https://github.com/user-attachments/assets/295c768c-a2df-48f5-80cb-1a1ce5b19e00"
/>
<img width="1904" height="1066" alt="image"
src="https://github.com/user-attachments/assets/f96cbde6-0529-4f5b-be5b-b56f28c5d2b7"
/>
<img width="1566" height="128" alt="image"
src="https://github.com/user-attachments/assets/be4df105-9e32-4a9d-89f0-fe973f441495"
/>

**Bug fixes**

- Fixed flyout overlay masks not being visible for `EuiDataGrid`'s
fullscreen mode by reducing the `z-index` of the fullscreen mode overlay
([#9267](elastic/eui#9267))

**Accessibility**

- Added information about the empty state of `EuiBasicTable` in the
table caption ([#9265](elastic/eui#9265))
- Improved `EuiBasicTable` accessibility by ensuring a fallback
`tableCaption` is applied if none is provided
([#9254](elastic/eui#9254))

### `@elastic/eui-theme-borealis` v5.3.0

- Added component token `components.tourStepIndicatorInactiveColor` and
`components.tourStepIndicatorActiveColor`
([#9271](elastic/eui#9271))
weronikaolejniczak pushed a commit to weronikaolejniczak/eui that referenced this pull request Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Emotion utilities to work with container queries

3 participants