Resources

Workflow Demo Live Q&A - January 31st

video
Feb 1, 2024
28:18

image: thumbnail.jpg

Transcript#

This transcript was generated automatically and may contain errors.

Thank you all so much for joining us today and for joining us here in our live Q&A room and spending time with us this Wednesday. A special thank you to Garrett for the awesome demo.

And as a reminder, if you want to ask any questions here in the Q&A, you can do so anonymously using the same Slido link I shared before. I'm going to show it on the screen here as well at pos.it slash demo questions. So you can use that to ask any questions anonymously, or you can just put them straight into the YouTube chat here.

I usually save this for the end, but I think it's worth saying here with everybody as well, if you do want to end up doing a trial of Posit Workbench or Connect, which you saw today in Garrett's demo, you can also use the link I'll show on the screen here to chat with our team and receive an evaluation environment. I'm sure they'd love to chat more about your team's use case.

Introductions

But thanks again for joining us. We have a few special guests joining here alongside Garrett as well. So I'd love to have us all introduce ourselves and maybe share a fun fact of where is your favorite vacation spot?

Hey, everybody. I'm Ryan. So I've been on a few of these demos now we've been doing since, gosh, I feel like it's been like almost a year now. But it's great to see so many folks joining these sessions. So I'm a data science advisor here at Posit. And I guess my favorite vacation spot is probably Maine. I had a great grandmother that lived in Maine. I loved going up there. It's been a little while, but I love the outdoors and Maine's pretty awesome.

Well, hi, everybody. Thank you for attending my webinar. My name is Garrett. I work in developer relations at Posit. And I'm a recent resident of the Tampa Bay area. So I like to go back there to visit friends, but also like Clearwater Beach is just excellent. So that's my favorite vacation spot.

Hi, I'm Garrett. I'm a developer on the Shiny team at Posit. And I think my favorite vacation spot would be somewhere in the mountains with a river that I could go whitewater rafting on.

Hi, yeah, I'm Carson, also an engineer on the Shiny team. And my favorite vacation spot would have to be Southern California, probably particularly near San Diego area. Love to golf, so love to golf in that area.

And I didn't introduce myself, but I'm Rachel Dempsey. I lead customer marketing here at Posit. And it's hard for me to pick favorites, but I think my favorite spot would be Block Island, Rhode Island, which is a little island I like to go to every summer.

BSLib and Shiny Dashboard compatibility

So I want to make sure I cover some of those that were in the demo, and then I'll jump into the ones here. But one of the first questions I saw was, does BS Lib work with Shiny Dashboard?

No, it does not work with Shiny Dashboard. But the good news to that is we view BS Lib at being at a stage now where we view it as superseding Shiny Dashboard. So a lot of the components that you use in Shiny Dashboard, you'll find modern replacements for BS Lib. So we have things like cards and sidebar layouts. And also things you won't find, like tooltips and popovers that will add some really nice additional functionality to your dashboards. And then, of course, you get all like sort of the rich theming infrastructure that comes with BS Lib as well.

So but, you know, technically speaking, there was just some challenges with updating Shiny Dashboard from, you know, it uses this framework called Admin LTE, which was built on Bootstrap 3. So bringing up both of those dependencies to modern versions, there was just kind of some technical complexity with that, where we decided to kind of go in a different direction where we decided that we would actually kind of build out these components in BS Lib instead of depending on a framework that was struggling to keep up to speed with modern practices.

So I know there is a few things, probably the biggest thing is sidebar navigation. I think I've seen at least one question about this, where we don't have an answer for, you know, with Shiny Dashboard, you can have kind of like links that navigate to different sections of content in your dashboard. And we don't have a great answer for that in BS Lib at the moment. But it's probably, you know, at the top of our priority list for new UI work coming for BS Lib.

Dynamic cards and layout columns

I see Oliver asked, thanks for the great talk. Do you know if BS Lib layout columns would allow me to add cards dynamically depending on the user inputs?

Well, I could take a stab at this. First of all, I would say I'm a user of these packages. And then I'm really glad that Garrett and Carson are here because they're developers and they could correct me if I'm wrong. But if you think of, I don't know if you have previous experience with Shiny, but if you create UI dynamically, what you can do is Shiny and then maybe use fluid rows and columns to place that in your app or create a chunk of input that uses those. The same thing happens with layout columns. So I think the answer is yes, although I haven't tried it yet.

Yeah, I'll go on record and say that was spot on, that the best way to do that is to use dynamic UI, bring your layout columns into the server, create your cards there, and that way you can have a dynamic number of cards.

BSLib conflicts with Shiny widgets

Another question from YouTube is, will BS Lib have any conflicts with Shiny Dashboard or Shiny widgets?

Yeah, I'm kind of vaguely aware that, I mean, this was kind of entangled with that technical problem of bringing Shiny Dashboard up to a modern version. A bootstrap is, if we are to do that, we are kind of asking the greater ecosystem of Shiny packages to move along with us, to moving, you know, all the code that they've written that is targeting a certain version of bootstrap. Like if we just update the dependencies of these kind of core packages, then we're kind of asking the greater community to come along that ride with us.

