({{ ...user, id: user.id }}))}
selectedItems={selectedItems}
onSelectionChange={setSelectedItems}
promotedBulkActions={promotedBulkActions}
bulkActions={bulkActions}
paginationComponent={paginationComponent}
renderItem={({ id, name, email, role }) => {{
return (
{{ email }}
{{ role }}
);
}})
/>
);
}}
```
--------------------------------
### Navigation Using Icons
Source: https://github.com/shopify/polaris-react/blob/main/polaris.shopify.com/content/components/internal-only/navigation.mdx
This example shows how to use the shouldResizeIcon prop when using icons.
```tsx
import {Navigation} from "@shopify/polaris";
import {HomeIcon, OrdersIcon, ProductsIcon} from "@shopify/polaris-icons";
function NavigationExample() {
return (
{},
shouldResizeIcon: true,
},
{
label: 'Page two',
icon: OrdersIcon,
onClick: () => {},
shouldResizeIcon: true,
},
{
label: 'Page three',
icon: ProductsIcon,
onClick: () => {},
shouldResizeIcon: true,
},
]}
/>
);
}
```
--------------------------------
### Complete Badge
Source: https://github.com/shopify/polaris-react/blob/main/polaris.shopify.com/content/components/feedback-indicators/badge.mdx
Use to indicate when a given task has been completed, for example, when an order has been fulfilled.
```tsx
import {Badge} from '@shopify/polaris';
function MyComponent() {
return Fulfilled;
}
```
--------------------------------
### Run VisuallyHidden Component Migration
Source: https://github.com/shopify/polaris-react/blob/main/documentation/guides/migrating-from-v10-to-v11.md
Use this command to migrate the VisuallyHidden component. Replace `` with the target directory.
```sh
npx @shopify/polaris-migrator v10-react-replace-text-components --componentName='VisuallyHidden'
```
--------------------------------
### Combobox Default Example
Source: https://github.com/shopify/polaris-react/blob/main/polaris.shopify.com/content/components/selection-and-input/combobox.mdx
Use when merchants can select one option from a predefined or editable list.
```tsx
import {Combobox, TextField} from "@shopify/polaris";
import {useState, useCallback} from "react";
export default () => {
const emptyValue = {
label: "",
value: "",
};
const [selectedValue, setSelectedValue] = useState(emptyValue);
const [inputValue, setInputValue] = useState("");
const options = [
{label: "Pear", value: "pear"},
{label: "Plum", value: "plum"},
{label: "Strawberry", value: "strawberry"},
{label: "Raspberry", value: "raspberry"},
{label: "Apple", value: "apple"},
{label: "Grape", value: "grape"},
{label: "Blueberry", value: "blueberry"},
];
const updateSelectionValue = useCallback(
(value: string) => {
setSelectedValue({
label: value,
value: value.toLowerCase(),
});
setInputValue(value);
},
[],
);
const handleInputChange = useCallback(
(value: string) => {
setInputValue(value);
// Filter options based on input value
// For this example, we're not filtering, but in a real app you would
},
[],
);
const handleOnFocus = useCallback(() => {
// Potentially show all options when focused
}, []);
const comboboxOptions = options.map((option) => (
{option.label}
));
return (
}
// @ts-ignore
onSelect={updateSelectionValue}
selected={selectedValue.value}
>
{comboboxOptions}
);
};
```
--------------------------------
### Navigation with aria-labelledby
Source: https://github.com/shopify/polaris-react/blob/main/polaris.shopify.com/content/components/internal-only/navigation.mdx
This example shows how to add an aria-labelledby to add a hidden label to the `nav` element.
```tsx
import {Navigation} from "@shopify/polaris";
import {HomeIcon, OrdersIcon, ProductsIcon} from "@shopify/polaris-icons";
function NavigationExample() {
return (
{},
},
{
label: 'Page two',
icon: OrdersIcon,
onClick: () => {},
},
]}
/>
Main navigation
);
}
```
--------------------------------
### Run Dev Server for Polaris Website
Source: https://github.com/shopify/polaris-react/blob/main/README.md
This command uses turbo to run the 'dev' command for the 'polaris.shopify.com' workspace, starting the Next.js development server for the documentation site.
```shell
pnpm turbo run dev --filter=polaris.shopify.com
```