Getting Started
April 1, 2026 · View on GitHub
This document shows the basic steps to integrate the Lyne components into your project.
Component documentation is available on digital.sbb.ch and on Docs App.
Select your technology to get started:
Plain Javascript
ⓘ For simple testing and reproductions, see Stackblitz starter for @sbb-esta/lyne-elements.
-
Install the
@sbb-esta/lyne-elementsand@sbb-esta/lyne-elements-experimentalpackages:npm install --save @sbb-esta/lyne-elements @sbb-esta/lyne-elements-experimentalor, if using yarn:
yarn add @sbb-esta/lyne-elements @sbb-esta/lyne-elements-experimental -
Including global styles is strongly recommended to apply all SBB styles to your application. See the Theming Guide if you prefer more granularity on what to import.
@import 'node_modules/@sbb-esta/lyne-elements/standard-theme.css'; /** If you are using experimental components, additionally add */ @import 'node_modules/@sbb-esta/lyne-elements-experimental/standard-theme.css'; -
Import the desired element and add it to globalThis:
import { SbbButtonElement } from '@sbb-esta/lyne-elements/button.js'; globalThis.SbbButtonElement = SbbButtonElement;
Angular
ⓘ We provide a Lyne Angular wrapper which helps to use Lyne components in Angular. See https://lyne-angular.app.sbb.ch for more information. However, it's possible to use Lyne Components in Angular without the wrapper.
ⓘ For simple testing and reproductions, see Stackblitz starter for @sbb-esta/lyne-angular.
-
Install Angular CLI, see Angular CLI documentation
-
Install the
@sbb-esta/lyne-elementspackage:npm install --save @sbb-esta/lyne-elementsor, if using yarn:
yarn add @sbb-esta/lyne-elements -
Including global styles is strongly recommended to apply all SBB styles to your application. See the Theming Guide if you prefer more granularity on what to import. Importing stylesheets is done by editing the
styles.(s)css:@import 'node_modules/@sbb-esta/lyne-elements/standard-theme.css'; /** If you are using experimental components, additionally add */ @import 'node_modules/@sbb-esta/lyne-elements-experimental/standard-theme.css';or editing your
angular.json:... "styles": [ "src/styles.scss", "node_modules/@sbb-esta/lyne-elements/standard-theme.css", /** If you are using experimental components */ "node_modules/@sbb-esta/lyne-elements-experimental/standard-theme.css" ], ... -
In order to use web components with Angular, you have to import
CUSTOM_ELEMENTS_SCHEMAfrom the@angular/corepackage. -
In each component, import the Lyne components you want to use in the TypeScript file: e.g.
import '@sbb-esta/lyne-elements/button.js';
Example app
import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import '@sbb-esta/lyne-elements/button.js';
@Component({
selector: 'my-app',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: ` <sbb-button>Lorem ipsum</sbb-button> `,
})
export class App {}
bootstrapApplication(App).catch((err) => console.error(err));
React/Next.js
ⓘ For simple testing and reproductions, see Stackblitz starter for @sbb-esta/lyne-react.
-
Prepare a React and Next.js setup.
-
Install the
@sbb-esta/lyne-reactpackage:npm install --save @sbb-esta/lyne-reactor, if using yarn:
yarn add @sbb-esta/lyne-react -
Including global styles is strongly recommended to apply all SBB styles to your application. See the Theming Guide if you prefer more granularity on what to import.
@import '~@sbb-esta/lyne-elements/standard-theme.css'; /** If you are using experimental components, additionally add */ @import '~@sbb-esta/lyne-elements-experimental/standard-theme.css'; -
Enhance the
transpilePackagesarray in Next.js config.module.exports = { ..., transpilePackages: [ '@sbb-esta/lyne-react', '@sbb-esta/lyne-elements', '@lit/react', '@lit/reactive-element', 'lit', 'lit-html', 'lit-element', ], } -
(Optional) To activate Server Side Rendering with Declarative Shadow DOM, you have to install the
@lit-labs/nextjspackage and use the methodwithLitSSR():const withLitSSR = require('@lit-labs/nextjs')({ addDeclarativeShadowDomPolyfill: true, }); module.exports = withLitSSR({ ..., transpilePackages: [ '@sbb-esta/lyne-elements', '@sbb-esta/lyne-react', '@sbb-esta/lyne-design-tokens', '@lit-labs/nextjs', '@lit-labs/ssr', '@lit-labs/ssr-react', '@lit/react', '@lit/reactive-element', 'lit', 'lit-element', 'lit-html', ], }); -
Import and use Lyne component:
import { SbbButton } from '@sbb-esta/lyne-react/button'; export default function MyComponent() { return <SbbButton onClick={() => {}}></SbbButton>; }Whenever types are needed, they can be imported directly from the
@sbb-esta/lyne-elementspackage:import type { SbbButtonSize } from '@sbb-esta/lyne-elements/button.js'; import { SbbButton } from '@sbb-esta/lyne-react/button'; export default function MyComponent() { const size: SbbButtonSize = 'm'; return <SbbButton onClick={() => {}} size={size}></SbbButton>; }