Utilização

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

Declaração do tipo

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

Membros 17

NomeTipoObrigatórioDescrição
roleProp<Role>Não—
onAction(event: AccessibilityActionEvent) => voidNãoThe screen reader action taken, by name.
accessibleProp<boolean>NãoMakes the view one screen reader element, read as its label or its children's text.
labelProp<string>NãoWhat a screen reader says for the view.
hintProp<string>NãoWhat happens when the view is activated, read after the label.
aria-hiddenProp<boolean>NãoScreen readers skip the view and its subtree.
actionsProp<readonly AccessibilityAction[]>NãoActions a screen reader offers; onAction receives the one taken.
liveProp<"off" | "polite" | "assertive">NãoARIA's aria-live: announces changes to the view's content, on iOS too.
aria-disabledProp<boolean>Não—
aria-selectedProp<boolean>Não—
aria-checkedProp<boolean | "mixed">Não—
aria-busyProp<boolean>Não—
aria-expandedProp<boolean>Não—
aria-valueminProp<number>Não—
aria-valuemaxProp<number>Não—
aria-valuenowProp<number>Não—
aria-valuetextProp<string>Não—
onAction — assinaturas de método

Assinaturas

ts
(event: AccessibilityActionEvent): void

Parâmetros

NomeTipoObrigatórioDescrição
eventAccessibilityActionEventSim—

Devolve

void

Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.