carbon-design-system/carbon-components-svelte được TopGit xếp vào nhóm dự án UI/UX, với 2.9k sao trên GitHub, viết chủ yếu bằng TypeScript. Svelte implementation of the Carbon Design System
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Carbon Components Svelte is a Svelte component library that implements the Carbon Design System, an open source design system by IBM. Ship accessible, consistent, production-ready interfaces.
90+ components: from inputs to data tables
5 built-in themes: two light, three dark
Fully typed TypeScript API: props, events, and slots
WCAG 2.1 AA: keyboard and screen-reader ready
The Carbon Svelte ecosystem also includes:
Carbon Icons Svelte: 2,700+ Carbon icons as Svelte components
Carbon Pictograms Svelte: 1,500+ Carbon pictograms as Svelte components
Carbon Charts Svelte: 25+ charts, powered by d3
Carbon Preprocess Svelte: Collection of Svelte preprocessors for Carbon
Documentation
Installation
# npm
npm i carbon-components-svelte
# pnpm
pnpm add carbon-components-svelte
# Yarn
yarn add carbon-components-svelte
# Bun
bun add carbon-components-svelte
Usage
Styling
Before importing components, you will need to first apply Carbon component styles. The Carbon Design System supports five themes (2 light, 3 dark).
white.css: Default Carbon theme (light)
g10.css: Gray 10 theme (light)
g80.css: Gray 80 theme (dark)
g90.css: Gray 90 theme (dark)
g100.css: Gray 100 theme (dark)
all.css: All five themes (White, Gray 10, Gray 80, 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:
css/white.scss
css/g10.scss
css/g80.scss
css/g90.scss
css/g100.scss
css/all.scss
Import one theme once at the top-level entry point of your app, like index.js or src/+layout.svelte.
The most performant method to load styles is to import SCSS directly from carbon-components. Although it requires more set up, you can reduce the size of the bundle CSS by importing individual component styles instead of a pre-compiled CSS StyleSheet.
Refer to the official Carbon guide on SASS for documentation.
Dynamic theming
To switch themes at runtime, import the combined "all.css" StyleSheet instead of a single theme. It bundles all five themes and toggles between them through a theme attribute on the HTML element.
import "carbon-components-svelte/css/all.css";
Update the theme by setting the theme attribute on the html element. The default theme is "white".
Refer to the documentation site for component API documentation.
Preprocessors & Plugins
carbon-preprocess-svelte is a collection of Svelte preprocessors for Carbon. It trims build times and bundle size with two drop-in tools for faster HMR in development and leaner CSS when you ship.
[!NOTE]
Using carbon-preprocess-svelte is optional and not a prerequisite for this library. It should be installed as a development dependency.
# npm
npm i -D carbon-preprocess-svelte
# pnpm
pnpm add -D carbon-preprocess-svelte
# Yarn
yarn add -D carbon-preprocess-svelte
# Bun
bun add -D carbon-preprocess-svelte
optimizeImports
optimizeImports is a Svelte preprocessor that rewrites barrel imports from Carbon components/icons/pictograms packages to their source Svelte code paths. This can significantly speed up development and production build compile times while preserving typeahead and autocompletion offered by integrated development environments (IDE) like VS Code.
The preprocessor optimizes imports from the following packages:
carbon-components-svelte
carbon-icons-svelte
carbon-pictograms-svelte
Before & After
- import { Button } from "carbon-components-svelte";
+ import Button from "carbon-components-svelte/src/Button/Button.svelte";
- import { Add } from "carbon-icons-svelte";
+ import Add from "carbon-icons-svelte/lib/Add.svelte";
- import { Airplane } from "carbon-pictograms-svelte";
+ import Airplane from "carbon-pictograms-svelte/lib/Airplane.svelte";
optimizeCss
optimizeCss is a Vite plugin that removes unused Carbon styles at build time, often removing hundreds of kilobytes from production bundles. The plugin is compatible with Rollup (Vite extends the Rollup plugin API).
[!NOTE]
This is a plugin and not a Svelte preprocessor. It should be added to the list of vite.plugins. For Vite set-ups, this plugin is only run when building the app. For Rollup and Webpack, you should conditionally apply the plugin to only execute when building for production.
Configure your bundler
Add optimizeImports to your Svelte preprocessor and optimizeCss to your bundler plugins. See examples for full configurations.
The icon and pictogram sets ship as separate packages of individual Svelte components. Each is optional, so install only what you need.
Icons
2,700+ icons designed for product UI, in four sizes (16, 20, 24, and 32 pixels), set with a single prop.
# npm
npm i carbon-icons-svelte
# pnpm
pnpm add carbon-icons-svelte
# Yarn
yarn add carbon-icons-svelte
# Bun
bun add carbon-icons-svelte
<script>
import Add from "carbon-icons-svelte/lib/Add.svelte";
</script>
<Add size={24} />
Pictograms
1,500+ illustrative pictograms for empty states, onboarding, hero sections, and feature callouts. Larger than icons, 64px by default.
# npm
npm i carbon-pictograms-svelte
# pnpm
pnpm add carbon-pictograms-svelte
# Yarn
yarn add carbon-pictograms-svelte
# Bun
bun add carbon-pictograms-svelte
<script>
import Cloud from "carbon-pictograms-svelte/lib/Cloud.svelte";
</script>
<Cloud />
Documentation for LLMs
Documentation is available in LLM-friendly plain text for use with coding assistants, plus a standalone Markdown document for every component. Append .md to any component's URL to read it.
llms.txt: a component index where each entry links to its per-component Markdown doc, sized for model context windows.
llms-full.txt: the full component documentation in a single plain-text file.
Examples
examples/rollup
examples/sveltekit
examples/vite
examples/webpack
TypeScript support
TypeScript definitions are generated by sveld.
Contributing
Refer to the Contributing guidelines.
Changelog
License
Apache 2.0
IBM Telemetry
This package uses IBM Telemetry to collect de-identified and anonymized metrics data in CI environments. By installing
this package as a dependency you are agreeing to telemetry collection. To opt out, see
Opting out of IBM Telemetry data collection.
For more information on the data being collected, please see the
IBM Telemetry documentation.
carbon-design-system/carbon-components-svelte có phải mã nguồn mở không?
Có — carbon-design-system/carbon-components-svelte phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/carbon-design-system/carbon-components-svelte.
carbon-design-system/carbon-components-svelte có trang demo không?
Dự án có trang chủ ở https://svelte.carbondesignsystem.com. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
carbon-design-system/carbon-components-svelte còn đang phát triển không?
Commit gần nhất trên carbon-design-system/carbon-components-svelte là 12 ngày trước (theo timestamp GitHub). Repo có 263 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
carbon-design-system/carbon-components-svelte dùng license gì?
carbon-design-system/carbon-components-svelte phát hành theo license Apache-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
Đọc thêm về carbon-design-system/carbon-components-svelte ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/carbon-design-system/carbon-components-svelte là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về carbon-components-svelte?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về carbon-components-svelte.