Yeah, so I know there's vaguely some issues with Shiny widgets working with Bootstrap 5. And if you're using BSLib components like cards and sidebar layouts, like our modern answers for dashboarding, they're going to require you to use Bootstrap 5. So yes, there might be some issues with using certain widgets from Shiny widgets inside of a BSLib dashboard that is using Bootstrap 5. But hopefully that situation continues to improve, and the maintainer of Shiny widgets will continue to make their stuff more compatible with modern versions of Bootstrap.

Resources for learning BSLib

Another question from a bit earlier was, what resources would you recommend to read around BSLib and other aspects of styling in Shiny?

Sure. So BSLib has a homepage. If you search the web for BSLib, you can find the documentation homepage. And we have a number of articles there, including several getting started articles. Some of them are around theming. And they give you a good place to start if you're wanting to learn how to theme your apps with BSLib. And there's also another article that if you're interested in learning more about how to create dashboards with BSLib, under Getting Started, there's an article called Shiny Dashboards. And it's a great place to start to get familiar with the sort of dashboard layouts and components that BSLib can provide.

Can I just second that? Because that's how I've learned to use BSLib, and that website is so thorough. Like, it's really well done. It surpasses what you might think of as documentation. It's really like a learning portal.

Shiny for Python compatibility

Another question over from YouTube was, are the packages presented in this session also compatible with Shiny for Python?

I don't know 100% of the packages that were presented. But I guess I'll say there's probably a decent chunk of the stuff that you've seen that is available in Shiny for Python. So, you know, we've been talking about BSLib. And kind of the two big main features of BSLib is the custom theming aspect and the suite of components that allow you to build nice-looking dashboards. Definitely that suite of components. You'll find the same, you know, you'll find layout columns, you'll find cards, you'll find layout sidebar. You'll find all of these things in Shiny for Python. Currently at the moment, we don't have as rich custom theming abilities in Shiny for Python. But that is certainly higher up on our priority list for giving you an experience that is close to the experience that you get with BSLib with custom theming. That doesn't mean you can't do custom theming in Shiny for Python. It's just a little bit different of an approach that's maybe a little bit harder to get started with and more technically difficult. But it's certainly possible if you have the drive for figuring out how to do it. There's nothing preventing you from writing CSS. Just put it that way.

Shiny Express

This isn't necessarily a question, but I saw a lot of excitement the past two days about Shiny Express. And I was just wondering if either of you from the Shiny team could share a little bit about that.

So Shiny Express is essentially like a new syntax mode for writing Shiny apps in Python. So it allows you to essentially intermingle UI and server code. So instead of having a separate UI object and a separate server function, you get to essentially mix the two, which allows you to write more succinct Shiny code where you can essentially write a render function directly in a script. And then that effectively transforms itself into an output container with a server render function.

So Shiny Express itself is built on Shiny, what we're calling Shiny core, which is the way that you're used to writing Shiny apps in R essentially. And that way of writing Shiny apps is not going anywhere. We kind of view that as the way that you're going to want to write Shiny apps on a project where you really value long-term maintainability and flexibility. Because Express, like it says in the name, does take some shortcuts to make it easier to learn and write Shiny apps, but it's going to be a little bit more restrictive in what you're able to do with it. So we're hoping it's going to be a nice on-ramp for people. It's a lot quicker to get started. Even development-wise, it's really nice to type less to create an example.

But again, for more serious projects where you're going to want to put this thing in production and test it and work on a team of people potentially to develop this app and write good modular code, the classic way of writing Shiny apps is still, we think, best in that kind of context.

But again, for more serious projects where you're going to want to put this thing in production and test it and work on a team of people potentially to develop this app and write good modular code, the classic way of writing Shiny apps is still, we think, best in that kind of context.

And Shiny Express is solely for Python at the moment, right? It is solely for Python. It's not like we couldn't bring this to R as well. But one thing also worth pointing out here about Shiny Express and the possibility of bringing it to R is that we already have something that feels pretty close to Shiny Express with our markdown documents with runtime Shiny mode. If you look at Shiny Express apps, they're quite similar to that same style of with your RMD document with runtime Shiny, you can essentially just inline a render plot statement and then it renders a plot there that's fully interactive. It's a very similar kind of concept and style for Shiny Express.

Shiny UI editor and theme preview

Another question asked over on Slido was, can you remind us of the manual point and click package to create Shiny apps? And can this be integrated with what was shown today?

I think this is referring to the Shiny UI editor. So that would be, let's see, it's a package, also a VS Code extension. You can search for Shiny UI editor and it's a way to basically pick out components, kind of drag them into your app and kind of get the skeleton of a UI for your Shiny app and to build that really quickly. So I'd recommend looking at that. The other thing that Garrick demoed today was the themer or the theme preview. So VS lib, VS theme preview. You can use that. You can even, I'm forgetting the exact function, but you can use a similar function to run the theme preview for your own app, kind of inject the dynamic theming into your app, which is what we saw today.

BSLib and Quarto

So I saw a few questions that touched on Quarto and how VS lib works with Quarto. This specific one is, are VS lib and thematic useful for creating Quarto presentations with reveal JS?

One of the things that I'm really excited about with VS lib is that when you're learning VS lib, a lot of the skills that you learn are ultimately transferable to a lot of different places in the Shiny ecosystem. And this is a good highlight of one of those ways. So as you're learning how to use VS lib to theme Bootstrap in particular, Quarto uses a very similar setup to theme presentation slides, HTML documents in general, which is all kind of based around using the variables that Bootstrap provides and a package called sass, which is basically a command line tool for rendering CSS. What it does is it lets you customize CSS with things like your own colors or your own fonts or lots of different things. There's lots of different ways that you can change the theme, how Bootstrap looks. And the way that you do it with VS lib is very, very similar to how you approach that problem with Quarto. Also similar to how you approach it with theming our markdown documents and a number of other things.

Yeah, and the one small thing I had about thematic is the automatic detection of colors and fonts might not work in reveal JS presentations. And actually with Quarto, I'm pretty sure there's only like the automatic detection stuff only really works in our markdown. I don't think it works currently at all with Quarto, but it still gives you high level parameters for saying, you know, here's a background color. Here's a foreground color and here's a font and here's an accent color. So it still simplifies and distills like these kind of main color and font ideas and translates that to your R plots. You'll just have to do a little bit of work of, you know, bringing in those colors and fonts into thematic as well.

Flex dashboard theming

Another question was, will changing themes and colors for a shiny flex dashboard work the same way as demonstrated?

Yeah. So flex dashboard is based on our markdown. It's a way of creating dashboards using our markdown. It's sort of now it's the predecessor to Quarto dashboards. BSLib lets you customize the theme of our markdown documents. The syntax for doing that is a little bit different from what we saw today, where you have to make those changes in the YAML front end. You have to make those changes in the YAML front matter of the document rather than in the code. But beyond that, it's a pretty similar process in terms of figuring out which parts of the theme you want to change and basically setting those variables and values. That's also covered in the BSLib documentation page, so you can find some information about styling and theming our markdown documents there.

Screen width and responsive layouts

But one I saw over on Slido was, can you talk about issues related to shiny apps with different screen widths? This app is only built to be shown on full screen. Is there any way to be more flexible?

I'd say that a lot of it is built around looking or trying our best to look good at all different screen sizes. One of the things that I noticed in this one was that we were in this app. We were zooming in quite a bit to try to make sure that everything was readable for the video. And I think the experience if you are developing locally or if you were actually looking at the app on your desktop would be a little bit different. We also in the last year introduced an idea of fillability. This is a slightly advanced concept, but we have some nice articles on the BS Lib page that can help with that. The general idea is that, especially in dashboards, you have these UI components or you have plots where they really want to take up the full height and width of the cell that they're in. So you kind of want to have a plot that fills up the entire card rather than being just a fixed size. And often playing with the settings for whether something is fillable, as in it fills its container. You can get to different layouts. It depends a lot on the type of thing that you're trying to put into your dashboard.

Thematic and Plotly

Does thematic work well with Plotly?

It's funny, we were just talking about this in private before the chat here. But partially, yes. If you're using ggplotly, then Plotly does a little bit of extra work to make sure that the result that you would get with ggplot2 and thematic is going to be the same as what you'll get with ggplotly in Plotly. But if you're using the core Plotly API, if you're not using ggplot2 at all, then the Plotly graph will not respect whatever you're doing with thematic. And it would be nice to, I don't know if the answer is for Plotly to respect thematic, but I think Plotly could certainly do a little bit more to be, at least give you an option to say, I want to be informed, like whatever styling is in my container in the Shiny app, this Plotly graph should use, inherit those styles a little bit better. So I would like for that to be a feature someday, for sure.

Closing and getting involved

Well, thank you all so much. I will go through and just see which questions we might have missed and send them over to you, if that's okay, to make sure that we get to those too. I did notice that some people had given some suggestions for topics they'd like to cover in some of these sessions. So I just wanted to remind everybody that we host these workflow demos the last Wednesday of every month. And the topics that we cover come from suggestions that we receive from you all as well. So if you want to later on comment in the YouTube chat or just comment here now, if there's something that you'd like to see, please let us know. We'd love to hear from you.

If people have further questions about BSLib or feedback or want to get involved with the package, what's the best way to do that? Sure. Definitely through our GitHub page. You can search for rstudio slash BSLib on GitHub. And we are always happy to answer questions in our issues and to listen to feedback and help out.

I just want to say thank you again to everyone for attending the workshop. And for those of you who sang, that was beautiful. I'm going to edit that part out of the recording so nobody can replay that part.

Well, thank you all so much for joining us today. I did just put the link into the chat. If you do want to join us again, we have these the last Wednesday of every month. That link in the chat will add them all to your calendar. But thank you so much for joining us. Have a great rest of the day, everybody.