-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Custom Components] Support Named Slots in svelte #8706
Comments
cc @pngwn |
Very interesting. I'll have to think about this a little. |
On reflection, I think it might be better to match the Svelte API for this where the slot name is a parameter on the thing being slotted: with CustomComponent():
gr.Button() # default slot
gr.Button(slot="extra") # named slot We could potentially use this mechanism ourselves for things like icons etc in the future. Imagine this: with gr.IconButton() as btn:
gr.Markdown("**Important button**")
gr.icons.Warning(slot="icon") |
We could even expose html primitives for quick bits of UI, food for thought. |
LGTM. One last question, it looks like we can't add multiple components to a named slot in this way. with CustomComponent():
gr.Button() # default slot
# expected to be rendered in order in <slot name="extra" />
gr.Button(slot="extra") # named slot
gr.Button(slot="extra") # named slot Similar usage to with CustomComponent():
gr.Button() # default slot
# expected to be rendered in order in <slot name="extra" />
with gr.Fragment(slot="extra"): # named slot
# default slot
gr.Button()
gr.Button() |
Yeah maybe, I guess that would reduce the API surface area a little an provide a more explicit API. |
Is your feature request related to a problem? Please describe.
Custom components can only use
Default Slot
in svelte currently, therefore it cannot provide more customized layout configurations for users. I'm wondering if gradio can provide a component likegr.Slot
to supportNamed Slot
.Describe the solution you'd like
This is a sample to use
gr.Slot
:app.py
custom_components/Index.svelte
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: