Kyndryl Design System - Foundation
Contributing to this project
Read the Contributing Guide here.
Using this library in another project
Install the package
# stable/main
npm install @kyndryl-design-system/foundation -S
# beta (use until first stable release)
npm install @kyndryl-design-system/foundation@beta -S
# when using beta, lock the version, as breaking changes can happen at any time
Import the root styles to your app's global styles
The method used (JS Import, SCSS @use, CSS @import, or <style> tag) will vary based on your framework/bundler, but the stylesheet can be found in node_modules
at:
@kyndryl-design-system/foundation/scss/root.scss
// or
@kyndryl-design-system/foundation/css/root.css
Use CSS tokens/variables
You can make use of tokens/variables included in root.css such as --kyn-header-height
to pad the body for the fixed position header, --kyn-spacing-gutter
for the padding on your main container, or any of the color tokens. These are very bare-bones currently, and will need to be fleshed out later.
Start using components
See Storybook for the full components documentation.
Example: Component with Sub-components
This example imports the Header component AND all of it's subcomponents by targeting the index file.
import '@kyndryl-design-system/foundation/components/global/header';
<kyn-header>
<kyn-header-nav>
<kyn-header-link>Link</kyn-header-link>
</kyn-header-nav>
</kyn-header>
Example: Single Component
This example imports the HeaderLink component by targeting the component file directly.
import '@kyndryl-design-system/foundation/components/global/header/headerLink';
<kyn-header-link>Link</kyn-header-link>
React usage
React does not yet support automatic interop with Web Components. This means that React treats all props passed to Web Components as string attributes. It sounds like they are planning to release it with React 19, and is now available behind an @experimental
flag. Until you've upgraded to a version of React that has support, you will need to use a library like reactify-wc to use these components in React.
Some options for React wrapper libraries:
Server-Side Rendering (SSR)
When using with an SSR framework like Next.js, you may encounter errors with code that only runs client-side, like window
references for example. Here is an article that provides some methods to work around this: Using Non-SSR Friendly Components with Next.js. Basically, for components that make use of something like window
, they need their rendering deferred to only happen on the client-side.