Sharing theme tokens with the runtime
See original GitHub issueSometimes, a theme’s specific tokens may be required during runtime. E.g. for generating styles with theme-based breakpoints on the fly. I propose the following API for making values of a theme’s tokens importable from runtime:
// Component.treat.ts
import { getTokens } from 'treat';
export const sharedTokens = getTokens(
// theme => tokens
({ breakpoints, shorthands, aliases }) => ({ breakpoints, shorthands, aliases })
);
Usage:
import { sharedTokens } from './Component.treat';
export default function Component() {
return <div>{sharedTokens.breakpoints.join()}</div>;
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to use DI Token to provide different services instance at ...
This container component has one method onEmployeeList() which decides which list of employee data to load inside component at runtime.
Read more >using design tokens in your apps, and try dark theme in Jira ...
We've been busy incorporating design tokens in Jira Cloud in recent months, and building the new light/dark themes. We're thrilled to share ......
Read more >Old and new ideas in React UI
Design Tokens; Modular Scales; Theme specification; ThemeProvider in React; Styles connected to theme; Element primitive; Classes, ...
Read more >Styling Using Design Tokens - Lumo Theme - Vaadin
Learn how to use Lumo design tokens to style your application and components.
Read more >CancellationTokenSource.CreateLinkedTokenSource Method
Runtime.dll ... An array that contains the cancellation token instances to observe. ... A CancellationTokenSource that is linked to the source tokens.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah! We have a custom provider too! It wraps the ThemeProvider from treat.
@maraisr Sounds viable, thanks! I’ve been doing something similar, but was wondering whether creating a custom provider could be avoided.