Verwendung

Make an icon-only button accessible.

tsx
// Make an icon-only button accessible.
import { Pressable, Symbol, type AccessibilityProps } from 'kuito';

// An icon button needs words for a screen reader: callers pass them through.
function IconButton(props: AccessibilityProps & { icon: string; onPress: () => void }) {
  return (
    <Pressable role="button" label={props.label} hint={props.hint} onPress={props.onPress}>
      <Symbol name={props.icon} size={22} />
    </Pressable>
  );
}

<IconButton icon="heart" label="Like" hint="Adds the song to your likes" onPress={() => {}} />;

Typdeklaration

ts
export interface AccessibilityProps extends AccessibilityNativeProps {
  role?: Prop<Role>;
  /** The screen reader action taken, by `name`. */
  onAction?: (event: AccessibilityActionEvent) => void;
}

Mitglieder 17

NameTypErforderlichBeschreibung
roleProp<Role>Nein—
onAction(event: AccessibilityActionEvent) => voidNeinThe screen reader action taken, by name.
accessibleProp<boolean>NeinMakes the view one screen reader element, read as its label or its children's text.
labelProp<string>NeinWhat a screen reader says for the view.
hintProp<string>NeinWhat happens when the view is activated, read after the label.
aria-hiddenProp<boolean>NeinScreen readers skip the view and its subtree.
actionsProp<readonly AccessibilityAction[]>NeinActions a screen reader offers; onAction receives the one taken.
liveProp<"off" | "polite" | "assertive">NeinARIA's aria-live: announces changes to the view's content, on iOS too.
aria-disabledProp<boolean>Nein—
aria-selectedProp<boolean>Nein—
aria-checkedProp<boolean | "mixed">Nein—
aria-busyProp<boolean>Nein—
aria-expandedProp<boolean>Nein—
aria-valueminProp<number>Nein—
aria-valuemaxProp<number>Nein—
aria-valuenowProp<number>Nein—
aria-valuetextProp<string>Nein—
onAction — Methodensignaturen

Signaturen

ts
(event: AccessibilityActionEvent): void

Parameter

NameTypErforderlichBeschreibung
eventAccessibilityActionEventJa—

Rückgabe

void

Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.