-
Notifications
You must be signed in to change notification settings - Fork 24
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
Make the current doc more visible in the sidebar. #84
Comments
Hi @NOTMEE12 This is a good suggestion - thanks. The styling would work properly in both light and dark modes by setting The ideal solution would be to have the Here's the dbc.Navlink https://dash-bootstrap-components.opensource.faculty.ai/docs/components/nav/
|
Hi! I've searched a little and plotly dash has a |
Here's a working concept: from dash import Dash, _dash_renderer, dcc, Output, Input, ALL, callback
_dash_renderer._set_react_version("18.2.0")
import dash_mantine_components as dmc
dash = Dash(__name__)
# this works best with IDs without spaces in them (because they will be converted)
navlinks = [f"CustomElement{i}" for i in range(20)]
dash.layout = dmc.MantineProvider(
forceColorScheme="light",
children=[
dmc.AppShell([
dmc.AppShellNavbar([
dmc.NavLink(
label=navlink,
id={"type": "nav", "index": idx},
href=f"/{navlink}",
variant="light",
color="gray"
)
for idx, navlink in enumerate(navlinks)
])
]),
dcc.Location(id="url")
]
)
@callback(
Output({"type": "nav", "index": ALL}, "active"),
Input("url", "pathname")
)
def update_nav(pathname: str):
out = [False] * len(navlinks)
idx = int(navlinks.index(pathname.lstrip("/")))
out[idx] = True
return out
dash.run() |
Oh, yes, that's a great workaround until DMC 365 is completed. Would you like to do a PR? |
I have been using this work-around strategy in my app: |
Instead of a seperate index counter, you can just use the URL as the index. Makes it a bit shorte. # Create Navlinks
[
dmc.NavLink(
label=f"{page['name']}",
href=page["relative_path"],
id={"type": "navlink", "index": page["relative_path"]},
)
for page in page_registry.values()
]
# ...
# Callback
@app.callback(Output({"type": "navlink", "index": ALL}, "active"), Input("_pages_location", "pathname"))
def update_navlinks(pathname):
return [control["id"]["index"] == pathname for control in callback_context.outputs_list] |
@demk0r - are you on the dmc discord? Just wanted to mention you there 🙂 |
I look at DMC docs really often and it would be nice to have a little indicator or maybe a background color change on the currently selected doc (I think that a background color change or a border would be quite nice).
This is how the docs currently look:
If I want to search on the sidebar where am I and maybe check out more components in the same category, I'll have to read all of them.
A simple change like this would be enough.
Those changes I made are just in the devtools:
They won't work for light mode.
The changes I made are just a proposal.
The text was updated successfully, but these errors were encountered: