Created
October 8, 2022 17:48
-
-
Save AnnMarieW/a224ef5fa1cc66ed228b396a4467c6cc to your computer and use it in GitHub Desktop.
Display a file directory using dmc.Accordion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dash import Dash | |
import dash_mantine_components as dmc | |
from dash_iconify import DashIconify | |
app = Dash(__name__) | |
pages = ["home.py", "page1.py", "page2.py"] | |
assets = ["mycss.css", "app.png", "page1.png"] | |
def make_file(file_name): | |
return dmc.Text( | |
[DashIconify(icon="akar-icons:file"), " ", file_name], style={"paddingTop": 10} | |
) | |
def make_folder(folder_name): | |
return [DashIconify(icon="akar-icons:folder"), " ", folder_name] | |
file_dir = dmc.Accordion( | |
[ | |
dmc.AccordionItem([make_file(f) for f in assets], label=make_folder("assets")), | |
dmc.AccordionItem([make_file(f) for f in pages], label=make_folder("pages")), | |
], | |
multiple=True, | |
) | |
app.layout = dmc.Container([file_dir, make_file("app.py")]) | |
if __name__ == "__main__": | |
app.run_server(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment