Switch

Accessibility

NameTypeDescription
ariaControlsstringAllows you to specify an aria-controls attribute to establish the relationship between the Switch and element which is controlled by it. ariaControls works only with a unique id of an element.
ariaLabelstringAllows you to specify an aria-label attribute of the component.
ariaLabelledbystringAllows you to specify an aria-labelledby attribute of the component. This attribute references the id(s) of element(s) that label(s) the Switch, separated by a space. The elements with those ids can be hidden, so that their text is only announced by screen readers.

Example

<Card
title="Billing details"
actions={
<Switch
checked={isExpanded}
onChange={handleShowBillingDetails}
ariaLabel="Toggle billing details section"
ariaControls="BillingDetailsForm"
/>
}
>
{isExpanded && (
<CardSection>
<BillingDetailsForm id="BillingDetailsForm" />
</CardSection>
)}
</Card>