Utilisation

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={() => {}} />;

Déclaration du type

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

Membres 17

NomTypeRequisDescription
roleProp<Role>Non—
onAction(event: AccessibilityActionEvent) => voidNonThe screen reader action taken, by name.
accessibleProp<boolean>NonMakes the view one screen reader element, read as its label or its children's text.
labelProp<string>NonWhat a screen reader says for the view.
hintProp<string>NonWhat happens when the view is activated, read after the label.
aria-hiddenProp<boolean>NonScreen readers skip the view and its subtree.
actionsProp<readonly AccessibilityAction[]>NonActions a screen reader offers; onAction receives the one taken.
liveProp<"off" | "polite" | "assertive">NonARIA's aria-live: announces changes to the view's content, on iOS too.
aria-disabledProp<boolean>Non—
aria-selectedProp<boolean>Non—
aria-checkedProp<boolean | "mixed">Non—
aria-busyProp<boolean>Non—
aria-expandedProp<boolean>Non—
aria-valueminProp<number>Non—
aria-valuemaxProp<number>Non—
aria-valuenowProp<number>Non—
aria-valuetextProp<string>Non—
onAction — signatures de méthode

Signatures

ts
(event: AccessibilityActionEvent): void

Paramètres

NomTypeRequisDescription
eventAccessibilityActionEventOui—

Retourne

void

Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.