Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiTitle] size prop not working when having css prop #7247

Closed
Alecton4 opened this issue Oct 3, 2023 · 3 comments
Closed

[EuiTitle] size prop not working when having css prop #7247

Alecton4 opened this issue Oct 3, 2023 · 3 comments
Labels
answered Issues answered by the EUI team - auto-closes open issues in 7 days if no follow-up response question

Comments

@Alecton4
Copy link

Alecton4 commented Oct 3, 2023

Key information

  • EUI version: 88.5.3
  • React version: 18.2.0
  • Build tool: Vite

Usage question

The size prop is ignored even when an empty css prop is applied. Is this behavior expected? I wish to have size="l" and css={{textAlign: "center"}} work together.

image

Minimum reproducible sandbox

https://codesandbox.io/s/compassionate-framework-2t8vnn?file=/demo.tsx

export const Demo = () => (
  <EuiFlexGroup direction="column" alignItems="center">
    <EuiTitle size="l">
      <strong>{"This is a title"}</strong>
    </EuiTitle>
    <EuiTitle size="l" css={{}}>
      <strong>{"This is a title"}</strong>
    </EuiTitle>
  </EuiFlexGroup>
);
@cee-chen
Copy link
Contributor

cee-chen commented Oct 3, 2023

EuiTitle itself is merging the css prop correctly. For your specific CodeSandbox example, it's missing a JSX pragma needed to make the css prop work:

https://codesandbox.io/s/nice-panka-7rtllh?file=/demo.tsx:0-39

If you're using the css prop in a local React app outside CodeSandbox, you'll need to make sure you have the correct babel setup or JSX pragma for Emotion. Please see https://emotion.sh/docs/css-prop for more information.

@cee-chen cee-chen added the answered Issues answered by the EUI team - auto-closes open issues in 7 days if no follow-up response label Oct 3, 2023
@Alecton4
Copy link
Author

Alecton4 commented Oct 4, 2023

@cee-chen Thanks for help! This was the first time I learned this pragma thing. After adding the /** @jsxImportSource @emotion/react */ pragma, the title works great.

However some other components changed in style, and I need to learn how to adjust further. If you have time, could you suggest some more readings and references on the impact of having/not having the pragma? Thanks!

@Alecton4 Alecton4 closed this as completed Oct 4, 2023
@cee-chen
Copy link
Contributor

cee-chen commented Oct 4, 2023

could you suggest some more readings and references on the impact of having/not having the pragma? Thanks!

Emotion's docs are the canonical source for that kind of information - I find myself going back to them often. For troubleshooting specific issues with your setup, I'd suggest searching through Emotion's GitHub repo (particularly their open/closed issues) - it's likely other devs have run into the same problems as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Issues answered by the EUI team - auto-closes open issues in 7 days if no follow-up response question
Projects
None yet
Development

No branches or pull requests

2 participants