@times-design-system/components-react-scss
v1.8.1
Published
Times Design System React components with SCSS styling
Maintainers
Readme
@times-design-system/components-react-scss
Times Design System React components with SCSS styling.
This package provides the same React components as @times-design-system/components-react, but uses SCSS styling with @times-design-system/theme-scss instead of CSS variables.
Installation
npm install @times-design-system/components-react-scss @times-design-system/theme-scssUsage
1. Install Theme Package
Install @times-design-system/theme-scss alongside this package:
npm install @times-design-system/theme-scss2. Import Theme at Application Root
In your main application stylesheet (once, at the root level):
// app.scss or globals.scss
@import '@times-design-system/theme-scss/theme-classes.scss';
@import '@times-design-system/theme-scss/tds-layout.scss';
@import '@times-design-system/theme-scss/tds-typography.scss';This generates CSS variables for the current theme and makes typography utilities available.
3. Import the Component Styles and Use Components
Component styles are compiled from SCSS at build time and shipped as one stylesheet. Import it once:
import '@times-design-system/components-react-scss/styles.css';
import { Button } from '@times-design-system/components-react-scss';
export function App() {
return <Button label="Click me" />;
}4. Wrap with Theme Class
Wrap your application with a theme class to apply the styling:
import './app.scss';
export function App() {
return (
<div className="theme-core">
<Button label="Click me" />
</div>
);
}Architecture
This package is built from the same component source as @times-design-system/components-react (the reference implementation); only the stylesheets differ. Each src/<Component>/styles.scss replaces the matching components-react/src/<Component>/styles.css at build time, so the two packages always expose identical components, props, exports and class names. scripts/react-components/parity.test.mjs enforces this (npm test).
Component Styling:
- Components use SCSS variables from theme-scss (e.g.,
$spacing-03,$border-radius-full) for layout tokens - Components define CSS custom properties for semantic tokens (e.g.,
--tds-button-bg)
Application Styling:
- Import theme files at app root to generate CSS variables from the current theme
- Wrap app with theme class (e.g.,
<div className="theme-core">) - CSS variables cascade to all child components
Differences from components-react
- Styling: Layout tokens are compiled from SCSS instead of read from CSS variables
- Dependencies: Requires
@times-design-system/theme-scssinstead of@times-design-system/theme-css - Theme Classes: Requires wrapping components with theme classes (e.g.,
theme-core,theme-sport, etc.)
Everything else — components, props, icon handling (registerIcons, icons-all) and subpath exports — is identical; see the components-react README.
Development
- Edit component behaviour in
packages/components-react/src. - Edit styles here in
src/<Component>/styles.scss. Every component stylesheet in components-react must have an SCSS counterpart.
License
ISC
