Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
carbon-components-svelte
Advanced tools
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:
The documentation website contains live demos and examples.
Other forms of documentation are auto-generated:
Install carbon-components-svelte
as a development dependency.
yarn add -D carbon-components-svelte
# OR
npm i -D carbon-components-svelte
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.
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
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.
carbon-components-svelte
includes pre-compiled CSS StyleSheets for each Carbon theme:
Each StyleSheet is generated from the flagship carbon-components library.
The compiled CSS is generated from the following .scss
files:
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>
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.
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>
optimizeCarbonImports
is a Svelte preprocessor that optimizes base imports inside the script
block of a Svelte file from the following libraries:
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
const {
optimizeCarbonImports,
} = require("carbon-components-svelte/preprocess");
module.exports = {
preprocess: [optimizeCarbonImports()],
};
// 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 definitions are generated by sveld.
Refer to the Contributing guidelines.
0.31.0 - 2021-03-20
Breaking Changes
title
value in InlineNotification
title
, caption
values in ToastNotification
iconDescription
prop from HeaderNavMenu
Features
Popover
componentContextMenu
componentTabsSkeleton
Select
Pagination
Fixes
NumberInput
Slider
markup to use CSS to hide input if hideTextInput
is true
StructuredListBody
MultiSelect
: "clear" should be typed as a custom eventLink
autofocus
attribute if the value is true
Documentation
Slider
hidden text input, invalid, disabled examplesSelect
warning, invalid, helper text, skeleton (hidden label) examplesRadioButton
disabled buttons exampleToastNotification
, InlineNotification
Select
item groups example to use the hidden default optionHousekeeping
carbon-components
to version 10.31.0carbon-icons-svelte
to version 10.27.0 (icons are correctly typed using SvelteComponentTyped
)FAQs
Svelte implementation of the Carbon Design System
The npm package carbon-components-svelte receives a total of 13,604 weekly downloads. As such, carbon-components-svelte popularity was classified as popular.
We found that carbon-components-svelte demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.