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

Switch Composable Gets Clipped When Using Bootstrap CSS #631

Open
masah517 opened this issue Dec 16, 2024 · 5 comments
Open

Switch Composable Gets Clipped When Using Bootstrap CSS #631

masah517 opened this issue Dec 16, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@masah517
Copy link

YOUR BUG DESCRIPTION HERE

If relevant, specify:

  • OS: M1 Mac
  • Kobweb libs version: "0.20.0"
  • Kobweb CLI version: 0.9.18

Steps to Reproduce

  1. Import the Bootstrap 5 CSS in the module level build.gradle.kts.
<link 
    rel="stylesheet" 
    href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
/>
  1. Use the Silk Switch Composable
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
        //Text("THIS PAGE INTENTIONALLY LEFT BLANK")
        Switch(
            checked = true,
            onCheckedChange = {},
            size = SwitchSize.LG,
        )
    }
  1. Observe the size of the Switch.

Expected Behavior

The Switch should render correctly at its default size of 46px × 24px as shown when Bootstrap is not included.
(the SwitchSize.LG is used, and the default text size of my Chrome browser is 16.px)

スクリーンショット 2024-12-16 15 27 41

Actual Behavior

The size of the Switch gets clipped down to 39.984px × 17.984px when Bootstrap CSS is included, as attached screenshot below.
スクリーンショット 2024-12-16 15 27 25

Additional Context

I have prepared the basic project that can reproduce the above issue, so please kindly refer to it if required.
https://github.com/masah517/SwitchKobwebDemo

@masah517 masah517 added the bug Something isn't working label Dec 16, 2024
@masah517
Copy link
Author

The Chrome browser version is : 131.0.6778.140

@DennisTsar
Copy link
Collaborator

Thanks for the detailed report!

Bootstrap's styling is fairly opinionated and unfortunately by default takes precedence over some of Silk's styles. However, you can give the Bootstrap styles lower precedence by importing it within a CSS layer, as described in this section of the README. With that change, Switch works as expected.

I'd recommend importing the Bootstrap styles in a layer regardless, but we could also fix this specific issue by removing Switch's questionable use of box-sizing: content-box, which is the property causing the styling to break.

@masah517
Copy link
Author

@DennisTsar
Thank you for the prompt reply and for pointing me to the solution :)

I imported the Bootstrap styles within a CSS layer as suggested, and it resolved my issue perfectly.
Also good to know the clarification regarding the box-sizing: content-box property, which caused the conflict.

Thanks again for your quick and helpful response!

@masah517 masah517 reopened this Dec 16, 2024
@masah517
Copy link
Author

masah517 commented Dec 16, 2024

While using a CSS layer works well for me, I was wondering if there are any plans to remove the use of
box-sizing: content-box in the future?

I agree that using layers is a better solution overall, but I’m curious if this specific property might be revisited down the line.

@bitspittle
Copy link
Member

You can definitely leave this bug open! We can close it after investigating the property. Either we should remove box-sizing if it's not necessary or at least we can explain why we need to keep it?

Thank you Dennis for the quick analysis btw.

@bitspittle bitspittle self-assigned this Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants