A plugin to generate st.
commands with their corresponding parameters and values, based on the components from our existing Figma Design System.
Warning Heads up! This is an experiment from our design team. We’re releasing early to get feedback, and there’s a lot of stuff missing. If you find this useful, please contribute! See our contributing section below.
Go to our community profile, select the plugin and hit Try it out
. Then, in Figma, run it from the Plugins
tab.
This plugin is complementary to our official Design System library. Select a component instance, tweak its props and values, and hit See my code
to get a code snippet you can use in your Streamlit app! Check out the video below to get a sense of how to use it 👇
Intro.mov
If you are running into any errors while using the plugin, check out the tips below to get unstuck:
- Make sure you're using our official Design System library to generate your code snippets.
- Make sure to keep both the Design System library and the plugin up to date with the latest versions.
- The plugin is tightly bound to the Figma library's naming convention and layer structure, so we advise you to avoid renaming layers. Of course, you can update text values, change variations, but make sure layer names remain untouched.
- Make sure you are generating the code using component instances, and not from the main component. You can get a refresher on Figma's components and instances here.
- Do not detach the components.
- In the spirit of releasing early and often, this plugin currently supports a subset of the full power from our open-source library. We're adding support for new widgets and props periodically, but you might hit an
unsupported widget
error with some of our Figma components. Feel free to reach out and let us know which widgets you'd like us to work on next! - Similarly, a few of our components are too complex to edit in Figma and recreate their code (think charts, dataframes, tables). For those, we're using placeholder snippets, allowing you to implement a generic version of the widget in your app, with a limited set of functionality.
If you are still facing issues after reviewing the pointers above, feel free to file an issue and we'll try to get to it as soon as we can. Or even better, check out our contributing guidelines and give it a try at fixing it yourself!
The latest version of the plugin features support for the following widget categories:
- Text elements, except for
st.latex
andst.markdown
. - Input widgets, except for
st.select_slider
. - Native Chart elements (that is,
st.line_chart
,st.bar_chart
,st.area_chart
,st.map
)
Warning Friendly reminder: Keep in mind this is an experiment from our design team. We’re releasing early to get feedback, and as you can see, there’s a lot of stuff missing. If you find the plugin useful, please contribute! See our contributing section below.
We're evaluating/planning on adding support for the following in the future (in no particular order):
- Media elements.
- Progress and Status.
- Data display elements.
- Layout and Containers.
- Control flow (mainly
st.form
andst.form_submit_button
).
st.markdown
, recognizing bold, italic, underline andstrikethroughtext format.label_visibility
param modifier for input widgets.- Support for optional properties, such as
language
inst.code
,file_name
onst.download_button
, amongst others. - Global page config through st.set_page_config.
- Plugin settings, such as the ability to add optional arguments to your snippets, such as
key
oranchor
for text elements, ability to toggle imports on/off, amongst others.
- Adding example callbacks for some input widgets, to extend their functionality.
- Refactoring, type annotations, an automated way to pipe widgets and data to the plugin, and a lot of other internal improvements.
Want to see something else added on this list? File an issue and let us know your ideas! We'll take a look and hopefully add it at some point to the roadmap.
Do you have any ideas or improvements on what we currently support with the plugin? Or found a bug that you couldn't figure out with our troubleshooting guide? Want to ask us a question? Feel free to use our issue tracker to let us know, and we'll do our best to get to your question soon!
Warning Third time's a charm. Remember, this is an experiment from our design team. We’re doing this on the side, along with the rest of our normal work stuff, so please be patient if you don't get a reply right away. And if you find the plugin useful, please contribute! See our contributing section below.
Thanks for your interest in helping with this plugin's development! Please see the instructions below to install everything locally, and contributing guidelines.
If your contribution is more than a few lines of code, then prior to starting to code on it please post in the issue saying you want to volunteer, and then wait for a positive response. And if there is no issue for it yet, create it first!
This helps make sure:
- Two people aren't working on the same thing;
- This is something maintainers believe should be implemented/fixed;
- Any API, UI, or deeper architectural changes that need to be implemented have been fully thought through by our maintainers;
- Your time is well spent!
Ready? Let's go! 🚀
Below are the steps to get the plugin running in your machine. You can also find more detailed instructions in Figma's setup guide.
- First, check if you have node installed on your machine by opening a terminal window and running:
node -v
- If the command above outputs a version number, then you can safely skip this step. If you don't get anything back, or get a
node command not found
error, you need to download Node.js which comes with NPM. This will allow you to install TypeScript and other libraries. You can find the download link here. - After installing Node, install Typescript by running the following command in a terminal window:
npm install -g typescript
- After you've installed these global libraries, you need to clone the repo in your working directory:
git clone https://github.com/streamlit/figma-to-streamlit
- Then, enter the
figma-to-streamlit
directory andnpm install
the plugin's dependencies:
cd figma-to-streamlit
npm install
- After dependencies are installed, build the plugin by running:
npm run dev
If all goes well, you should see an output similar to the following on your Terminal 👇
Make sure to keep the process running while you are developing to automatically watch the files for changes.
After you've completed the setup instructions above, it's time to run the plugin in Figma.
- First, Get the Figma desktop app if you don't have it, since you need the desktop version to develop the plugin locally.
- Log in to your Figma account and open the file editor in the Figma desktop app. You can open any existing document or create a new one.
- Go to
Menu > Plugins > Development > Import plugin from manifest...
, find thefigma-to-streamlit
folder you've cloned above, locate themanifest.json
file, and open it. - In the
plugins
tab, you should now seeFigma to Streamlit
underDevelopment
, and you can run it by hovering over it and clickingRun
, or by going toMenu > Plugins > Development > Figma to Streamlit
. - That's it! You might want to open the console tab by hitting
Cmd + Shift + I
as well, for easier development flow.
This plugin is completely free and open-source, licensed under the Apache 2.0 license.