Skip to content

docs: add FLOW_COMPONENT_GUIDELINES and DESIGN_GUIDELINES#9143

Open
Artur- wants to merge 4 commits into
mainfrom
guidelines
Open

docs: add FLOW_COMPONENT_GUIDELINES and DESIGN_GUIDELINES#9143
Artur- wants to merge 4 commits into
mainfrom
guidelines

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented Apr 17, 2026

Document the implementation mechanics and design principles for Flow components so the conventions used across the existing modules are discoverable in one place, mirroring the equivalent guides in the web-components repository.

Artur- added 4 commits April 28, 2026 15:39
Document the implementation mechanics and design principles for Flow
components so the conventions used across the existing modules are
discoverable in one place, mirroring the equivalent guides in the
web-components repository.
Flow APIs should use the positive, natural-language form for boolean
properties (setEnabled, setVisible) even though the underlying web
component uses the negative HTML form (disabled, hidden). The polarity
flip happens at the element boundary inside the wrapper.
Property order independence, graceful behaviour before UI attachment,
and no thrown errors for bad input (warnings instead).
Flow queues JS calls until connection rather than silently dropping
them. Properties are stored server-side and synced on connect.
@vaadin vaadin deleted a comment from github-actions Bot Apr 28, 2026
@sonarqubecloud
Copy link
Copy Markdown

Comment thread DESIGN_GUIDELINES.md
- A component-specific extension or override.
- A specific interaction pattern not pinned down by the universal rule.

### Every interactive element has an accessible name
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and a few other points below are covered in the web component design guidelines. IMO, we should not duplicate them here other than i18n part (should mention mapping web component i18n property to Java class). Things like "focus order" and RTL can be probably dropped.

Comment thread DESIGN_GUIDELINES.md

---

## Declarative (XML/Lumo) compatibility remains
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: what this XML/Lumo is about? This should be renamed.

Comment thread DESIGN_GUIDELINES.md

## Declarative (XML/Lumo) compatibility remains

Flow components are sometimes consumed through Lit templates, Hilla, or server-side templating. The component's default state (zero-argument constructor + defaults) MUST produce something meaningful that renders correctly with no further calls.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: we should not mention Hilla, and generally reduce this section (it's not a common use case).

Comment thread DESIGN_GUIDELINES.md

**What this means in practice:**

- The web component declares `static experimental = true`; the Flow wrapper MUST be gated by the corresponding Vaadin feature flag (see `com.vaadin.experimental.FeatureFlags`).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: web components use static get experimental() but this is kind of not relevant here?

Comment thread DESIGN_GUIDELINES.md

- The single-line-to-common-case principle keeps Flow application code readable: most buttons in a real application are created as `new Button("Save", e -> save())`, and that must not require boilerplate.
- Overloaded constructors make the component's intended uses discoverable through IDE autocompletion.
- Refusing fluent chains keeps Flow consistent with the rest of Vaadin Flow and Jakarta: everything is setter-based so that framework tooling (validation, binding, state restoration) sees the same shape.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: "keeps Flow consistent with the rest of Vaadin Flow" sounds like a tautology, consider rephrasing.

Comment thread DESIGN_GUIDELINES.md

For implementation details, see [FLOW_COMPONENT_GUIDELINES.md](FLOW_COMPONENT_GUIDELINES.md).

For the design principles of the underlying web components, see `DESIGN_GUIDELINES.md` in the web-components repository; the Flow component's API must stay consistent with that design.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this should now mention guidelines folder instead of DESIGN_GUIDELINES.md file.

Comment thread DESIGN_GUIDELINES.md

- The web component is the source of truth for behaviour, DOM structure, theme variants, slots, shadow parts, and CSS custom properties. The Flow component must match the web component's semantics, not contradict them.
- If the web component exposes a property `disabled`, the Flow component's `setDisabled(boolean)` (usually via `HasEnabled`) must map to that property — not to something the Flow layer invents.
- If the web component exposes an event `opened-changed`, the Flow event listener must listen for that DOM event via `@DomEvent("opened-changed")` — not synthesise a separate Flow-only event.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this isn't quite true and in fact, "opened" property is not the best example - see #8230 for the change in Popover that removed @DomEvent for it. Consider using some other property name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants