All Projects → IBM → Carbon Components Svelte

IBM / Carbon Components Svelte

Licence: apache-2.0
Svelte implementation of the Carbon Design System

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Carbon Components Svelte

carbon-components-svelte
Svelte implementation of the Carbon Design System
Stars: ✭ 1,615 (+135.77%)
Mutual labels:  svelte, component-library, carbon, design-system, ui-library
kahi-ui
Straight-forward Svelte UI for the Web
Stars: ✭ 169 (-75.33%)
Mutual labels:  svelte, component-library, design-system, ui-library
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 (-96.64%)
Mutual labels:  component-library, design-system, ui-library
design-systems
A list of famous design systems, design languages and guidelines
Stars: ✭ 403 (-41.17%)
Mutual labels:  component-library, design-system, ui-library
smores-react
🍭 Marshmallow React components
Stars: ✭ 34 (-95.04%)
Mutual labels:  component-library, design-system
Pivotal Ui
Pivotal's design system & component library
Stars: ✭ 637 (-7.01%)
Mutual labels:  design-system, component-library
Circuit Ui
SumUp's component library for the web
Stars: ✭ 625 (-8.76%)
Mutual labels:  design-system, component-library
mayflower
Mayflower Mono Repo (react and pattern lab and documentation)
Stars: ✭ 17 (-97.52%)
Mutual labels:  component-library, design-system
vf-core
A (primarily CSS) framework that targets needs of life science websites and services
Stars: ✭ 16 (-97.66%)
Mutual labels:  component-library, design-system
bui
‹b› Web components for creating applications – built by Blackstone Publishing using lit-html and lit-element
Stars: ✭ 29 (-95.77%)
Mutual labels:  design-system, ui-library
marble
Marble is the design system used by The Metropolitan Museum of Art 🏛
Stars: ✭ 14 (-97.96%)
Mutual labels:  component-library, design-system
svelteit
Svelteit is a minimalistic UI/UX component library for Svelte and Sapper projects
Stars: ✭ 64 (-90.66%)
Mutual labels:  svelte, component-library
UUI
React-based components and accelerators library built by EPAM Systems.
Stars: ✭ 90 (-86.86%)
Mutual labels:  design-system, ui-library
polarwind
Envoy's product component library
Stars: ✭ 17 (-97.52%)
Mutual labels:  component-library, design-system
maker
Maker Design System by Square
Stars: ✭ 43 (-93.72%)
Mutual labels:  component-library, design-system
Hiui
HIUI is a solution that is adequate for the fomulation and implementation of interaction and UI design standard for front, middle and backend.
Stars: ✭ 366 (-46.57%)
Mutual labels:  design-system, component-library
Operational Ui
Building blocks for effective operational interfaces
Stars: ✭ 258 (-62.34%)
Mutual labels:  design-system, component-library
Svelte Materialify
A Material UI Design Component library for Svelte heavily inspired by vuetify.
Stars: ✭ 351 (-48.76%)
Mutual labels:  component-library, svelte
Backpack
Backpack Design System
Stars: ✭ 396 (-42.19%)
Mutual labels:  design-system, component-library
anv-ui-components
AnyVision React components library
Stars: ✭ 35 (-94.89%)
Mutual labels:  component-library, design-system

carbon-components-svelte

NPM GitHub npm downloads to date Build

Carbon Components Svelte is a Svelte component library that implements the Carbon Design System, an open source design system by IBM.

Design systems facilitate design and development through reuse, consistency, and extensibility.

The Carbon Svelte portfolio also includes:

Documentation

Deploys by Vercel

The documentation website contains live demos and examples.

Other forms of documentation are auto-generated:

Getting started

Install carbon-components-svelte as a development dependency.

yarn add -D carbon-components-svelte
# OR
npm i -D carbon-components-svelte

Usage

The quickest way to get started is to customize a template from the examples folder.

Example set-ups demonstrate usage with popular application bundlers and frameworks. They include a mix of client-side rendering (CSR) and server-side rendering (SSR) approaches.

Scaffolding

Each example is published in a dedicated branch of the same name.

Use degit to scaffold a new project:

For example, to use the svite template, run the following commands:

npx degit ibm/carbon-components-svelte#svite svelte-app
cd svelte-app
yarn install

Importing components

Import components from carbon-components-svelte in the script tag of your Svelte file.

<!-- App.svelte -->
<script>
  import { Accordion, AccordionItem } from "carbon-components-svelte";
</script>

<Accordion>
  <AccordionItem title="Section 1" open> Content 1 </AccordionItem>
  <AccordionItem title="Section 2"> Content 2 </AccordionItem>
  <AccordionItem title="Section 3"> Content 3 </AccordionItem>
</Accordion>

Refer to COMPONENT_INDEX.md for component API documentation.

Pre-compiled CSS StyleSheets

carbon-components-svelte includes pre-compiled CSS StyleSheets for each Carbon theme:

  • white.css: Default Carbon theme (light)
  • g10.css: Gray 10 theme (light)
  • g90.css: Gray 90 theme (dark)
  • g100.css: Gray 100 theme (dark)
  • all.css: All themes (White, Gray 10, Gray 90, Gray 100) using CSS variables

Each StyleSheet is generated from the flagship carbon-components library.

The compiled CSS is generated from the following .scss files:

Usage

svelte-preprocess

The easiest way to import a StyleSheet is with svelte-preprocess.

const svelteOptions = {
  preprocess: require("svelte-preprocess")(),
};
<!-- App.svelte -->
<style lang="scss" global>
  /** Gray 10 theme **/
  @import "carbon-components-svelte/css/g10";
</style>
JavaScript import

Importing a CSS file in a JavaScript file will require the appropriate file loader(s).

import "carbon-components-svelte/css/all.css";
import App from "./App.svelte";

const app = new App({ target: document.body });

export default app;

See webpack.config.js in examples/webpack.

Dynamic theming

Use carbon-components-svelte/css/all.css for dynamic, client-side styling.

Update the theme by setting the theme attribute on the html element. The default theme is "white".

<!DOCTYPE html>
<html lang="en" theme="g10">
  <body>
    ...
  </body>
</html>

Using JavaScript:

<script>
  /** @type {"white" | "g10" | "g90" | "g100"} */
  let theme = "white";

  $: document.documentElement.setAttribute("theme", theme);
</script>

<button on:click="{() => (theme = 'g90')}">Update theme</button>

Preprocessors

optimizeCarbonImports

optimizeCarbonImports is a Svelte preprocessor that optimizes base imports inside the script block of a Svelte file from the following libraries:

  • carbon-components-svelte
  • carbon-icons-svelte
  • carbon-pictograms-svelte

The preprocessor rewrites base imports to directly import the source Svelte file. This may lead to faster complile times during development.

Example:

Before

import { Button, Header } from "carbon-components-svelte";
import { Notification20 } from "carbon-icons-svelte";
import { Airplane } from "carbon-pictograms-svelte";

After

import Button from "carbon-components-svelte/Button/Button.svelte";
import Header from "carbon-components-svelte/UIShell/GlobalHeader/Header.svelte";
import Notification20 from "carbon-icons-svelte/lib/Notification20/Notification20.svelte";
import Airplane from "carbon-pictograms-svelte/lib/Airplane/Airplane.svelte";

svelte.config.js

// svelte.config.js
const {
  optimizeCarbonImports,
} = require("carbon-components-svelte/preprocess");

module.exports = {
  preprocess: [optimizeCarbonImports()],
};

svelte-loader

// webpack.config.js
const {
  optimizeCarbonImports,
} = require("carbon-components-svelte/preprocess");

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.svelte$/,
        use: {
          loader: "svelte-loader",
          options: {
            hotReload: true,
            preprocess: [optimizeCarbonImports()],
          },
        },
      },
    ],
  },
};

TypeScript support

TypeScript definitions are generated by sveld.

Contributing

Refer to the Contributing guidelines.

Changelog

License

Apache 2.0

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].