yarn add @twilio-paste/product-switcher - or - yarn add @twilio-paste/product-switcher
import {
ProductSwitcher,
ProductSwitcherButton,
ProductSwitcherItem,
useProductSwitcherState,
} from '@twilio-paste/core/product-switcher';
const ProductSwitcherMenu = () => {
const productSwitcher = useProductSwitcherState();
const [product, setProduct] = React.useState('twilio');
return (
<>
<ProductSwitcherButton {...productSwitcher} i18nButtonLabel="Switch products" />
<ProductSwitcher {...productSwitcher} aria-label="Available Products">
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="twilio"
checked={product === 'twilio'}
onChange={(e) => {
setProduct('twilio');
}}
productName="Twilio"
productStrapline="SMS, Voice & Video"
productIcon={<LogoTwilioIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="segment"
checked={product === 'segment'}
onChange={(e) => {
setProduct('segment');
}}
productName="Segment"
productStrapline="Customer data platform"
productIcon={<ProductSegmentIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="flex"
checked={product === 'flex'}
onChange={(e) => {
setProduct('flex');
}}
productName="Flex"
productStrapline="Cloud-based contact center"
productIcon={<ProductFlexIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="sendgrid"
checked={product === 'sendgrid'}
onChange={(e) => {
setProduct('sendgrid');
}}
productName="SendGrid"
productStrapline="Email delivery and API"
productIcon={<ProductEmailAPIIcon decorative />}
/>
<ProductSwitcherItem
{...productSwitcher}
name="product"
value="admin"
checked={product === 'admin'}
onChange={(e) => {
setProduct('admin');
}}
productName="Console Admin"
productStrapline="Admin center"
productIcon={<LogoTwilioIcon decorative />}
/>
</ProductSwitcher>
</>
);
};
element
Overrides the default element name to apply unique styles with the Customization Provider
- Type
any
- Default
'PRODUCT_SWITCHER'
Inherited props
Paste components will often extend native HTML elements and as a result will inherit or extend their available properties. Below is a list of the props this component has inherited and are also available to use.
productIcon RequiredRequired
Icon to use for the ProductSwitcherItem. Use a Paste Icon.
- Type
NonNullable<ReactNode>
- Default
'PRODUCT_SWITCHER_ITEM'
productName RequiredRequired
Name of the ProductSwitcherItem.
- Type
string
productStrapline RequiredRequired
Subtext for the ProductSwitcherItem.
- Type
string
element
Overrides the default element name to apply unique styles with the Customization Provider.
- Type
any
- Default
'PRODUCT_SWITCHER_ITEM'
Inherited props
Paste components will often extend native HTML elements and as a result will inherit or extend their available properties. Below is a list of the props this component has inherited and are also available to use.
i18nButtonLabel RequiredRequired
Accessible label for the ProductSwitcherButton used by screen readers.
- Type
string
element
Overrides the default element name to apply unique styles with the Customization Provider.
- Type
any
- Default
'PRODUCT_SWITCHER_BUTTON'
Inherited props
Paste components will often extend native HTML elements and as a result will inherit or extend their available properties. Below is a list of the props this component has inherited and are also available to use.