Utilities for styled-components
npm install @leancodepl/styled-toolsTypeScript utilities for styled-components with type-safe theme access.
``bash`
npm install @leancodepl/styled-toolsor
yarn add @leancodepl/styled-tools
Creates type-safe theme utilities for styled-components with full TypeScript support.
Returns: Object containing theme proxy and useTheme hook
`typescript
// theme.ts
import { mkTheme } from "@leancodepl/styled-tools"
import styled from "styled-components"
interface AppTheme {
colors: { primary: string; secondary: string }
spacing: { small: string; large: string }
}
export const { theme, useTheme } = mkTheme
const Button = styled.button
color: ${theme.colors.primary};
padding: ${theme.spacing.small};`
`typescript
import React from 'react';
import { useTheme } from './theme';
function ThemedComponent() {
const theme = useTheme();
return (