Skip to content

Accessibility and RTL standard

This page sets the rules that make ConnectSoft Blazor UI usable with a keyboard and a screen reader, correct in right-to-left languages, and correct in the reader's locale and time zone. It is written for engineers who write or review components, CSS and UI tests. Layout across screen sizes is in Responsive layout.

Targets

  • The accessibility target is WCAG 2.1 AA, the target the UIKit already tests its components against.
  • Text direction comes from the UIKit UI context: an explicit user choice first, then the language, then the host default. The UIKit renders it as the dir attribute, so components never decide the direction themselves.
  • Existing CSS is not flagged in review. The UIKit conversion to logical properties is planned work (ENF-047).

Rules

CS-A11Y-001: Use logical properties and utilities in new CSS

Severity: major · Applies to: blazor, template · Enforced by: manual (target: ENF-048) · Status: active

Why

Logical properties follow the text direction, so one stylesheet serves left-to-right and right-to-left layouts. Physical properties such as margin-left need a mirrored override for every rule, and the overrides drift. Swapping whole RTL stylesheets doubles the CSS to maintain.

Do

  • Use margin-inline-start and margin-inline-end, padding-inline-*, border-inline-*, inset-inline-* and text-align: start or end.
  • In markup, use the logical Tailwind utilities: ms-*, me-*, ps-*, pe-*, start-*, end-*, text-start, text-end, rounded-s-* and rounded-e-*.
  • Mirror only what has a direction meaning, such as chevrons and arrows, with a [dir="rtl"] selector.

Don't

  • Use margin-left, margin-right, padding-left, padding-right, left, right, float: left|right or text-align: left|right in new CSS.
  • Use ml-*, mr-*, pl-*, pr-*, left-*, right-*, text-left or text-right in new markup.
  • Load a separate RTL stylesheet.

Example

/* Do */
.order-actions > button + button {
    margin-inline-start: 0.5rem;
}

/* Don't */
.order-actions > button + button {
    margin-left: 0.5rem;
}

How to check

  • Search the CSS and markup in the change for the physical properties and utilities listed above.
  • A stylelint rule will report them in new CSS (ENF-048).

CS-A11Y-002: Let shrinkable grid tracks shrink with minmax(0, 1fr)

Severity: major · Applies to: blazor, template · Enforced by: manual (target: ENF-048) · Status: active

Why

1fr means minmax(auto, 1fr): the track never shrinks below its widest item. A wide chart or long label then makes the track overflow its container. In a right-to-left layout it overflows off the left edge, where the page cannot scroll, so values disappear without any scroll bar. A "page does not scroll sideways" test passes the whole time.

Do

  • Write minmax(0, 1fr) for a track that must fit its container.
  • Or set min-width: 0 on the grid item.
  • Test layout with the data that is widest in real use, for example the role that sees the most categories.

Don't

  • Write grid-template-columns: 1fr or repeat(n, 1fr) for a track whose content can be wider than the container.

Example

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

How to check

  • Search the change for 1fr in grid-template-columns without minmax(0,.
  • In a Playwright test at phone width, assert that every element's box is inside the viewport (left >= 0 and right <= innerWidth).

CS-A11Y-003: Show dates through one formatter in the user's time zone

Severity: blocker · Applies to: blazor, template · Enforced by: manual (target: ENF-054) · Status: active

Why

A timestamp stored in UTC and printed without conversion shows the wrong day for every event recorded near midnight. At a month boundary it moves the event into the previous month, which reaches reports and billing. On Blazor Server, ToLocalTime() and DateTime.Now use the server's time zone, not the reader's. When each component formats dates on its own, two dates on one screen disagree.

Do

  • Store and transport timestamps in UTC.
  • Display every date and time through one display formatter service.
  • In that formatter, convert to the time zone configured for the tenant or the user, and fall back to the browser's time zone.
  • Format with the current UI culture.
  • Get the current time from TimeProvider in the code that needs it (CS-TIM-001).

Don't

  • Call ToLocalTime(), DateTime.Now, DateTimeOffset.Now or DateTime.Today in components.
  • Format a timestamp with ToString("dd/MM/yyyy") in markup.
  • Show the creation instant where the event's own date belongs.

Example

<td>@DisplayDates.Date(order.PlacedAtUtc)</td>
<td>@DisplayDates.DateTime(order.ShippedAtUtc)</td>

How to check

  • Search changed components for ToLocalTime, DateTime.Now, DateTimeOffset.Now and DateTime.Today.
  • A unit test of the formatter converts a UTC instant just before midnight and asserts the local date in the configured zone.
  • Search changed components and markup for ToString(" with a date format, such as ToString("dd/MM/yyyy"). Every date goes through the display formatter.

CS-A11Y-004: Give every input a programmatic label

Severity: major · Applies to: blazor, template · Enforced by: axe (target: ENF-052) · Status: active

Why

A screen reader announces an input by its label. A placeholder or nearby text is not a label, and an unlabelled input fails WCAG 2.1 AA, the UIKit's target.

Do

  • Associate a visible <label for="..."> with the input's id, or wrap the input in its label.
  • Use aria-label or aria-labelledby only when there is no visible label, for example an icon-only button.
  • Mark a required field visibly and with aria-required="true", including a field that becomes required because of another choice.
  • Link the error text with aria-describedby and set aria-invalid="true" on a field in error.

Don't

  • Use a placeholder as the only label.

How to check

  • The axe scan in the template's smoke test (CS-A11Y-005) reports no label violations.
  • Required inputs carry aria-required="true", including inputs that become required because of another choice.
  • Inputs in error carry aria-invalid="true" and an aria-describedby that points to the error text.

CS-A11Y-005: Run a Playwright and axe smoke test in every Shell and micro-frontend template

Severity: major · Applies to: template · Enforced by: Playwright test (target: ENF-052) · Status: active

Why

A unit test cannot see contrast, missing labels or landmarks in the rendered page. A smoke test in each template catches these before a product is generated from it, and gives every generated product a working start for its own end-to-end tests. Playwright with Microsoft.Playwright.MSTest.v4 is the end-to-end framework (CS-TST-001).

Do

  • Add an end-to-end test project that starts the sample host, opens each top-level page and runs Deque.AxeCore.Playwright with the WCAG 2.1 AA tags (wcag2a, wcag2aa, wcag21a, wcag21aa).
  • Fail the test on any violation of impact serious or critical.
  • Wait for the circuit to connect before the scan.

Don't

  • Exclude a rule from the scan without a written reason next to the exclusion.

Example

[TestMethod]
public async Task HomePageHasNoSeriousAccessibilityViolations()
{
    await this.Page.GotoAsync(this.BaseUrl);

    var result = await this.Page.RunAxe(new AxeRunOptions
    {
        RunOnly = new RunOnlyOptions { Type = "tag", Values = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"] },
    });

    var blocking = result.Violations.Where(v => v.Impact is "serious" or "critical").ToList();
    Assert.AreEqual(0, blocking.Count, string.Join(", ", blocking.Select(v => v.Id)));
}

How to check

  • The template repository has an end-to-end project with an axe test per top-level page, and the pipeline runs it.
  • The axe test fails on any violation of impact serious or critical.
  • Every rule excluded from the scan has a written reason next to the exclusion.

CS-A11Y-006: Render ARIA state attributes as explicit "true" or "false"

Severity: major · Applies to: blazor, template · Enforced by: manual · Status: active

Why

Blazor renders an attribute bound to true with an empty value and omits it when the value is false. For a state attribute such as aria-selected or aria-expanded, neither form means what ARIA defines, so a screen reader cannot tell which tab is current or whether a menu is open.

Do

  • Bind state attributes to a string: aria-selected="@(isSelected ? "true" : "false")".
  • Apply this to aria-selected, aria-expanded, aria-pressed, aria-checked and aria-current.
  • Use "true" : null only where absence means false by definition, such as aria-busy and aria-invalid.

Don't

  • Bind a bool directly: aria-expanded="@isOpen".

How to check

  • Search for aria-(selected|expanded|pressed|checked|current)="@ followed by a bare identifier.
  • A Playwright assertion such as ToHaveAttributeAsync("aria-selected", "true") on the selected item.

CS-A11Y-007: Show validation and refusal messages in the user's language

Severity: major · Applies to: blazor, template, service · Enforced by: manual · Status: active

Why

A model-validation response that carries PropertyName: English sentence reaches the user untranslated when the UI translates only refusals that carry an error code. The user cannot tell which field is wrong or what to do.

Do

  • Give every validation and domain refusal a stable error code, and translate on the code in the UI.
  • Name the field in the user's language and say what to do.
  • Test the refusal path of each form in a non-English culture.

Don't

  • Show a server message or a property name to the user as is.

How to check

A test submits an invalid request through the form in a non-English culture and asserts the localized text.

CS-A11Y-008: Render both branches of a bool

Severity: minor · Applies to: blazor, template · Enforced by: manual · Status: active

Why

When a stored "no" renders as the same dash that means "nothing recorded", the user reads a deliberate answer as a missing one and enters it again.

Do

  • Render an explicit text for true and for false.
  • Reserve the dash or empty mark for null.

Don't

  • Render only the true branch and leave false blank.

How to check

A bUnit test renders the component with true, false and null and asserts three different outputs.

CS-A11Y-009: Set the tone of a message explicitly

Severity: minor · Applies to: blazor, template · Enforced by: manual · Status: active

Why

When a confirmation and a refusal share one grey style, a refusal reads as a caption. Screen readers announce neither unless the message has a live-region role.

Do

  • Show outcome messages through one message component with an explicit tone.
  • Render an error or a warning with role="alert".
  • Render a success message as a polite live region (role="status").
  • Set the tone where the message is assigned.

Don't

  • Infer the tone from the message text.

How to check

Review new outcome messages for an explicit tone.

CS-A11Y-010: Make every action reachable from the keyboard, and test it from a known focus

Severity: minor · Applies to: blazor, template · Enforced by: manual · Status: active

Why

An action that only a mouse can reach fails WCAG 2.1 AA. Keyboard tests are flaky when they press Tab from an unknown start: FocusOnNavigate moves focus to the page heading after navigation, and browsers differ in whether a Tab walk wraps around the page.

Do

  • Use native button, a and form elements, or give a custom control a role, tabindex="0" and key handlers.
  • In a keyboard test, read document.activeElement first, then choose Tab or Shift+Tab by the target's document position.

Don't

  • Attach @onclick to a div or span without a role and keyboard handling.

How to check

  • A Playwright test reaches the action from a known focus and activates it with the keyboard.
  • Search new markup for div and span elements with @onclick. Each one has a role, tabindex="0" and a key handler.

CS-A11Y-011: Don't use month or week inputs

Severity: major · Applies to: blazor, template · Enforced by: manual · Status: active

Why

Some current browsers do not implement type="month" and type="week" and fall back to a text input. Blazor's event handler for date-type inputs then throws inside the browser, and the bound value never reaches .NET. The filter silently never fires for those users.

Do

  • Use type="date", or a pair of selects for month and year.

Don't

  • Use <input type="month"> or <input type="week">.

How to check

Search markup for type="month" and type="week".

CS-A11Y-020: Translate every coded value through the lookup its column declares

Severity: major · Applies to: blazor, template, service · Enforced by: manual · Status: active

Why

A renderer that translates a fixed list of column names shows raw internal codes for every other coded column, group key and warning token. The user sees English placeholders or codes on a page in their language, and every new report repeats the gap.

Do

  • Declare a lookup name for every coded column in the report or list schema.
  • Resolve every coded cell, group key and warning token through that lookup and the resource files.
  • Fail a test when a coded column has no lookup.

Don't

  • Switch on column names in display code to decide what to translate.
  • Render a placeholder such as unassigned or a status code without a resource lookup.

How to check

A test over the whole report catalogue renders every report and asserts that no coded column or warning shows a raw code.