how do I create anchor tags using dash_html_components?
<A NAME="top">
this way I can put something like
html.A(‘Return to Top’, href=’#top’)
how do I create anchor tags using dash_html_components?
<A NAME="top">
this way I can put something like
html.A(‘Return to Top’, href=’#top’)
@wbrgss might have some thoughts on this topic
@ralle123 try using id
instead of name
; html.A()
doesn’t accept the name
property. For example:
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div(
children=[
html.A(id='top'),
html.H1('I\'m at the top'),
]
+ [html.Br() for i in range(100)]
+ [html.H1('I\'m at the bottom'), html.A('Return to top', href='#top')]
)
app.run_server(debug=True)
@byronz As an aside, yes, my thoughts on this are related to the slightly tangential issue of implementing Markdown Headings so that they are automatically anchors. I also noticed that anchor “hotlinks” still needed some extra JS to scrollTo()
the given anchor, i.e. the above code will only work with user interaction, but navigating to e.g. http://my-url/#bottom won’t automatically scroll to the bottom on page load. The markdown engine + related issue is here:
https://github.com/rexxars/react-markdown/issues/69