-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Attach elem_classes
selectors to layout elements, and an id to the Tab button (for targeting via CSS/JS)
#5590
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/bae6a1ebcbd832f00c2b2b47cd22a28e5be89683/gradio-3.44.4-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@bae6a1ebcbd832f00c2b2b47cd22a28e5be89683#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
elem_classes
selectors to layout elements, including the TabItemelem_classes
selectors to layout elements, including the TabItem button
elem_classes
selectors to layout elements, including the TabItem buttonelem_classes
selectors to layout elements, and an id to the Tab button (for targeting via CSS/JS)
js/tabs/static/Tabs.svelte
Outdated
<button class="selected"> | ||
<button | ||
class="selected" | ||
{...elem_id ? { id: t.elem_id + "-button" } : {}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Svelte if you set an attribute to null it gets removed. That might be a slightly cleaner way of expressing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice. Figured there'd a nicer way. Will update
Nice! just tested and everything looks good. Small nit: wondering if we should name the tab button |
Thanks @dawoodkhan82 for reviewing! I don't think we need to be more specific, users can select by |
This PR does two things:
It passes the
elem_classes
attribute to the Blocks layouts (e.g. Row, Accordion, Tab, etc.) We had these attributes set up correctly in the frontend, but we were never passing them in from the frontendFor the
TabItem
, theelem_id
would get attached to the div holding the tab contents. We now also attach an{elem_id}-button
to the button that you click on to select the tab. This closes: Add id, class, and or attribute to a Tab's button #5585Test code: