Repository navigation
docs: mention themed HTML on the Styling HTML Elements page - #6770
totally-not-ai[bot] wants to merge 5 commits into
Conversation
The theme styles for native HTML elements were described only on the Table page and in the configuration properties. Add a section to the page about styling HTML elements, where readers look for it.
Preview DeploymentThis PR has been deployed for preview. URL: https://docs-preview-pr-6770.fly.dev Changed pagesAdded content is highlighted in green; removed content is marked in red on each page.
Built from 71bc02a |
vaadin-review-bot
left a comment
There was a problem hiding this comment.
Reviewed the changes — left 2 comments.
| Finding | |
|---|---|
| The themes already style many native HTML elements by default, so the opening claim is wrong | |
| Only the outer table rule has zero specificity; the cell rules do not |
| [role="since:com.vaadin:vaadin@V25.3"] | ||
| == Theme Styles for HTML Elements | ||
|
|
||
| By default, native HTML elements are styled only by the browser and your own CSS. The Aura and Lumo themes can also style some of them, so that they match the Vaadin components. The `<table>` element is the one supported so far. |
There was a problem hiding this comment.
By default, native HTML elements are styled only by the browser and your own CSS.
Both themes style native elements out of the box, with no opt-in class:
- Lumo:
packages/vaadin-lumo-styles/src/global/typography.cssstylesh1–h6,p,blockquote,a,hr,b,strong,small,codeandpre. It is pulled in bylumo.cssthroughsrc/global/index.css. - Aura:
packages/aura/src/typography.cssstylesh1–h6andb, strong, and sets the font on the root.
What the vaadin-themed-html class adds is the fuller, component-matching styling, currently for <table> only. Suggested rewrite of the first two sentences:
The Aura and Lumo themes already set typography on native HTML elements, such as headings, paragraphs and links. Some elements can also get the fuller styling that matches the Vaadin components, which is opt-in. The
<table>element is the one supported so far.
styling-elements.adoc:89 · accuracy
There was a problem hiding this comment.
Good catch. The opening now says the themes already style the typography of some native elements, such as headings, and that the fuller, component-matching styles are opt-in, with <table> the only element so far. I also fixed the same claim in the themedHtml property description and in the Table page's Styling section, so the three pages agree.
|
|
||
| To leave an element under a themed ancestor to the browser and your own CSS, add the `vaadin-unthemed-html` class name to that element. In Flow, this class name is available as [classname]`Constants.UNTHEMED_HTML_CLASS_NAME`, in the same class. | ||
|
|
||
| The theme styles have zero specificity, so your own CSS overrides them. For the Flow component that renders a table, see <<{articles}/components/html-elements/table#styling,Table>>. |
There was a problem hiding this comment.
The theme styles have zero specificity, so your own CSS overrides them.
In packages/aura/src/table.css (and the Lumo equivalent) only the outer selector is wrapped in :where(…). The nested rules inside it carry element specificity, because the nesting selector contributes 0 and the nested part adds its own:
:is(th, td) { padding; text-align }→ (0,0,1)th { font-weight }→ (0,0,1):is(thead, tfoot) :is(th, td) { background }→ (0,0,2)
So a reader whose own rule is td { padding: 0 } ties with the theme and wins only on source order, not on specificity. Consider: "The theme styles use low specificity, so a class-based rule of your own overrides them."
styling-elements.adoc:121 · accuracy
There was a problem hiding this comment.
Right, only the outer :where(…) rule has zero specificity. Changed it to: "The theme styles use low specificity, so a class-based rule of your own overrides them."
Summary
Adds a "Theme Styles for HTML Elements" section to the Styling HTML Elements page. Until now, the theme styles for native HTML elements were only described on the Table page and in the configuration properties, not on the page about styling HTML elements.
Fixes #6769
What changed
vaadin-themed-htmlclass name on an element or an ancestor (Flow and React examples)themedHtmlconfiguration propertyvaadin-unthemed-html<table>is the only element supported so far, so it stays correct when more elements are added.themedHtmlproperty description and the Table page's Styling section no longer say that the themes don't style other HTML elements at all; they now say those elements don't get the theme's table-style (fuller) styles.Test summary
Working on behalf of Stefan