Protected against bots by Yandex SmartCaptcha. Data processing policy
InkWell
Makes any element tappable: catches a tap, a double tap and a long press and shows feedback — a ripple in the app, a highlight on hover and press on the site. It is the most common way to make an arbitrary block "clickable" — a card, a list row, an icon.
Type:
single-child
@taps:0
InkWell onTap:{taps = taps + 1}
Padding
#padding all 16
Text "Tap me"
Parameters
| Parameter | Type | Description |
|---|---|---|
onTap
|
callback | Tap |
onDoubleTap
|
callback | Double tap (app only) |
onLongPress
|
callback | Long press (app only) |
splashColor
|
color | Ripple color (on the site — the highlight color on press) |
highlightColor
|
color | Highlight color on press |
hoverColor
|
color | Highlight color on mouse hover |
focusColor
|
color | Highlight color on keyboard focus |
A handler is written in any of three forms, as with Button :
-
a body
{…}— runs on tap (for example,onTap:{opened = !opened}); -
an action string
"navigate:/home"— an app action is invoked; -
a variable holding a function,
onTap:$copy.
An element without a handler promises nothing: on the site it gets neither the hand cursor nor a highlight.
Nested structures
#borderRadius
and
#customBorder
The shape the ripple is clipped to (in the app). For rounding —
#borderRadius circular 12
, for an arbitrary shape —
#customBorder
(same format as the
#shape
of buttons).
@opened:false
InkWell onTap:{opened = !opened}
#borderRadius circular 12
Padding
#padding all 16
Text "With a rounded ripple"
Examples
Clickable card
@selected:false
InkWell onTap:{selected = !selected} hoverColor:#1A36345E
DecoratedBox
#decoration color:#36345E
#borderRadius circular 16
Padding
#padding all 20
Column spacing:4 crossAxisAlignment:start
Text "Basic plan"
Text "Tap to choose"
Link on tap
InkWell onTap:"navigate:/pricing"
Padding
#padding symmetric horizontal:12 vertical:8
Text "Pricing"
Differences between the app and the site
-
In the app the feedback is a ripple from the tap point on the nearest Material layer. An opaque fill of the child (
ColoredBox,DecoratedBoxwith a color) lies above the ripple and hides it; if you need a visible ripple, do not paint the whole child. - On the site there is a ripple from the tap point and a highlight layer on hover and press. The cursor becomes a hand only if there is a handler.
-
From the keyboard it works as in the app: an
InkWellwith a handler is reached with Tab, activated with Enter and Space (without modifiers), and on keyboard focus is highlighted withfocusColor(12 % black by default). A screen reader announces it as a button — so anInkWellwith only an icon inside needs a name:Semantics label:"Menu"around it. -
It is not always called a button. A navigation (
navigator.show,navigate:) becomes a real<a href>link. A card that has its own buttons or links inside gets focus and keys, but not the button role: a button inside a button is an accessibility error. That is why the name goes on theInkWellitself —Semantics label:around it — and not#web role:button ariaLabel:on a block inside: the block is not what gets focus. AListView/GridViewrow stays a list item. A role named by the author (Semantics link:true,#web role:) wins. -
onDoubleTap,onLongPress,#borderRadiusand#customBorderare not read on the site. AnInkWellwithout a child is an empty block on the site.
Bad practices
A tappable element without a handler
// BAD — InkWell without onTap: looks tappable only in the app, and only through the ripple
InkWell
Text "Tap"
// GOOD — there is a handler, the feedback is honest
@clicked:false
InkWell onTap:{clicked = true}
Text "Tap"