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

Allow app to fill width #8651

Merged
merged 5 commits into from
Jul 11, 2024
Merged

Allow app to fill width #8651

merged 5 commits into from
Jul 11, 2024

Conversation

aliabid94
Copy link
Collaborator

@aliabid94 aliabid94 commented Jun 27, 2024

Useful for dashboards and other complex apps that want to use all the screen space.

Closes: #8201
Closes: #6732

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jun 27, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detecting...

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/671c117f6be50a9f2b5cb3557769e6b1320d3609/gradio-4.37.2-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@671c117f6be50a9f2b5cb3557769e6b1320d3609#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-builds.s3.amazonaws.com/671c117f6be50a9f2b5cb3557769e6b1320d3609/gradio-client-1.2.1.tgz

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jun 27, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/app minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Allow app to fill width

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs
Copy link
Member

Niceee I just needed this for the app I'm building 😆

@abidlabs
Copy link
Member

Two quick comments:

(1) I think .launch() would be a better place to put this parameter. I know we put a lot of global styling features in gr.Blocks like css and theme but this doesn't make sense since Blocks can be nested within other Blocks and only the style parameters in the outer Blocks apply.

(2) Not a strong opinion, but instead of a boolean, should we make this a more flexible parameter that can take in a specified width e.g. full width corresponds to 100%. And the default setting could be a tuple of ints corresponding to the current widths at different screen breakpoints

@aliabid94
Copy link
Collaborator Author

(1) I think .launch() would be a better place to put this parameter.

We already have fill_height in gr.Blocks() though

Not a strong opinion, but instead of a boolean, should we make this a more flexible parameter that can take in a specified width e.g. full width corresponds to 100%. And the default setting could be a tuple of ints corresponding to the current widths at different screen breakpoints

I don't think that's necessary until we see a request for it, seems like overkill.

@abidlabs
Copy link
Member

abidlabs commented Jun 28, 2024

We already have fill_height in gr.Blocks() though

Ah good point, ok then

I don't think that's necessary until we see a request for it, seems like overkill.

Hmm but would be a breaking change (or redundant api) if we do get requests for it

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Nice - also agree Blocks init is the best place for the parameter

@abidlabs
Copy link
Member

abidlabs commented Jun 28, 2024

Ok the Blocks init is fine, but just a few things:

  • On very wide screens, this will cause Gradio apps to look very stretched out and distorted. Instead of a boolean parameter, do you think we should set a higher max width instead of 100%
  • This parameter doesn't seem to have any effect on Spaces: compare https://huggingface.co/spaces/abidlabs/fill-width and https://huggingface.co/spaces/abidlabs/fill-width-2 -- I think its due to the fact that Spaces adds its own margin around the iframe. Can we work with Spaces to fix that?
  • Can we add fill_height and fill_width to Interface and ChatInterface as well?

Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks @aliabid94!

@aliabid94
Copy link
Collaborator Author

On very wide screens, this will cause Gradio apps to look very stretched out and distorted. Instead of a boolean parameter, do you think we should set a higher max width instead of 100%

There is already a max-width set by gradio's container that's meant to prevent this. When you set full_width to True, you are specifically asking to skip this, so we should take all the width in this case.

This parameter doesn't seem to have any effect on Spaces: compare https://huggingface.co/spaces/abidlabs/fill-width and https://huggingface.co/spaces/abidlabs/fill-width-2 -- I think its due to the fact that Spaces adds its own margin around the iframe. Can we work with Spaces to fix that?

I'll message Spaces team

Can we add fill_height and fill_width to Interface and ChatInterface as well?

Done.

@aliabid94 aliabid94 merged commit 1500b89 into main Jul 11, 2024
9 checks passed
@aliabid94 aliabid94 deleted the fill_wifth branch July 11, 2024 19:53
@pngwn pngwn mentioned this pull request Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants