question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A dcc.DocumentTitle Component for Updating the Page Title Dynamically

See original GitHub issue

This would enable users to update the tab:

  1. When navigating pages with dcc.Location
  2. When updating tabs with dcc.Tabs

I’ve helped a customer with a similar component with an implementation below:


import {Component} from 'react';
import PropTypes from 'prop-types';

export default class DocumentTitle extends Component {

    componentDidMount() {
        document.title = this.props.children;
    }

    componentWillReceiveProps(nextProps) {
        document.title = nextProps.children;
    }

    render() {
        return null;
    }
}

DocumentTitle.defaultProps = {
    children: 'Dash'
}

DocumentTitle.propTypes = {
    children: PropTypes.string,
    id: PropTypes.string
}

To bring this into the library, we would need to:

  1. incorporate that code as a new component
  2. then add some tests
  3. Modify componentWillReceiveProps to the non-deprecated way of doing things with React
  4. Add docs to:
    • dash.plotly.com/urls
    • dash.plotly.com/dash-core-comoponents/documenttitle. Provide a cross link to /external-resources to mention how to set the page title via the server side template, which would provide the page title on page load rather than dynamically. Doing this on page load would be better for SEO.
    • Provide a link to these docs from the external-resources page where we discuss how to set the title in the server-side template and mention the limitations of that method (it will only update the page title on page load, not on subsequent navigation via dcc.Link)

If any community member takes this on before we get around to, please comment below!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
chriddypcommented, Jul 28, 2020

OK, this feature is now available in dash==1.14.0. and is documented in http://dash.plotly.com/external-resources. See the “Update the Document Title Dynamically based off of the URL or Tab” example.

I’ll keep this issue open to consider a dcc.DocumentTitle component which would enable a Python interface to updating the title. The current example documented above uses a clientside callback (JavaScript).

0reactions
debilosauruscommented, Mar 26, 2022

Hi there, I tried to set the “app.title” and the “app._favicon” for a monitoring app, searched and found this discussion. But I slightly disagree with your suggestion. From the view of the user (me), my fist attempt was to simply create the “app.id” attribute for the use as the output target with usual callback mechanism. This of course doesnt worked, but instead of creating more specialiced dcc function, this would be a way more compatible solution. First drawback: I dont know the dash code, so this maybe wont be easy to implement Second drawback: A consequence would be a change “app.layout” to the formal better “app.children” to make the app a proper parent. kr, Tx.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the title in tab - Dash Python - Plotly Community Forum
I have a multipage app where each page currently has Dash as the title. How can I change it to say something else?...
Read more >
Dynamically update the title in Dash Plotly - Stack Overflow
I want to plot 'Number' column values from the example's data frame with the dynamically updated title. I'll try to work on your...
Read more >
@plotly/webpack-dash-dynamic-import - Package Manager
Fast, reliable, and secure dependency management.
Read more >
NICHD Data and Specimen Hub (DASH) Tutorial - NIH
Clicking on a study title will take you to the "Study Overview" page. ... Study Components (Datasets and Documents), Collections, Biospecimens.
Read more >
Docstrings · Dash.jl - JuliaHub
Configures the document.title (the text that appears in a browser tab) text ... page through 10,000 rows in data 100 rows at a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found