Do slots need certain elements? #277
-
I have started to implement this player as part of our whole Mux solution. So far it is going well. I do have a question about the slots. I am trying to put some text into the top-chrome slot using
However if I do that the rendered div has 0 height and the text floats along the top edge of the media-controller. If I use an h1, h2, h3 etc instead of a div, like:
The rendered h2 element has the correct height and is placed just inside and along the top of the media-controller as expected. Is there a reason why certain elements such as div or p have this behaviour? Is it expected? Cheers |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
A little more digging and I see that the style :host sets the line height to 0, this seems to be causing the issue. So maybe it was by design and that we need to style our elements that are placed in the slots? Cheers |
Beta Was this translation helpful? Give feedback.
-
@streamworksaudio thanks for opening this! I have a small example here using The Depending on what you're after, you might find it handy to use Here's some more docs about using slots, which are admittedly pretty hard to find right now, so I'm guessing you didn't see this: https://github.com/muxinc/media-chrome/blob/main/docs/media-controller.md#layout---slots Let me know if that helps! |
Beta Was this translation helpful? Give feedback.
-
Going to mark this as answered, but happy to amend if we'd still like this open (same to you, @streamworksaudio) |
Beta Was this translation helpful? Give feedback.
@streamworksaudio thanks for opening this!
I have a small example here using
top-chrome
, which seems to be working as expected: https://codesandbox.io/s/media-chrome-slots-wid6ndThe
top-chrome
slot is pretty un-opinionated as far as applying any default styles, so if you're using a<div>
you'll definitely have to give it some of your own styles (which gives you a lot of flexibility).Depending on what you're after, you might find it handy to use
<media-control-bar slot="top-chrome">
, the control bar has some default styles applied.Here's some more docs about using slots, which are admittedly pretty hard to find right now, so I'm guessing you didn't see this: https://github.com/muxinc/me…