Skip to main content
Brand and assets
BuildMonitor and contribute
/
Brand and assets
  • Foundations
    • The brand
    • Logo
    • Colors
    • Typography
    • Styles
    • Shadows & radii
    • Spacing & grid
    • Gradients
    • Styling & the sx prop
    • Color tokens
    • More
    • Accessibility
      • Accessible names
      • Headings
      • Images
      • Accessible colors
      • Anchors
      • HTML semantics
      • DOM order
      • Accessible alternatives
      • Debug with the accessibility tree
      • Engineer setup
  • Assets
  • AI references
  • Foundations
  • Accessibility
  • Accessible alternatives

Accessible alternatives

With our current effort to level up our product quality, especially in our dashboards, you might face some fancy / complex components to implement. Now we cover public agents, we have to provide those in an accessible manner.

Instead of spending effort to make those accessible directly, we can provide an accessible (low effort) alternative. This approach ensures that while some elements may be visually or interactively redundant, they do not hinder the accessibility for users relying on assistive technologies, adhering to the principles of providing equivalent access in different forms.

To implement alternatives, you can use both APIs:

  • The aria-hidden="true" attribute is used to indicate that an element and its children should be ignored by assistive technologies like screen readers. This is crucial for managing the accessibility tree and ensuring that non-interactive or decorative elements do not interfere with the user's experience.
  • Tamagui's <VisuallyHidden /> component is designed to provide accessibility for visual UI components by hiding text visually but making it available to screen readers. This technique is particularly useful for elements like icon-only buttons, ensuring compliance with WCAG guidelines by providing necessary textual context that is accessible to assistive technologies.

You can use the first on the non-accessible code and the second on the accessible one.

Example​

This example is extracted from the PromoCards component. The PromoCards component is a carousel that displays a set of cards with a main card and a next card. Full implementation of the PromoCards component can be found here.

Making the carousel accessible would require to implement the related aria pattern (more details here). It means implementing focus management and custom keyboard navigation. With the alternative approach, we can provide a simple list of cards that will be accessible to screen readers and keyboard users.

<Box aria-hidden> {/* This will hide the content from screen readers */}
<Box sx={{ position: "relative" }}>
<PromoCard
onMouseEnter={stopAnimation}
onMouseLeave={startAnimation}
ref={activeRef}
key={currentCard.title}
card={currentCard}
status="active"
/>
{startNext ? <PromoCard ref={nextRef} key={nextCard.title} card={nextCard} status="next" /> : null}
</Box>
<Dots
count={cards.length}
activeIndex={startNext ? nextIndex : activeIndex}
onDotClick={(index) => setActiveIndex(index)}
/>
</Box>
<VisuallyHidden id="promo-cards-screen-reader-only"> {/* This will provide the accessible content */}
<SemanticList>
{cards.map((card) => (
<SemanticList.Item key={card.title}>
<PromoCardContent key={card.title} card={card} />
</SemanticList.Item>
))}
</SemanticList>
</VisuallyHidden>

ℹ If not possible/high effort, you also can provide the alternative with a link to another page with the appropriate accessible content.

Edit this page
Previous
DOM order
Next
Debug with the accessibility tree
  • Example