All Projects → carbon-design-system → Carbon Web Components

carbon-design-system / Carbon Web Components

Licence: apache-2.0
Carbon Design System variant on top of Web Components

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Carbon Web Components

sodium-ui
Sodium is a simple, modular and customizable web component library to build elegant and accessible UI pieces for your React Application.
Stars: ✭ 23 (-86.55%)
Mutual labels:  web-components, component-library, design-system
Clarity
Clarity is a scalable, accessible, customizable, open source design system built with web components. Works with any JavaScript framework, built for enterprises, and designed to be inclusive.
Stars: ✭ 6,398 (+3641.52%)
Mutual labels:  design-system, component-library, web-components
Axiom React
Axiom - Brandwatch design system and React pattern library
Stars: ✭ 41 (-76.02%)
Mutual labels:  design-system, component-library
Components
Example Components (Built with Tonic)
Stars: ✭ 42 (-75.44%)
Mutual labels:  web-components, component-library
Vue Design System
An open source tool for building UI Design Systems with Vue.js
Stars: ✭ 2,077 (+1114.62%)
Mutual labels:  design-system, component-library
Carbon Components Svelte
Svelte implementation of the Carbon Design System
Stars: ✭ 685 (+300.58%)
Mutual labels:  design-system, component-library
Orbit
React components of open-source Orbit design system by Kiwi.com
Stars: ✭ 774 (+352.63%)
Mutual labels:  design-system, component-library
Stylable
Stylable - CSS for components
Stars: ✭ 1,109 (+548.54%)
Mutual labels:  design-system, web-components
Circuit Ui
SumUp's component library for the web
Stars: ✭ 625 (+265.5%)
Mutual labels:  design-system, component-library
Minna Ui
😸 A fast, friendly, and fun web UI kit for everyone.
Stars: ✭ 86 (-49.71%)
Mutual labels:  design-system, web-components
Purescript Ocelot
An opinionated component library for Halogen apps
Stars: ✭ 81 (-52.63%)
Mutual labels:  design-system, component-library
Scale
The Scale library offers a set of customizable web components written with Stencil.js & TypeScript. The default theme of the library can be easily replaced so that a corresponding corporate identity of a dedicated brand can be represented.
Stars: ✭ 87 (-49.12%)
Mutual labels:  design-system, web-components
Fast
The adaptive interface system for modern web experiences.
Stars: ✭ 6,532 (+3719.88%)
Mutual labels:  web-components, component-library
Blazor.fast
A tiny wrapper around Fast and Fluent Web Components to integrate with Blazor and easily use the EditForm components
Stars: ✭ 23 (-86.55%)
Mutual labels:  design-system, web-components
Pivotal Ui
Pivotal's design system & component library
Stars: ✭ 637 (+272.51%)
Mutual labels:  design-system, component-library
Website
Website and documentation for Radix.
Stars: ✭ 45 (-73.68%)
Mutual labels:  design-system, component-library
Aksara Ui
Aksara Design System, from Kata.ai.
Stars: ✭ 107 (-37.43%)
Mutual labels:  design-system, component-library
Backpack
Backpack Design System
Stars: ✭ 396 (+131.58%)
Mutual labels:  design-system, component-library
React95
🌈🕹 Refreshed Windows 95 style UI components for your React app
Stars: ✭ 4,877 (+2752.05%)
Mutual labels:  design-system, component-library
Components
Primer React components
Stars: ✭ 1,133 (+562.57%)
Mutual labels:  design-system, component-library

A Carbon Design System variant that's as easy to use as native HTML elements, with no framework tax, no framework silo.

Carbon Design System

Carbon is an open-source design system built by IBM. With the IBM Design Language as its foundation, the system consists of working code, design tools and resources, human interface guidelines, and a vibrant community of contributors.

Carbon is released under the Apache-2.0 license

This project is using Percy.io for visual regression testing

carbon-web-components

carbon-web-components is a variant of Carbon Design System with Custom Elements v1 and Shadow DOM v1 specs.

The effort stems from https://github.com/carbon-design-system/issue-tracking/issues/121. If you are interested in this project, adding 👍 to the description of that GH issue, or even contributing, will be greatly appreciated!

Getting started

To install carbon-web-components in your project, you will need to run the following command using npm:

npm install -S carbon-web-components carbon-components lit-html lit-element

If you prefer Yarn, use the following command instead:

yarn add carbon-web-components carbon-components lit-html lit-element

Basic usage

Our example at CodeSandbox shows the most basic usage:

Edit carbon-web-components

The first thing you need is setting up a module bundler to resolve ECMAScript imports. Above example uses Webpack. You can use other bundlers like Rollup, too.

Once you set up a module bundler, you can start importing our component modules, like:

import 'carbon-web-components/es/components/dropdown/dropdown.js';
import 'carbon-web-components/es/components/dropdown/dropdown-item.js';

Once you do that, you can use our components in the same manner as native HTML tags, like:

<bx-dropdown trigger-content="Select an item">
  <bx-dropdown-item value="all">Option 1</bx-dropdown-item>
  <bx-dropdown-item value="cloudFoundry">Option 2</bx-dropdown-item>
  <bx-dropdown-item value="staging">Option 3</bx-dropdown-item>
  <bx-dropdown-item value="dea">Option 4</bx-dropdown-item>
  <bx-dropdown-item value="router">Option 5</bx-dropdown-item>
</bx-dropdown>

If you just want to try our components for demonstrations, etc., you can use CDNs that support module mapping (e.g. JSPM). With it, you can just import our modules in <script type="module">:

<!DOCTYPE html>
<html>
  <head>
    <script type="module">
      import 'https://jspm.dev/carbon-web-components/es/components/dropdown/dropdown.js';
      import 'https://jspm.dev/carbon-web-components/es/components/dropdown/dropdown-item.js';
    </script>
    <style type="text/css">
      #app {
        font-family: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
        width: 300px;
        margin: 2rem;
      }

      bx-dropdown:not(:defined),
      bx-dropdown-item:not(:defined) {
        visibility: hidden;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <bx-dropdown trigger-content="Select an item">
        <bx-dropdown-item value="all">Option 1</bx-dropdown-item>
        <bx-dropdown-item value="cloudFoundry">Option 2</bx-dropdown-item>
        <bx-dropdown-item value="staging">Option 3</bx-dropdown-item>
        <bx-dropdown-item value="dea">Option 4</bx-dropdown-item>
        <bx-dropdown-item value="router">Option 5</bx-dropdown-item>
      </bx-dropdown>
    </div>
  </body>
</html>

Angular

Edit carbon-web-components with Angular

Angular users can use our components in the same manner as native HTML tags, too, once you add CUSTOM_ELEMENTS_SCHEMA schema to your Angular module, like:

import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';

@NgModule({
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  declarations: [AppComponent],
  imports: [BrowserModule],
  bootstrap: [AppComponent],
})
export class AppModule {}

The .d.ts files in carbon-web-components package are compiled with TypeScript 3.7. You can use TypeScript 3.7 in your Angular application with upcoming Angular 9.0 release, or with the following instructions, so your application can use those .d.ts files:

React

Edit carbon-web-components with React

You can use wrapper React components in carbon-web-components/es/components-react generated automatically from the custom elements which allows you to use our components seamlessly in your React code. Here's an example:

import React from 'react';
import { render } from 'react-dom';
import BXDropdown from 'carbon-web-components/es/components-react/dropdown/dropdown.js';
import BXDropdownItem from 'carbon-web-components/es/components-react/dropdown/dropdown-item.js';

const App = () => (
  <BXDropdown triggerContent="Select an item">
    <BXDropdownItem value="all">Option 1</BXDropdownItem>
    <BXDropdownItem value="cloudFoundry">Option 2</BXDropdownItem>
    <BXDropdownItem value="staging">Option 3</BXDropdownItem>
    <BXDropdownItem value="dea">Option 4</BXDropdownItem>
    <BXDropdownItem value="router">Option 5</BXDropdownItem>
  </BXDropdown>
);

render(<App />, document.getElementById('root'));

Note: Using the React wrapper requires an additional dependency, prop-types.

To run the wrapper React components in SSR environment requires Node 12.16.3 or above that supports "conditional mapping" feature:

Edit carbon-web-components with React SSR

Same Node version requirement applies to Next.js:

Edit carbon-web-components with React SSR

Vue

Edit carbon-web-components with Vue

Vue users can use our components in the same manner as native HTML tags, without any additional steps!

Other usage guides

Getting started with development

  1. Fork this repository and clone it
  2. yarn install
  3. yarn wca && yarn storybook

Running React/Angular/Vue Storybook demo

List of available components

View available web components at: https://web-components.carbondesignsystem.com/. You can see usage information in several ways:

  1. Going to Docs tab, where it shows the usage and available attributes, properties and custom events.
  2. Clicking the KNOBS tab at the bottom and changing values there. Most knobs are shown as something like Button kind (kind), where kind is the attribute name
  3. Clicking the ACTION LOGGER tab at the bottom and interacting with the selected component. You may see something like bx-modal-closed which typically indicates that an event with such event type is fired. You can also expand the twistie to see the details of the event

Browser support

  • Latest Chrome/Safari/FF ESR
  • IE/Edge support is bast-effort basis
    • Some components may not be supported

To support IE, you need a couple additional setups:

  • Toolstack to re-transpile our code to ES5 (e.g. by specifying IE11 in @babel/preset-env configuration)
  • Polyfills, listed here

Here's an example code that shows such setup:

Edit carbon-web-components with IE

Coding conventions

Can be found at here.

Creating build

> yarn clean
> yarn build

You'll see the build artifacts in /path/to/carbon-web-components/es directory.

Running unit test

You can run unit test by:

> gulp test:unit

You can run specific test spec by:

> gulp test:unit -s tests/spec/dropdown_spec.ts

You can choose a browser (instead of Headless Chrome) by:

> gulp test:unit -b Firefox

You can keep the browser after the test (and re-run the test when files change) by:

> gulp test:unit -b Chrome -k

You can prevent code coverate instrumentation code from being generated by:

> gulp test:unit -d

You can update snapshots by:

> gulp test:unit --update-snapshot

Above options can be used together. This is useful to debug your code as you test:

> gulp test:unit -s tests/spec/dropdown_spec.ts -b Chrome -d -k

Running build integration test

You can run build integration test by:

> yarn test:integration:build

You can run a specific set of UI test steps (e.g. running tests/integration/build/form-angular_steps.js only) by:

> yarn test:integration:build form-angular_steps

By default Chrome runs in headless mode. You can show Chrome UI by:

> CI=false yarn test:integration:build

Running UI integration test

You can run UI integration test by:

> yarn test:integration:ui

You can run a specific set of UI test steps (e.g. running tests/integration/ui/dropdown_steps.js only) by:

> yarn test:integration:ui dropdown_steps

By default Chrome runs in headless mode. You can show Chrome UI by:

> CI=false yarn test:integration:ui
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].