Top Related Projects
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
An enterprise-class UI design language and React UI library
Bootstrap components built with React
A utility-first CSS framework for rapid UI development.
Chakra UI is a component system for building SaaS products with speed ⚡️
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Quick Overview
Polaris React is Shopify's design system for building user interfaces. It provides a comprehensive set of React components, design guidelines, and resources to help developers create consistent and high-quality Shopify admin experiences. The library aims to streamline the development process and ensure a cohesive look and feel across Shopify's products.
Pros
- Extensive collection of pre-built, customizable React components
- Consistent design language aligned with Shopify's branding and user experience
- Regular updates and maintenance by Shopify's team
- Comprehensive documentation and examples
Cons
- Primarily designed for Shopify admin interfaces, which may limit its applicability in other contexts
- Learning curve for developers unfamiliar with Shopify's design patterns
- Potential for over-reliance on the design system, potentially limiting creativity in unique use cases
Code Examples
- Creating a basic page layout:
import React from 'react';
import {Page, Layout, Card} from '@shopify/polaris';
function MyPage() {
return (
<Page title="My Page">
<Layout>
<Layout.Section>
<Card title="Welcome" sectioned>
<p>This is a sample card using Polaris components.</p>
</Card>
</Layout.Section>
</Layout>
</Page>
);
}
- Using a form with Polaris components:
import React, {useState, useCallback} from 'react';
import {Form, FormLayout, TextField, Button} from '@shopify/polaris';
function MyForm() {
const [name, setName] = useState('');
const handleSubmit = useCallback(() => {
console.log('Form submitted with name:', name);
}, [name]);
return (
<Form onSubmit={handleSubmit}>
<FormLayout>
<TextField
label="Name"
value={name}
onChange={(value) => setName(value)}
/>
<Button submit>Submit</Button>
</FormLayout>
</Form>
);
}
- Creating a data table:
import React from 'react';
import {DataTable} from '@shopify/polaris';
function MyDataTable() {
const rows = [
['Emerald Silk Gown', '$875.00', 124689, 140],
['Mauve Cashmere Scarf', '$230.00', 124533, 83],
];
return (
<DataTable
columnContentTypes={['text', 'numeric', 'numeric', 'numeric']}
headings={['Product', 'Price', 'SKU Number', 'Net quantity']}
rows={rows}
/>
);
}
Getting Started
To start using Polaris React in your project:
-
Install the package:
npm install @shopify/polaris
-
Import and use the CSS in your app's entry point (e.g.,
index.js
):import '@shopify/polaris/build/esm/styles.css';
-
Wrap your app with the
AppProvider
component:import {AppProvider} from '@shopify/polaris'; function App() { return ( <AppProvider i18n={{}}> {/* Your app components */} </AppProvider> ); }
Now you can start using Polaris components in your React application.
Competitor Comparisons
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
Pros of Material-UI
- Larger ecosystem with more components and third-party extensions
- More customizable theming system with advanced features
- Better documentation and extensive examples
Cons of Material-UI
- Steeper learning curve due to more complex API
- Larger bundle size, which may impact performance
- Less opinionated design, requiring more decisions from developers
Code Comparison
Material-UI example:
import Button from '@mui/material/Button';
function App() {
return <Button variant="contained">Hello World</Button>;
}
Polaris example:
import {Button} from '@shopify/polaris';
function App() {
return <Button primary>Hello World</Button>;
}
Both libraries offer React components for building user interfaces, but Material-UI provides more flexibility and customization options, while Polaris focuses on a cohesive design system specifically tailored for Shopify's ecosystem. Material-UI's extensive feature set comes at the cost of increased complexity, while Polaris offers a more streamlined experience with a smaller learning curve. Developers should consider their project requirements, design preferences, and team expertise when choosing between these libraries.
An enterprise-class UI design language and React UI library
Pros of Ant Design
- Larger ecosystem with more components and tools
- More extensive documentation and examples
- Higher adoption rate and community support
Cons of Ant Design
- Steeper learning curve due to its extensive feature set
- Larger bundle size, which may impact performance
- Less opinionated design, requiring more customization effort
Code Comparison
Ant Design button example:
import { Button } from 'antd';
const MyComponent = () => (
<Button type="primary">Click me</Button>
);
Polaris React button example:
import { Button } from '@shopify/polaris';
const MyComponent = () => (
<Button primary>Click me</Button>
);
Both libraries offer similar component APIs, but Ant Design tends to use more props for customization, while Polaris React often uses boolean flags for common variations.
Ant Design provides a comprehensive UI toolkit suitable for various projects, while Polaris React is tailored specifically for Shopify-like interfaces. Ant Design offers more flexibility but requires more setup, whereas Polaris React provides a more opinionated and streamlined development experience for Shopify-oriented projects.
Bootstrap components built with React
Pros of react-bootstrap
- Wider community adoption and longer history, resulting in more resources and third-party integrations
- More flexible and customizable, allowing for easier adaptation to various design systems
- Lighter weight and potentially better performance due to modular component imports
Cons of react-bootstrap
- Less opinionated design, requiring more effort to achieve a cohesive look
- May require more configuration and setup to match specific brand guidelines
- Lacks some advanced components and features present in Polaris
Code Comparison
react-bootstrap:
import { Button, Modal } from 'react-bootstrap';
<Modal show={showModal} onHide={handleClose}>
<Modal.Header closeButton>
<Modal.Title>Modal Title</Modal.Title>
</Modal.Header>
<Modal.Body>Modal content here</Modal.Body>
<Modal.Footer>
<Button variant="secondary" onClick={handleClose}>Close</Button>
<Button variant="primary" onClick={handleSave}>Save Changes</Button>
</Modal.Footer>
</Modal>
Polaris:
import { Modal, TextContainer, Button } from '@shopify/polaris';
<Modal
open={active}
onClose={handleChange}
title="Modal Title"
primaryAction={{
content: 'Save',
onAction: handleSave,
}}
secondaryActions={[
{
content: 'Close',
onAction: handleChange,
},
]}
>
<Modal.Section>
<TextContainer>
<p>Modal content here</p>
</TextContainer>
</Modal.Section>
</Modal>
A utility-first CSS framework for rapid UI development.
Pros of Tailwind CSS
- Highly customizable and flexible, allowing for rapid UI development
- Utility-first approach enables quick styling without leaving HTML
- Smaller bundle size when properly configured with PurgeCSS
Cons of Tailwind CSS
- Steeper learning curve for developers new to utility-first CSS
- Can lead to cluttered HTML with many class names
- Requires additional setup and configuration for optimal performance
Code Comparison
Tailwind CSS:
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Button
</button>
Polaris React:
import { Button } from '@shopify/polaris';
<Button primary>Button</Button>
Key Differences
- Tailwind CSS is a utility-first CSS framework, while Polaris React is a React component library
- Tailwind focuses on low-level utility classes, whereas Polaris provides pre-built, styled components
- Tailwind offers more flexibility in design, while Polaris ensures consistency with Shopify's design system
Use Cases
- Tailwind CSS: Ideal for custom designs and projects requiring high flexibility
- Polaris React: Best for Shopify-related projects or applications aiming for a consistent, pre-designed look
Community and Ecosystem
- Both projects have active communities and regular updates
- Tailwind has a broader ecosystem with various plugins and extensions
- Polaris is more focused on the Shopify ecosystem and e-commerce applications
Chakra UI is a component system for building SaaS products with speed ⚡️
Pros of Chakra UI
- More flexible and customizable design system
- Larger community and ecosystem with more third-party components
- Better support for dark mode and color mode switching
Cons of Chakra UI
- Less opinionated, which may lead to inconsistent designs across projects
- Steeper learning curve due to more configuration options
- Not specifically tailored for e-commerce applications
Code Comparison
Chakra UI component:
<Box
bg="gray.100"
p={4}
borderRadius="md"
boxShadow="md"
>
<Text fontSize="xl">Hello, Chakra UI!</Text>
</Box>
Polaris React component:
<Card sectioned>
<TextContainer>
<DisplayText size="medium">Hello, Polaris!</DisplayText>
</TextContainer>
</Card>
Both libraries provide a component-based approach to building user interfaces, but Chakra UI offers more granular control over styling and layout. Polaris React components are more opinionated and aligned with Shopify's design system, making it easier to create consistent UIs for e-commerce applications. Chakra UI's flexibility allows for more diverse use cases but may require more effort to maintain consistency across projects.
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Pros of styled-components
- More flexible and customizable styling approach
- Better integration with component-based architecture
- Supports dynamic styling based on props
Cons of styled-components
- Steeper learning curve for developers new to CSS-in-JS
- Potential performance overhead for large applications
- Less opinionated, requiring more setup and configuration
Code Comparison
Polaris-React:
import {Button} from '@shopify/polaris';
<Button primary>Submit</Button>
styled-components:
import styled from 'styled-components';
const StyledButton = styled.button`
background-color: ${props => props.primary ? 'blue' : 'white'};
color: ${props => props.primary ? 'white' : 'black'};
`;
<StyledButton primary>Submit</StyledButton>
Summary
Polaris-React is a comprehensive UI kit with pre-built components, ideal for rapid development and consistent Shopify-like interfaces. It's more opinionated and easier to get started with but less flexible for custom designs.
styled-components offers a powerful CSS-in-JS solution, providing greater flexibility and customization. It integrates well with component-based architectures but requires more setup and has a steeper learning curve.
Choose Polaris-React for quick Shopify-style UIs or styled-components for highly customized, dynamic styling in React applications.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Polaris React (â ï¸ Deprecated)
The Shopify Polaris React library is deprecated.
We are no longer accepting contributions or feature requests in this repository.
On October 1, 2025, we released our Polaris Web Components for Shopify app development. We encourage Shopify App developers to adopt Polaris Web Components for new development.
This repository will remain available for historical purposes, but it will not receive updates or maintenance.
Why Web Components?
Polaris Web Components provide a more technology-agnostic foundation.
They work with every framework as well as plain JavaScript and server-rendered sites, enabling more Shopify App developers across more platforms to use Polaris.
About this repo
The shopify/polaris
repository is an intergalactic monorepo made up of NPM packages, VSCode extensions, and websites.
polaris/
âââ documentation # Documentation for working in the monorepo
âââ polaris-for-vscode # VS Code extension for Polaris
âââ polaris-icons # Icons for Polaris
âââ polaris-react # Components for @shopify/polaris package
âââ polaris-tokens # Design tokens for Polaris
âââ polaris.shopify.com # Documentation website
âââ stylelint-polaris # Rules for custom property usage and mainline coverage
Commands
Install dependencies and build workspaces
pnpm install && pnpm build
Run a command
One workspace
Run commands from a selected workspace using turbo run <command> --filter=<workspace>...
flag.
Command | Runs |
---|---|
pnpm turbo run dev --filter=@shopify/polaris | Open the react component storybook |
pnpm turbo run dev --filter=polaris.shopify.com | Open polaris.shopify.com NextJS site |
All workspaces
Run commands across all workspaces. This uses turbo run <command>
.
Command | Runs |
---|---|
pnpm changeset | Adds a new changelog entry |
pnpm lint | Lints all workspaces |
pnpm test | Tests all workspaces |
pnpm type-check | Build types and check for type errors |
pnpm clean | Remove generated files |
pnpm format | Format files with prettier |
Contribute to this repo
Pull requests are welcome. See the contribution guidelines for more information.
Licenses
Source code is under a custom license based on MIT. The license restricts Polaris usage to applications that integrate or interoperate with Shopify software or services, with additional restrictions for external, stand-alone applications.
All icons and images are licensed under the Polaris Design Guidelines License Agreement
Top Related Projects
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
An enterprise-class UI design language and React UI library
Bootstrap components built with React
A utility-first CSS framework for rapid UI development.
Chakra UI is a component system for building SaaS products with speed ⚡️
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot