Skip to contentSkip to navigationSkip to topbar
Paste assistant Assistant
Figma
Star

Product Switcher

Version 3.0.2GithubStorybook

A Product Switcher is an opinionated Menu that presents a list of Twilio products that a user has access to and can switch between.

Installation

Installation page anchor
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>
    </>
  );
};

ProductSwitcher

ProductSwitcher page anchor

element

Overrides the default element name to apply unique styles with the Customization Provider

Type
any
Default
'PRODUCT_SWITCHER'

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'

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'