plotly / plotly/dash

provide option to set HTML tag attributes

Open
#2,563 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

Is your feature request related to a problem? Please describe.

I'm part of a small team embedding a Plotly Dash in a larger website that must be accessible. We recently added Pa11y CI accessibility tests to our continuous integration and encountered the error:

<html> element must have a lang attribute
   (https://dequeuniversity.com/rules/axe/4.7/html-has-lang?application=axeAPI)
   (html)
   <html><head><style>input:invalid { ...</html>

Describe the solution you'd like

Ideally, there'd be an option (perhaps a kwarg) to add attributes to the html tag, perhaps from a dict? e.g. maybe

app = Dash('example', html_tags={'"lang": "en"})

Describe alternatives you've considered

Searching the community forum led me to a workaround by passing the index_string kwarg, so I now have something like

from dash.dash import _default_index

index_string = _default_index.replace("<html>", "<html lang='en'>")

app = Dash('example', index_string=index_string)

which satisfies pa11y-ci.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Dash constructor and the index_string option, then inspect the mentioned _default_index template to understand where the html tag is assembled. The work is complete when callers can configure html tag attributes for accessibility, including lang, without manually replacing _default_index; add or run coverage for the resulting document output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
accessibility, web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.