TapArea allows components to be clickable and touchable in an accessible way

also known as Touchable

Figma:

Web:

iOS:

Android:

A11y:

Props

Component props
Name
Type
Default
Required
React.Node
-

TapArea is a wrapper around non-button components (or children) that provides clicking / touching functionality as if they were a unified button area.

string
-

Specify the id of an associated element (or elements) whose contents or visibility are controlled by a button component so that screen reader users can identify the relationship between elements.

Optional with button-role.

Accessibility: It populates aria-controls.

boolean
-

Indicate that a button component hides or exposes collapsible components and expose whether they are currently expanded or collapsed.

Optional with button-role.

Accessibility: It populates aria-expanded.

boolean
-

Indicate that a button component controls the appearance of interactive popup elements, such as menu or dialog.

Optional with button-role.

Accessibility: It populates aria-haspopup.

string
-

Supply a short, descriptive label for screen-readers to replace TapArea texts that do not provide sufficient context about the button component behavior.

Accessibility: It populates aria-label.

boolean
-

Set disabled state so TapArea cannot be interacted with and actions are not available.

boolean
-

Set the TapArea height to expand to the full height of the parent.

boolean
true

Set the TapArea width to expand to the full width of the parent.

string
-

Specify a link URL.

Required with role=link.

"copy" | "grab" | "grabbing" | "move" | "noDrop" | "pointer" | "zoomIn" | "zoomOut"
"pointer"

Select a mouse cursor type to convey the TapArea expected behavior .

({ event: SyntheticFocusEvent<HTMLDivElement> | SyntheticFocusEvent<HTMLAnchorElement> }) => void
-

Callback fired when a TapArea component loses focus.

({ event: SyntheticFocusEvent<HTMLDivElement> | SyntheticFocusEvent<HTMLAnchorElement> }) => void
-

Callback fired when a TapArea component gets focus via keyboard navigation, mouse click (pressed), or focus method

onMouseDown
({ event: SyntheticMouseEvent<HTMLDivElement> | SyntheticMouseEvent<HTMLAnchorElement>, {| dangerouslyDisableOnNavigation: () => void |}> }) => void
-

Callback fired when a click event begins.

onMouseEnter
({ event: SyntheticMouseEvent<HTMLDivElement> | SyntheticMouseEvent<HTMLAnchorElement>, {| dangerouslyDisableOnNavigation: () => void |}> }) => void
-

Callback fired when a mouse pointer moves onto a TapArea component.

onMouseLeave
({ event: SyntheticMouseEvent<HTMLDivElement> | SyntheticMouseEvent<HTMLAnchorElement> }) => void
-

Callback fired when a mouse pointer moves out a TapArea component.

onMouseUp
({ event: SyntheticMouseEvent<HTMLDivElement> | SyntheticMouseEvent<HTMLAnchorElement> }) => void
-

Callback fired when a click event ends.

({ event: SyntheticMouseEvent<HTMLDivElement> | SyntheticKeyboardEvent<HTMLDivElement> | SyntheticMouseEvent<HTMLAnchorElement> | SyntheticKeyboardEvent<HTMLAnchorElement>, {| dangerouslyDisableOnNavigation: () => void |}> }) }) => void
-

Callback fired when a TapArea component is clicked (pressed and released) with a mouse or keyboard.

Required with button-role + button-type buttons.

See OnLinkNavigationProvider to learn more about link navigation.

React.Ref<"div"> | React.Ref<"a">
-

Forward the ref to the underlying div or anchor element.

"none" | "nofollow"
"none"

Optional with role=link.

"button" | "link"
"button"

Select a TapArea variant:

  • 'button': Use for TapArea to act like buttons. The TapArea is rendered as a <div>.
  • 'link': Use for TapArea to act like links. The button is rendered as an <a>.

Required with role=link.

"pill" | "circle" | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
-

Sets a border radius for the TapArea. Select a rounding option that aligns with its children.

Options are "circle" or "pill" for fully rounded corners or 0-8 representing the radius in boints.

-1 | 0
0

Remove the component from sequential keyboard navigation to improve accessibility. The component is not focusable with keyboard navigation but it can be focused with Javascript or visually by clicking with the mouse.

The default behaviour for the component is to be focusable in sequential keyboard navigation in the order defined by the document's source order.

If component is disabled, the component is also unreachable from keyboard navigation.

none | "compress"
"none"

Set a compressing behavior when the TapArea is clicked / touched.

  • 'none' does not compress TapArea.
  • 'compress' scales down TapArea.
null | "self" | "blank"
"null"

Define the frame or window to open the anchor defined on href:

  • 'null' opens the anchor in the same window.
  • 'blank' opens the anchor in a new window.
  • 'self' opens an anchor in the same frame.

Optional with role=link.

Accessibility

Localization

TapAreas with link role announce to assistive technologies that the link opens in a new tab when setting target to 'blank'. Localize the default label with DefaultLabelProvider. Learn more

Variants

Basic TapArea

If you have a Link or Button inside of TapArea, you can apply e.stopPropagation() so the onTap doesn't get triggered.

TapArea with link interaction can be paired with OnLinkNavigationProvider. See OnLinkNavigationProvider to learn more about link navigation.

Roles & compress behavior

Height & width

Inline usage

While TapArea doesn't provide an inline prop, this behavior can be achieved by wrapping with <Box display="inlineBlock">.

Mouse cursor

mouseCursor="copy"
copy
mouseCursor="grab"
grab
mouseCursor="grabbing"
grabbing
mouseCursor="move"
move
mouseCursor="noDrop"
noDrop
mouseCursor="pointer"
pointer
mouseCursor="zoomIn"
zoomIn
mouseCursor="zoomOut"
zoomOut

Rounding

rounding={0}
0
rounding={1}
1
rounding={2}
2
rounding={3}
3
rounding={4}
4
rounding={5}
5
rounding={6}
6
rounding={7}
7
rounding={8}
8
rounding="circle"
circle
rounding="pill"
pill

Ref

Accessibility: label, controls, expanded, & popup

Component quality checklist

Component quality checklist
Quality item
Status
Status description
Figma Library
Component is not currently available in Figma.
Responsive Web
Ready
Component is available in code for web and mobile web.
iOS
Component is not currently available in code for iOS.
Android
Component is not currently available in code for Android.

OnLinkNavigationProvider
OnLinkNavigationProvider allows external link navigation control across all children components with link behavior.